55import 'package:analysis_server/src/protocol_server.dart' ;
66import 'package:analysis_server/src/services/completion/yaml/producer.dart' ;
77import 'package:analysis_server/src/services/completion/yaml/yaml_completion_generator.dart' ;
8+ import 'package:analyzer/error/error.dart' ;
89import 'package:analyzer/file_system/file_system.dart' ;
10+ import 'package:analyzer/src/dart/analysis/experiments.dart' ;
911import 'package:analyzer/src/lint/registry.dart' ;
1012import 'package:analyzer/src/task/options.dart' ;
1113
@@ -17,10 +19,10 @@ class AnalysisOptionsGenerator extends YamlCompletionGenerator {
1719 // TODO(brianwilkerson) We need to support multiple valid formats.
1820 // For example, the lint rules can either be a list or a map, but we only
1921 // suggest list items.
20- static const MapProducer analysisOptionsProducer = MapProducer ({
22+ static MapProducer analysisOptionsProducer = MapProducer ({
2123 AnalyzerOptions .analyzer: MapProducer ({
22- AnalyzerOptions .enableExperiment: EmptyProducer ( ),
23- AnalyzerOptions .errors: EmptyProducer (),
24+ AnalyzerOptions .enableExperiment: ListProducer ( _ExperimentProducer () ),
25+ AnalyzerOptions .errors: _ErrorProducer (),
2426 AnalyzerOptions .exclude: EmptyProducer (),
2527 AnalyzerOptions .language: MapProducer ({
2628 AnalyzerOptions .strictCasts: EmptyProducer (),
@@ -45,7 +47,7 @@ class AnalysisOptionsGenerator extends YamlCompletionGenerator {
4547 AnalyzerOptions .include: EmptyProducer (),
4648 // TODO(brianwilkerson) Create constants for 'linter' and 'rules'.
4749 'linter' : MapProducer ({
48- 'rules' : ListProducer (LintRuleProducer ()),
50+ 'rules' : ListProducer (_LintRuleProducer ()),
4951 }),
5052 });
5153
@@ -58,10 +60,49 @@ class AnalysisOptionsGenerator extends YamlCompletionGenerator {
5860 Producer get topLevelProducer => analysisOptionsProducer;
5961}
6062
61- class LintRuleProducer extends Producer {
63+ class _ErrorProducer extends KeyValueProducer {
64+ static const enumProducer = EnumProducer ([
65+ 'ignore' ,
66+ 'info' ,
67+ 'warning' ,
68+ 'error' ,
69+ ]);
70+
71+ @override
72+ Producer ? producerForKey (String key) => enumProducer;
73+
74+ @override
75+ Iterable <CompletionSuggestion > suggestions (
76+ YamlCompletionRequest request) sync * {
77+ for (var error in errorCodeValues) {
78+ yield identifier ('${error .name .toLowerCase ()}: ' );
79+ }
80+ for (var rule in Registry .ruleRegistry.rules) {
81+ yield identifier ('${rule .name }: ' );
82+ }
83+ }
84+ }
85+
86+ class _ExperimentProducer extends Producer {
87+ /// Initialize a location whose valid values are the names of the known
88+ /// experimental features.
89+ const _ExperimentProducer ();
90+
91+ @override
92+ Iterable <CompletionSuggestion > suggestions (
93+ YamlCompletionRequest request) sync * {
94+ for (var feature in ExperimentStatus .knownFeatures.values) {
95+ if (! feature.isEnabledByDefault) {
96+ yield identifier (feature.enableString);
97+ }
98+ }
99+ }
100+ }
101+
102+ class _LintRuleProducer extends Producer {
62103 /// Initialize a location whose valid values are the names of the registered
63104 /// lint rules.
64- const LintRuleProducer ();
105+ const _LintRuleProducer ();
65106
66107 @override
67108 Iterable <CompletionSuggestion > suggestions (
0 commit comments