Skip to content
Closed
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 @@ -58,6 +58,7 @@ class CodeScanChatController(
}

override suspend fun processStartProjectScan(message: IncomingCodeScanMessage.StartProjectScan) {
logger.debug { "Started project scan" }
if (message.tabId != codeScanChatHelper.getActiveCodeScanTabId()) return
codeScanChatHelper.addNewMessage(buildUserSelectionProjectScanChatContent())
if (!codeScanManager.isInsideWorkTree()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ class CodeWhispererCodeScanManager(val project: Project) {
* Triggers a code scan and displays results in the new tab in problems view panel.
*/
fun runCodeScan(scope: CodeWhispererConstants.CodeAnalysisScope, isPluginStarting: Boolean = false, initiatedByChat: Boolean = false) {
LOG.debug { "Started a code scan" }
if (!isQConnected(project)) return

// Return if a scan is already in progress.
Expand All @@ -320,11 +321,12 @@ class CodeWhispererCodeScanManager(val project: Project) {
isOnDemandScanInProgress.set(false)
return
}

LOG.debug { "Valid connection established for Code review/scan" }
// If scope is project
if (scope == CodeWhispererConstants.CodeAnalysisScope.PROJECT) {
// launch code scan coroutine
try {
LOG.debug("Initiating code scan routine for project")
codeScanJob = launchCodeScanCoroutine(CodeWhispererConstants.CodeAnalysisScope.PROJECT, initiatedByChat)
} catch (e: CancellationException) {
notifyChat(codeScanResponse = null, scope = scope)
Expand All @@ -337,6 +339,7 @@ class CodeWhispererCodeScanManager(val project: Project) {
}
// Add File Scan
try {
LOG.debug("Initiating code scan routine for file")
codeScanJob = launchCodeScanCoroutine(CodeWhispererConstants.CodeAnalysisScope.FILE, initiatedByChat)
} catch (e: CancellationException) {
notifyChat(codeScanResponse = null, scope = scope)
Expand Down Expand Up @@ -408,6 +411,7 @@ class CodeWhispererCodeScanManager(val project: Project) {
FileEditorManager.getInstance(project).selectedEditor?.file
}
val codeScanSessionConfig = CodeScanSessionConfig.create(file, project, scope, initiatedByChat)
LOG.debug { " Created code scan session config" }
val selectedFile = codeScanSessionConfig.getSelectedFile()
language = codeScanSessionConfig.getProgrammingLanguage()
if (scope == CodeWhispererConstants.CodeAnalysisScope.FILE &&
Expand All @@ -420,6 +424,7 @@ class CodeWhispererCodeScanManager(val project: Project) {
} else {
withTimeout(Duration.ofSeconds(codeScanSessionConfig.overallJobTimeoutInSeconds())) {
// 1. Generate truncation (zip files) based on the current editor.
LOG.debug { "Getting session context for code scan" }
val sessionContext = CodeScanSessionContext(project, codeScanSessionConfig, scope)
val session = CodeWhispererCodeScanSession(sessionContext)
val codeScanResponse = session.run()
Expand Down Expand Up @@ -650,10 +655,14 @@ class CodeWhispererCodeScanManager(val project: Project) {
* This method adds code content to the problems view if not already added.
*/
fun buildCodeScanUI() = runInEdt {
val problemsWindow = getProblemsWindow()
if (!problemsWindow.contentManager.contents.contains(codeScanIssuesContent)) {
problemsWindow.contentManager.addContent(codeScanIssuesContent)
codeScanIssuesContent.displayName = message("codewhisperer.codescan.scan_display")
try {
val problemsWindow = getProblemsWindow()
if (!problemsWindow.contentManager.contents.contains(codeScanIssuesContent)) {
problemsWindow.contentManager.addContent(codeScanIssuesContent)
codeScanIssuesContent.displayName = message("codewhisperer.codescan.scan_display")
}
} catch (e: Exception) {
LOG.debug { "Unable to open problems window" }
}
}

Expand Down
Loading