Skip to content

Commit aa6f85c

Browse files
parloughCommit Queue
authored andcommitted
[analysis_server] Don't suggest removed lints during completion
Change-Id: Ibe05a2683045e6b94852f9e3157a1048949dbd44 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389782 Reviewed-by: Phil Quitslund <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 1041fe5 commit aa6f85c

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

pkg/analysis_server/lib/src/services/completion/yaml/analysis_options_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class _LintRuleProducer extends Producer {
108108
YamlCompletionRequest request) sync* {
109109
for (var rule in Registry.ruleRegistry.rules) {
110110
// TODO(pq): consider suggesting internal lints if editing an SDK options file
111-
if (!rule.state.isInternal) {
111+
if (!rule.state.isInternal && !rule.state.isRemoved) {
112112
yield identifier(rule.name, docComplete: rule.description);
113113
}
114114
}

pkg/analysis_server/test/src/services/completion/yaml/analysis_options_generator_test.dart

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ linter:
182182
- ^
183183
- annotate_overrides
184184
''');
185-
assertSuggestion('avoid_as');
185+
assertSuggestion('always_declare_return_types');
186186
assertNoSuggestion('annotate_overrides');
187187
}
188188

@@ -193,7 +193,7 @@ linter:
193193
- annotate_overrides
194194
- ^
195195
''');
196-
assertSuggestion('avoid_as');
196+
assertSuggestion('always_declare_return_types');
197197
assertNoSuggestion('annotate_overrides');
198198
}
199199

@@ -205,7 +205,7 @@ linter:
205205
- ^
206206
- avoid_empty_else
207207
''');
208-
assertSuggestion('avoid_as');
208+
assertSuggestion('always_declare_return_types');
209209
assertNoSuggestion('annotate_overrides');
210210
assertNoSuggestion('avoid_empty_else');
211211
}
@@ -238,6 +238,18 @@ linter:
238238
assertSuggestion('annotate_overrides');
239239
}
240240

241+
void test_linter_rules_removed() {
242+
registerRule(_RemovedLint());
243+
244+
getCompletions('''
245+
linter:
246+
rules:
247+
^
248+
''');
249+
250+
assertNoSuggestion('removed_lint');
251+
}
252+
241253
@failingTest
242254
void test_topLevel_afterOtherKeys() {
243255
// This test fails because the cursor is considered to be inside the exclude
@@ -279,3 +291,17 @@ class InternalRule extends LintRule {
279291
@override
280292
LintCode get lintCode => code;
281293
}
294+
295+
class _RemovedLint extends LintRule {
296+
static const LintCode _code = LintCode('removed_lint', 'Removed rule.');
297+
298+
_RemovedLint()
299+
: super(
300+
name: 'removed_lint',
301+
state: State.removed(),
302+
description: '',
303+
);
304+
305+
@override
306+
LintCode get lintCode => _code;
307+
}

0 commit comments

Comments
 (0)