Skip to content

Commit b8cf6ba

Browse files
srawlinsCommit Queue
authored andcommitted
DAS plugins: Wire up priority files
This is super awkward. I had "added support" in f27e78af6b20 but it was really just internal wiring. I honestly do not remember what I was thinking or why I landed that CL incomplete. Change-Id: Iad6800e11df189879acad4d189d6f8c68ee673f4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449602 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 9f55bda commit b8cf6ba

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

pkg/analysis_server_plugin/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- Add support for automatic re-analysis of files changed on-disk (as opposed to
66
file contents changed in the IDE, which is already supported).
77
- Add support for analyzing and reporting diagnostics in part files.
8+
- Add support for `RuleContext.isInLibDir` and `RuleContext.package`.
9+
- Add support for priority files in an IDE.
10+
- Correct the text range over which fixes are calculated.
811
- Breaking change: a `Plugin` class must now implement `String get name`.
912

1013
## 0.2.2

pkg/analysis_server_plugin/lib/src/plugin_server.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import 'package:analyzer_plugin/protocol/protocol_common.dart' as protocol;
4343
import 'package:analyzer_plugin/protocol/protocol_constants.dart' as protocol;
4444
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as protocol;
4545
import 'package:analyzer_plugin/src/protocol/protocol_internal.dart';
46+
import 'package:meta/meta.dart';
4647

4748
/// A pair, matching a [Diagnostic] with it's equivalent
4849
/// [protocol.AnalysisError].
@@ -101,6 +102,9 @@ class PluginServer {
101102
PluginRegistryImpl.registerIgnoreProducerGenerators();
102103
}
103104

105+
@visibleForTesting
106+
Set<String> get priorityPaths => {..._priorityPaths};
107+
104108
/// Handles an 'analysis.setPriorityFiles' request.
105109
///
106110
/// Throws a [RequestFailure] if the request could not be handled.
@@ -561,8 +565,10 @@ class PluginServer {
561565
result = await _handleAnalysisSetContextRoots(params);
562566

563567
case protocol.ANALYSIS_REQUEST_SET_PRIORITY_FILES:
564-
// TODO(srawlins): Support!
565-
result = null;
568+
var params = protocol.AnalysisSetPriorityFilesParams.fromRequest(
569+
request,
570+
);
571+
result = await handleAnalysisSetPriorityFiles(params);
566572

567573
case protocol.ANALYSIS_REQUEST_UPDATE_CONTENT:
568574
var params = protocol.AnalysisUpdateContentParams.fromRequest(request);

pkg/analysis_server_plugin/test/src/plugin_server_test.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,41 @@ bool b = false;
306306
expect(params.errors, isEmpty);
307307
}
308308

309+
Future<void> test_setPriorityFiles() async {
310+
newFile(filePath, '''
311+
int a = 0;
312+
''');
313+
newFile(file2Path, '''
314+
int b = 1;
315+
''');
316+
await channel.sendRequest(
317+
protocol.AnalysisSetContextRootsParams([contextRoot]),
318+
);
319+
320+
var paramsQueue = _analysisErrorsParams;
321+
var params = await paramsQueue.next;
322+
expect(params.file, filePath);
323+
324+
params = await paramsQueue.next;
325+
expect(params.file, file2Path);
326+
327+
await channel.sendRequest(
328+
protocol.AnalysisSetPriorityFilesParams([file2Path]),
329+
);
330+
331+
expect(pluginServer.priorityPaths, {file2Path});
332+
333+
await channel.sendRequest(
334+
protocol.AnalysisSetContextRootsParams([contextRoot]),
335+
);
336+
337+
params = await paramsQueue.next;
338+
expect(params.file, file2Path);
339+
340+
params = await paramsQueue.next;
341+
expect(params.file, filePath);
342+
}
343+
309344
Future<void> test_unsupportedRequest() async {
310345
writeAnalysisOptionsWithPlugin();
311346
newFile(filePath, 'bool b = false;');

0 commit comments

Comments
 (0)