@@ -256,8 +256,7 @@ private AnalysisConfiguration getAnalysisConfigForEngine(String configScopeId, S
256
256
var analysisProperties = analysisConfig .getAnalysisProperties ();
257
257
var inferredAnalysisProperties = startChild (trace , "getInferredAnalysisProperties" , ANALYSIS_CFG_FOR_ENGINE ,
258
258
() -> client .getInferredAnalysisProperties (new GetInferredAnalysisPropertiesParams (
259
- configScopeId , filesToAnalyze .stream ().map (ClientFile ::getUri ).toList ()
260
- )).join ().getProperties ());
259
+ configScopeId , filesToAnalyze .stream ().map (ClientFile ::getUri ).toList ())).join ().getProperties ());
261
260
analysisProperties .putAll (inferredAnalysisProperties );
262
261
var activeRules = analysisConfig .getActiveRules ().stream ().map (r -> {
263
262
var ar = new ActiveRule (r .getRuleKey (), r .getLanguageKey ());
@@ -266,8 +265,7 @@ private AnalysisConfiguration getAnalysisConfigForEngine(String configScopeId, S
266
265
return ar ;
267
266
}).toList ();
268
267
trace .setData ("activeRulesCount" , activeRules .size ());
269
- return startChild (trace , "buildAnalysisConfiguration" , ANALYSIS_CFG_FOR_ENGINE , () ->
270
- AnalysisConfiguration .builder ()
268
+ return startChild (trace , "buildAnalysisConfiguration" , ANALYSIS_CFG_FOR_ENGINE , () -> AnalysisConfiguration .builder ()
271
269
.addInputFiles (filesToAnalyze .stream ().map (BackendInputFile ::new ).toList ())
272
270
.putAllExtraProperties (analysisProperties )
273
271
// properties sent by client using new API were merged above
@@ -515,16 +513,13 @@ public void onPluginsSynchronized(PluginsSynchronizedEvent event) {
515
513
var connectionId = event .connectionId ();
516
514
checkIfReadyForAnalysis (configurationRepository .getBoundScopesToConnection (connectionId )
517
515
.stream ().map (BoundScope ::getConfigScopeId ).collect (Collectors .toSet ()));
518
- configurationRepository .getBoundScopesToConnection (connectionId )
519
- .stream ().map (BoundScope ::getConfigScopeId ).forEach (this ::autoAnalyzeOpenFiles );
520
516
}
521
517
522
518
@ EventListener
523
519
public void onConfigurationScopeAdded (ConfigurationScopesAddedWithBindingEvent event ) {
524
520
var configScopeIds = event .getConfigScopeIds ();
525
521
configScopeIds .forEach (schedulerCache ::registerModuleIfLeafConfigScope );
526
522
checkIfReadyForAnalysis (configScopeIds );
527
- configScopeIds .forEach (this ::autoAnalyzeOpenFiles );
528
523
}
529
524
530
525
@ EventListener
@@ -537,22 +532,17 @@ public void onConfigurationScopeRemoved(ConfigurationScopeRemovedEvent event) {
537
532
@ EventListener
538
533
public void onBindingConfigurationChanged (BindingConfigChangedEvent event ) {
539
534
var configScopeId = event .configScopeId ();
540
- analysisReadinessByConfigScopeId .remove (configScopeId );
541
- if (!checkIfReadyForAnalysis (configScopeId )) {
542
- client .didChangeAnalysisReadiness (new DidChangeAnalysisReadinessParams (Set .of (configScopeId ), false ));
543
- }
535
+ checkIfReadyForAnalysis (Set .of (configScopeId ));
544
536
}
545
537
546
538
@ EventListener
547
539
public void onAnalyzerConfigurationSynchronized (AnalyzerConfigurationSynchronized event ) {
548
540
checkIfReadyForAnalysis (event .getConfigScopeIds ());
549
- event .getConfigScopeIds ().forEach (this ::autoAnalyzeOpenFiles );
550
541
}
551
542
552
543
@ EventListener
553
544
public void onConfigurationScopesSynchronized (ConfigurationScopesSynchronizedEvent event ) {
554
545
checkIfReadyForAnalysis (event .getConfigScopeIds ());
555
- event .getConfigScopeIds ().forEach (this ::autoAnalyzeOpenFiles );
556
546
}
557
547
558
548
@ EventListener
@@ -651,38 +641,34 @@ private void streamIssue(String configScopeId, UUID analysisId, ConcurrentHashMa
651
641
}
652
642
653
643
private void checkIfReadyForAnalysis (Set <String > configurationScopeIds ) {
654
- var readyConfigScopeIds = configurationScopeIds .stream ()
655
- .filter (this ::isReadyForAnalysis )
656
- .collect (toSet ());
657
- saveAndNotifyReadyForAnalysis (readyConfigScopeIds );
658
- }
659
-
660
- private boolean checkIfReadyForAnalysis (String configurationScopeId ) {
661
- if (isReadyForAnalysis (configurationScopeId )) {
662
- saveAndNotifyReadyForAnalysis (Set .of (configurationScopeId ));
663
- return true ;
664
- }
665
- return false ;
666
- }
667
-
668
- private void saveAndNotifyReadyForAnalysis (Set <String > configScopeIds ) {
669
- var scopeIdsThatBecameReady = new HashSet <String >();
670
- configScopeIds .forEach (configScopeId -> {
671
- if (analysisReadinessByConfigScopeId .get (configScopeId ) != Boolean .TRUE ) {
672
- analysisReadinessByConfigScopeId .put (configScopeId , Boolean .TRUE );
673
- scopeIdsThatBecameReady .add (configScopeId );
644
+ var readyConfigScopeIds = new HashSet <String >();
645
+ var scopeThatBecameReady = new HashSet <String >();
646
+ var scopeThatBecameNotReady = new HashSet <String >();
647
+ configurationScopeIds .forEach (configScopeId -> {
648
+ var readyForAnalysis = isReadyForAnalysis (configScopeId );
649
+ var wasReady = analysisReadinessByConfigScopeId .put (configScopeId , readyForAnalysis );
650
+ if (readyForAnalysis && !Boolean .TRUE .equals (wasReady )) {
651
+ scopeThatBecameReady .add (configScopeId );
652
+ } else if (!readyForAnalysis && Boolean .TRUE .equals (wasReady )) {
653
+ scopeThatBecameNotReady .add (configScopeId );
654
+ }
655
+ if (readyForAnalysis ) {
656
+ readyConfigScopeIds .add (configScopeId );
674
657
}
675
658
});
676
- if (!scopeIdsThatBecameReady .isEmpty ()) {
677
- reanalyseOpenFiles (scopeIdsThatBecameReady ::contains );
678
- scopeIdsThatBecameReady .forEach (scopeId -> {
659
+ if (!scopeThatBecameReady .isEmpty ()) {
660
+ scopeThatBecameReady .forEach (scopeId -> {
679
661
var scheduler = schedulerCache .getOrCreateAnalysisScheduler (scopeId );
680
662
if (scheduler != null ) {
681
663
scheduler .wakeUp ();
682
664
}
683
665
});
684
- client .didChangeAnalysisReadiness (new DidChangeAnalysisReadinessParams (scopeIdsThatBecameReady , true ));
666
+ client .didChangeAnalysisReadiness (new DidChangeAnalysisReadinessParams (scopeThatBecameReady , true ));
667
+ }
668
+ if (!scopeThatBecameNotReady .isEmpty ()) {
669
+ client .didChangeAnalysisReadiness (new DidChangeAnalysisReadinessParams (scopeThatBecameNotReady , false ));
685
670
}
671
+ reanalyseOpenFiles (readyConfigScopeIds ::contains );
686
672
}
687
673
688
674
private boolean isReadyForAnalysis (String configScopeId ) {
@@ -797,8 +783,7 @@ private void analysisStarted(String configurationScopeId, UUID analysisId, List<
797
783
798
784
private CompletableFuture <AnalysisResult > schedule (String configScopeId , AnalyzeCommand command , UUID analysisId , ArrayList <RawIssue > rawIssues ,
799
785
boolean shouldFetchServerIssues , @ Nullable Trace trace ) {
800
- var scheduler = startChild (trace , "getOrCreateAnalysisScheduler" , "schedule" , () ->
801
- schedulerCache .getOrCreateAnalysisScheduler (configScopeId , command .getTrace ()));
786
+ var scheduler = startChild (trace , "getOrCreateAnalysisScheduler" , "schedule" , () -> schedulerCache .getOrCreateAnalysisScheduler (configScopeId , command .getTrace ()));
802
787
startChild (trace , "post" , "schedule" , () -> scheduler .post (command ));
803
788
var result = command .getFutureResult ();
804
789
result .exceptionally (exception -> {
0 commit comments