Skip to content

Commit

Permalink
DAS plugins: Simplify the set of analyzed paths with Sets
Browse files Browse the repository at this point in the history
Change-Id: I1d7bd2e1935d8daa455315c04adcff01d037934c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397181
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Samuel Rawlins <[email protected]>
  • Loading branch information
srawlins authored and Commit Queue committed Nov 22, 2024
1 parent 44a8f14 commit db021fa
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions pkg/analysis_server_plugin/lib/src/plugin_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class PluginServer {
// YAML files for analysis options and pubspec analysis and quick
// fixes.
.where((p) => file_paths.isDart(_resourceProvider.pathContext, p))
.toList();
.toSet();

await _analyzeFiles(
analysisContext: analysisContext,
Expand All @@ -211,37 +211,30 @@ class PluginServer {
}) async {
var file = _resourceProvider.getFile(path);
var analysisOptions = analysisContext.getAnalysisOptionsForFile(file);
var lints = await _computeLints(
var diagnostics = await _computeLints(
analysisContext,
path,
analysisOptions: analysisOptions as AnalysisOptionsImpl,
);
_channel.sendNotification(
protocol.AnalysisErrorsParams(path, lints).toNotification());
protocol.AnalysisErrorsParams(path, diagnostics).toNotification());
}

/// Analyzes the files at the given [paths].
Future<void> _analyzeFiles({
required AnalysisContext analysisContext,
required List<String> paths,
required Set<String> paths,
}) async {
var pathSet = paths.toSet();

// First analyze priority files.
for (var path in _priorityPaths) {
pathSet.remove(path);
await _analyzeFile(
analysisContext: analysisContext,
path: path,
);
if (paths.remove(path)) {
await _analyzeFile(analysisContext: analysisContext, path: path);
}
}

// Then analyze the remaining files.
for (var path in pathSet) {
await _analyzeFile(
analysisContext: analysisContext,
path: path,
);
for (var path in paths) {
await _analyzeFile(analysisContext: analysisContext, path: path);
}
}

Expand Down Expand Up @@ -411,9 +404,8 @@ class PluginServer {
required AnalysisContext analysisContext,
required List<String> paths,
}) async {
var analyzedPaths = paths
.where(analysisContext.contextRoot.isAnalyzed)
.toList(growable: false);
var analyzedPaths =
paths.where(analysisContext.contextRoot.isAnalyzed).toSet();

await _analyzeFiles(
analysisContext: analysisContext,
Expand Down

0 comments on commit db021fa

Please sign in to comment.