@@ -8,6 +8,7 @@ import com.intellij.ide.fileTemplates.FileTemplateUtil
8
8
import com.intellij.ide.fileTemplates.JavaTemplateUtil
9
9
import com.intellij.ide.highlighter.JavaFileType
10
10
import com.intellij.openapi.application.ApplicationManager
11
+ import com.intellij.openapi.application.invokeLater
11
12
import com.intellij.openapi.application.runReadAction
12
13
import com.intellij.openapi.application.runWriteAction
13
14
import com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction
@@ -157,7 +158,10 @@ object CodeGenerationController {
157
158
}
158
159
proc.forceTermination()
159
160
UtTestsDialogProcessor .updateIndicator(indicator, UtTestsDialogProcessor .ProgressRange .SARIF , " Start tests with coverage" , 1.0 )
160
- runInspectionsIfNeeded(model.project, srcClassPathToSarifReport)
161
+
162
+ invokeLater {
163
+ runInspectionsIfNeeded(model.project, srcClassPathToSarifReport)
164
+ }
161
165
}
162
166
}
163
167
}
@@ -686,6 +690,7 @@ object CodeGenerationController {
686
690
// uploading formatted code
687
691
val file = filePointer.containingFile
688
692
693
+ val srcClassPath = srcClass.containingFile.virtualFile.toNioPath()
689
694
val sarifReport = saveSarifReport(
690
695
proc,
691
696
testSetsId,
@@ -694,10 +699,10 @@ object CodeGenerationController {
694
699
model,
695
700
reportsCountDown,
696
701
file?.text ? : generatedTestsCode,
702
+ srcClassPathToSarifReport,
703
+ srcClassPath,
697
704
indicator
698
705
)
699
- val srcClassPath = srcClass.containingFile.virtualFile.toNioPath()
700
- srcClassPathToSarifReport[srcClassPath] = sarifReport
701
706
702
707
unblockDocument(testClassUpdated.project, editor.document)
703
708
}
@@ -734,21 +739,33 @@ object CodeGenerationController {
734
739
model : GenerateTestsModel ,
735
740
reportsCountDown : CountDownLatch ,
736
741
generatedTestsCode : String ,
742
+ srcClassPathToSarifReport : MutableMap <Path , Sarif >,
743
+ srcClassPath : Path ,
737
744
indicator : ProgressIndicator
738
- ): Sarif {
745
+ ) {
739
746
val project = model.project
740
747
741
- return try {
748
+ try {
742
749
// saving sarif report
743
- SarifReportIdea .createAndSave(proc, testSetsId, testClassId, model, generatedTestsCode, testClass, reportsCountDown, indicator)
750
+ SarifReportIdea .createAndSave(
751
+ proc,
752
+ testSetsId,
753
+ testClassId,
754
+ model,
755
+ generatedTestsCode,
756
+ testClass,
757
+ reportsCountDown,
758
+ srcClassPathToSarifReport,
759
+ srcClassPath,
760
+ indicator
761
+ )
744
762
} catch (e: Exception ) {
745
763
logger.error(e) { " error in saving sarif report" }
746
764
showErrorDialogLater(
747
765
project,
748
766
message = " Cannot save Sarif report via generated tests: error occurred '${e.message} '" ,
749
767
title = " Failed to save Sarif report"
750
768
)
751
- Sarif .empty()
752
769
}
753
770
}
754
771
0 commit comments