Skip to content

Commit db021fa

Browse files
srawlinsCommit Queue
authored andcommitted
DAS plugins: Simplify the set of analyzed paths with Sets
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]>
1 parent 44a8f14 commit db021fa

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

pkg/analysis_server_plugin/lib/src/plugin_server.dart

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class PluginServer {
196196
// YAML files for analysis options and pubspec analysis and quick
197197
// fixes.
198198
.where((p) => file_paths.isDart(_resourceProvider.pathContext, p))
199-
.toList();
199+
.toSet();
200200

201201
await _analyzeFiles(
202202
analysisContext: analysisContext,
@@ -211,37 +211,30 @@ class PluginServer {
211211
}) async {
212212
var file = _resourceProvider.getFile(path);
213213
var analysisOptions = analysisContext.getAnalysisOptionsForFile(file);
214-
var lints = await _computeLints(
214+
var diagnostics = await _computeLints(
215215
analysisContext,
216216
path,
217217
analysisOptions: analysisOptions as AnalysisOptionsImpl,
218218
);
219219
_channel.sendNotification(
220-
protocol.AnalysisErrorsParams(path, lints).toNotification());
220+
protocol.AnalysisErrorsParams(path, diagnostics).toNotification());
221221
}
222222

223223
/// Analyzes the files at the given [paths].
224224
Future<void> _analyzeFiles({
225225
required AnalysisContext analysisContext,
226-
required List<String> paths,
226+
required Set<String> paths,
227227
}) async {
228-
var pathSet = paths.toSet();
229-
230228
// First analyze priority files.
231229
for (var path in _priorityPaths) {
232-
pathSet.remove(path);
233-
await _analyzeFile(
234-
analysisContext: analysisContext,
235-
path: path,
236-
);
230+
if (paths.remove(path)) {
231+
await _analyzeFile(analysisContext: analysisContext, path: path);
232+
}
237233
}
238234

239235
// Then analyze the remaining files.
240-
for (var path in pathSet) {
241-
await _analyzeFile(
242-
analysisContext: analysisContext,
243-
path: path,
244-
);
236+
for (var path in paths) {
237+
await _analyzeFile(analysisContext: analysisContext, path: path);
245238
}
246239
}
247240

@@ -411,9 +404,8 @@ class PluginServer {
411404
required AnalysisContext analysisContext,
412405
required List<String> paths,
413406
}) async {
414-
var analyzedPaths = paths
415-
.where(analysisContext.contextRoot.isAnalyzed)
416-
.toList(growable: false);
407+
var analyzedPaths =
408+
paths.where(analysisContext.contextRoot.isAnalyzed).toSet();
417409

418410
await _analyzeFiles(
419411
analysisContext: analysisContext,

0 commit comments

Comments
 (0)