Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
try {
launchTestGenFlow(prompt, codeTestChatHelper, previousIterationContext, selectionRange)
} catch (e: Exception) {
// reset number of unitTestGenerated to null
session.numberOfUnitTestCasesGenerated = null
// Add an answer for displaying error message
val errorMessage = when {
e is CodeTestException &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.intellij.diff.DiffManagerEx
import com.intellij.diff.requests.SimpleDiffRequest
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.guessProjectDir
Expand Down Expand Up @@ -473,16 +472,14 @@ class CodeTestChatController(
)
session.openedDiffFile = FileEditorManager.getInstance(context.project).selectedEditor?.file
ApplicationManager.getApplication().runReadAction {
generatedFileContent = getFileContentAtTestFilePath(
session.projectRoot,
session.testFileRelativePathToProjectRoot
)
val selectedFile = FileEditorManager.getInstance(context.project).selectedEditor?.file
selectedFileContent = selectedFile?.let {
FileDocumentManager.getInstance().getDocument(it)?.text
}.orEmpty()
generatedFileContent = getGeneratedFileContent(session)
}

selectedFileContent = getFileContentAtTestFilePath(
session.projectRoot,
session.testFileRelativePathToProjectRoot,
)

// Line difference calculation: linesOfCodeGenerated = number of lines in generated test file - number of lines in original test file
numberOfLinesGenerated = generatedFileContent.lines().size
numberOfLinesSelected = selectedFileContent.lines().size
Expand Down Expand Up @@ -1070,6 +1067,12 @@ class CodeTestChatController(
}
}

// Return generated test file content
private fun getGeneratedFileContent(session: Session): String {
val generateFileContent = session.generatedTestDiffs[session.testFileRelativePathToProjectRoot].toString()
return generateFileContent
}

/*
If shortAnswer has buildCommand, use it, if it doesn't hardcode it according to the user type(internal or not)
private fun getBuildCommand(tabId: String): String {
Expand Down
Loading