@@ -4,35 +4,12 @@ import com.intellij.openapi.project.Project
44import com.intellij.openapi.wm.ToolWindow
55import com.intellij.openapi.wm.ToolWindowFactory
66import com.intellij.ui.content.ContentFactory
7- import com.offensive360.sast.util.ScanCache
87
98class SecurityFindingsToolWindowFactory : ToolWindowFactory {
109 override fun createToolWindowContent (project : Project , toolWindow : ToolWindow ) {
1110 val panel = SecurityFindingsPanel (project)
1211 val content = ContentFactory .getInstance().createContent(panel.component, " " , false )
1312 toolWindow.contentManager.addContent(content)
1413 SecurityFindingsService .getInstance(project).toolWindowPanel = panel
15-
16- // Load cached results on background thread to avoid freezing the UI
17- val projectBasePath = project.basePath
18- if (projectBasePath != null ) {
19- com.intellij.openapi.application.ApplicationManager .getApplication().executeOnPooledThread {
20- try {
21- val cached = ScanCache .load(projectBasePath)
22- if (cached != null && cached.findings.isNotEmpty()) {
23- val cachedFiles = cached.fileHashes.keys.map { java.io.File (it) }
24- val currentHashes = ScanCache .computeFileHashes(cachedFiles)
25- com.intellij.openapi.application.ApplicationManager .getApplication().invokeLater {
26- if (ScanCache .hasFilesChanged(currentHashes, cached.fileHashes)) {
27- panel.setStatus(" Code has changed since last scan. Run a new scan for updated results." )
28- } else {
29- panel.showFindings(cached.findings)
30- panel.setStatus(" Showing ${cached.findings.size} cached finding${if (cached.findings.size != 1 ) " s" else " " } from previous scan" )
31- }
32- }
33- }
34- } catch (_: Exception ) { }
35- }
36- }
3714 }
3815}
0 commit comments