From 939134338742c86e8aff177cd1703d3261684398 Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Thu, 14 Jul 2022 14:54:14 +0000 Subject: [PATCH] Invoke analyzeFiles() from handleAffectedFiles() only for analyzed files. Bug: https://github.com/dart-lang/sdk/issues/49404 Change-Id: I6e80394d28a51182b622ab113a5a6376dbde13ef Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251442 Commit-Queue: Konstantin Shcheglov Reviewed-by: Brian Wilkerson --- pkg/analyzer_plugin/CHANGELOG.md | 4 ++++ pkg/analyzer_plugin/lib/plugin/plugin.dart | 9 +++++++-- pkg/analyzer_plugin/pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/analyzer_plugin/CHANGELOG.md b/pkg/analyzer_plugin/CHANGELOG.md index 99be7f52a4b..d4e45858a68 100644 --- a/pkg/analyzer_plugin/CHANGELOG.md +++ b/pkg/analyzer_plugin/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.11.1 +- Call `analyzeFiles` from `handleAffectedFiles` only for files that are + analyzed in this analysis context. + ## 0.11.0 - Using `AnalysisContextCollection` and `AnalysisContext` for analysis. diff --git a/pkg/analyzer_plugin/lib/plugin/plugin.dart b/pkg/analyzer_plugin/lib/plugin/plugin.dart index fe76e5693fa..3f7bb5dde32 100644 --- a/pkg/analyzer_plugin/lib/plugin/plugin.dart +++ b/pkg/analyzer_plugin/lib/plugin/plugin.dart @@ -198,14 +198,19 @@ abstract class ServerPlugin { /// one or more files. The implementation may check if these files should /// be analyzed, do such analysis, and send diagnostics. /// - /// By default invokes [analyzeFiles]. + /// By default invokes [analyzeFiles] only for files that are analyzed in + /// this [analysisContext]. Future handleAffectedFiles({ required AnalysisContext analysisContext, required List paths, }) async { + final analyzedPaths = paths + .where(analysisContext.contextRoot.isAnalyzed) + .toList(growable: false); + await analyzeFiles( analysisContext: analysisContext, - paths: paths, + paths: analyzedPaths, ); } diff --git a/pkg/analyzer_plugin/pubspec.yaml b/pkg/analyzer_plugin/pubspec.yaml index 2b61963b11f..ad43abd91dc 100644 --- a/pkg/analyzer_plugin/pubspec.yaml +++ b/pkg/analyzer_plugin/pubspec.yaml @@ -1,6 +1,6 @@ name: analyzer_plugin description: A framework and support code for building plugins for the analysis server. -version: 0.11.0 +version: 0.11.1 repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer_plugin environment: