Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: pkg/analyzer/lib/src/task/options.dart

Issue 1412573012: Option support for `enableGenericMethods`. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.task.options; 5 library analyzer.src.task.options;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/plugin/options.dart'; 8 import 'package:analyzer/plugin/options.dart';
9 import 'package:analyzer/source/analysis_options_provider.dart'; 9 import 'package:analyzer/source/analysis_options_provider.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
(...skipping 17 matching lines...) Expand all
28 28
29 /// Configure this [context] based on configuration details specified in 29 /// Configure this [context] based on configuration details specified in
30 /// the given [options]. 30 /// the given [options].
31 void configureContextOptions( 31 void configureContextOptions(
32 AnalysisContext context, Map<String, YamlNode> options) => 32 AnalysisContext context, Map<String, YamlNode> options) =>
33 _processor.configure(context, options); 33 _processor.configure(context, options);
34 34
35 /// `analyzer` analysis options constants. 35 /// `analyzer` analysis options constants.
36 class AnalyzerOptions { 36 class AnalyzerOptions {
37 static const String analyzer = 'analyzer'; 37 static const String analyzer = 'analyzer';
38 static const String enableGenericMethods = 'enableGenericMethods';
38 static const String enableSuperMixins = 'enableSuperMixins'; 39 static const String enableSuperMixins = 'enableSuperMixins';
39 static const String errors = 'errors'; 40 static const String errors = 'errors';
40 static const String exclude = 'exclude'; 41 static const String exclude = 'exclude';
41 static const String language = 'language'; 42 static const String language = 'language';
42 static const String plugins = 'plugins'; 43 static const String plugins = 'plugins';
43 static const String strong_mode = 'strong-mode'; 44 static const String strong_mode = 'strong-mode';
44 45
45 /// Ways to say `ignore`. 46 /// Ways to say `ignore`.
46 static const List<String> ignoreSynonyms = const ['ignore', 'false']; 47 static const List<String> ignoreSynonyms = const ['ignore', 'false'];
47 48
48 /// Ways to say `include`. 49 /// Ways to say `include`.
49 static const List<String> includeSynonyms = const ['include', 'true']; 50 static const List<String> includeSynonyms = const ['include', 'true'];
50 51
51 /// Ways to say `true` or `false`. 52 /// Ways to say `true` or `false`.
52 static const List<String> trueOrFalse = const ['true', 'false']; 53 static const List<String> trueOrFalse = const ['true', 'false'];
53 54
54 /// Supported top-level `analyzer` options. 55 /// Supported top-level `analyzer` options.
55 static const List<String> topLevel = const [ 56 static const List<String> topLevel = const [
56 errors, 57 errors,
57 exclude, 58 exclude,
58 language, 59 language,
59 plugins, 60 plugins,
60 strong_mode 61 strong_mode
61 ]; 62 ];
62 63
63 /// Supported `analyzer` language configuration options. 64 /// Supported `analyzer` language configuration options.
64 static const List<String> languageOptions = const [enableSuperMixins]; 65 static const List<String> languageOptions = const [
66 enableGenericMethods,
67 enableSuperMixins
68 ];
65 } 69 }
66 70
67 /// Validates `analyzer` options. 71 /// Validates `analyzer` options.
68 class AnalyzerOptionsValidator extends CompositeValidator { 72 class AnalyzerOptionsValidator extends CompositeValidator {
69 AnalyzerOptionsValidator() 73 AnalyzerOptionsValidator()
70 : super([ 74 : super([
71 new TopLevelAnalyzerOptionsValidator(), 75 new TopLevelAnalyzerOptionsValidator(),
72 new ErrorFilterOptionValidator(), 76 new ErrorFilterOptionValidator(),
73 new LanguageOptionValidator() 77 new LanguageOptionValidator()
74 ]); 78 ]);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 388
385 void setLanguageOptions(AnalysisContext context, YamlNode configs) { 389 void setLanguageOptions(AnalysisContext context, YamlNode configs) {
386 if (configs is YamlMap) { 390 if (configs is YamlMap) {
387 configs.nodes.forEach((k, v) { 391 configs.nodes.forEach((k, v) {
388 String feature; 392 String feature;
389 if (k is YamlScalar && v is YamlScalar) { 393 if (k is YamlScalar && v is YamlScalar) {
390 feature = k.value?.toString(); 394 feature = k.value?.toString();
391 if (feature == AnalyzerOptions.enableSuperMixins) { 395 if (feature == AnalyzerOptions.enableSuperMixins) {
392 if (isTrue(v.value)) { 396 if (isTrue(v.value)) {
393 AnalysisOptionsImpl options = 397 AnalysisOptionsImpl options =
394 new AnalysisOptionsImpl.from(context.analysisOptions); 398 new AnalysisOptionsImpl.from(context.analysisOptions);
395 options.enableSuperMixins = true; 399 options.enableSuperMixins = true;
396 context.analysisOptions = options; 400 context.analysisOptions = options;
397 } 401 }
398 } 402 }
403 if (feature == AnalyzerOptions.enableGenericMethods) {
404 if (isTrue(v.value)) {
405 AnalysisOptionsImpl options =
406 new AnalysisOptionsImpl.from(context.analysisOptions);
407 options.enableGenericMethods = true;
408 context.analysisOptions = options;
409 }
410 }
399 } 411 }
400 }); 412 });
401 } 413 }
402 } 414 }
403 415
404 void setStrongMode(AnalysisContext context, bool strongMode) { 416 void setStrongMode(AnalysisContext context, bool strongMode) {
405 if (context.analysisOptions.strongMode != strongMode) { 417 if (context.analysisOptions.strongMode != strongMode) {
406 AnalysisOptionsImpl options = 418 AnalysisOptionsImpl options =
407 new AnalysisOptionsImpl.from(context.analysisOptions); 419 new AnalysisOptionsImpl.from(context.analysisOptions);
408 options.strongMode = strongMode; 420 options.strongMode = strongMode;
409 context.analysisOptions = options; 421 context.analysisOptions = options;
410 } 422 }
411 } 423 }
412 } 424 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698