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

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

Issue 2282233002: Add support for parsing, but not capturing, assers in constructor initializer lists (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: add flag Created 4 years, 3 months 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
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/analyzer.dart'; 9 import 'package:analyzer/analyzer.dart';
10 import 'package:analyzer/plugin/options.dart'; 10 import 'package:analyzer/plugin/options.dart';
(...skipping 27 matching lines...) Expand all
38 38
39 /// Configure this [context] based on configuration details specified in 39 /// Configure this [context] based on configuration details specified in
40 /// the given [options]. If [options] is `null`, default values are applied. 40 /// the given [options]. If [options] is `null`, default values are applied.
41 void configureContextOptions( 41 void configureContextOptions(
42 AnalysisContext context, Map<String, Object> options) => 42 AnalysisContext context, Map<String, Object> options) =>
43 _processor.configure(context, options); 43 _processor.configure(context, options);
44 44
45 /// `analyzer` analysis options constants. 45 /// `analyzer` analysis options constants.
46 class AnalyzerOptions { 46 class AnalyzerOptions {
47 static const String analyzer = 'analyzer'; 47 static const String analyzer = 'analyzer';
48 static const String enableAssertInitializer = 'enableAssertInitializer';
48 static const String enableAsync = 'enableAsync'; 49 static const String enableAsync = 'enableAsync';
49 static const String enableGenericMethods = 'enableGenericMethods'; 50 static const String enableGenericMethods = 'enableGenericMethods';
50 static const String enableStrictCallChecks = 'enableStrictCallChecks'; 51 static const String enableStrictCallChecks = 'enableStrictCallChecks';
51 static const String enableSuperMixins = 'enableSuperMixins'; 52 static const String enableSuperMixins = 'enableSuperMixins';
52 53
53 static const String errors = 'errors'; 54 static const String errors = 'errors';
54 static const String exclude = 'exclude'; 55 static const String exclude = 'exclude';
55 static const String language = 'language'; 56 static const String language = 'language';
56 static const String plugins = 'plugins'; 57 static const String plugins = 'plugins';
57 static const String strong_mode = 'strong-mode'; 58 static const String strong_mode = 'strong-mode';
(...skipping 19 matching lines...) Expand all
77 static const List<String> topLevel = const [ 78 static const List<String> topLevel = const [
78 errors, 79 errors,
79 exclude, 80 exclude,
80 language, 81 language,
81 plugins, 82 plugins,
82 strong_mode 83 strong_mode
83 ]; 84 ];
84 85
85 /// Supported `analyzer` language configuration options. 86 /// Supported `analyzer` language configuration options.
86 static const List<String> languageOptions = const [ 87 static const List<String> languageOptions = const [
88 enableAssertInitializer,
87 enableAsync, 89 enableAsync,
88 enableGenericMethods, 90 enableGenericMethods,
89 enableStrictCallChecks, 91 enableStrictCallChecks,
90 enableSuperMixins 92 enableSuperMixins
91 ]; 93 ];
92 } 94 }
93 95
94 /// Validates `analyzer` options. 96 /// Validates `analyzer` options.
95 class AnalyzerOptionsValidator extends CompositeValidator { 97 class AnalyzerOptionsValidator extends CompositeValidator {
96 AnalyzerOptionsValidator() 98 AnalyzerOptionsValidator()
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 if (excludes is YamlList) { 473 if (excludes is YamlList) {
472 List<String> excludeList = toStringList(excludes); 474 List<String> excludeList = toStringList(excludes);
473 if (excludeList != null) { 475 if (excludeList != null) {
474 context.setConfigurationData(CONTEXT_EXCLUDES, excludeList); 476 context.setConfigurationData(CONTEXT_EXCLUDES, excludeList);
475 } 477 }
476 } 478 }
477 } 479 }
478 480
479 void setLanguageOption( 481 void setLanguageOption(
480 AnalysisContext context, Object feature, Object value) { 482 AnalysisContext context, Object feature, Object value) {
483 if (feature == AnalyzerOptions.enableAssertInitializer) {
484 if (isTrue(value)) {
485 AnalysisOptionsImpl options =
486 new AnalysisOptionsImpl.from(context.analysisOptions);
487 options.enableAssertInitializer = true;
488 context.analysisOptions = options;
489 }
490 }
481 if (feature == AnalyzerOptions.enableAsync) { 491 if (feature == AnalyzerOptions.enableAsync) {
482 if (isFalse(value)) { 492 if (isFalse(value)) {
483 AnalysisOptionsImpl options = 493 AnalysisOptionsImpl options =
484 new AnalysisOptionsImpl.from(context.analysisOptions); 494 new AnalysisOptionsImpl.from(context.analysisOptions);
485 options.enableAsync = false; 495 options.enableAsync = false;
486 context.analysisOptions = options; 496 context.analysisOptions = options;
487 } 497 }
488 } 498 }
489 if (feature == AnalyzerOptions.enableStrictCallChecks) { 499 if (feature == AnalyzerOptions.enableStrictCallChecks) {
490 if (isTrue(value)) { 500 if (isTrue(value)) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 options.strongMode = strongMode; 555 options.strongMode = strongMode;
546 context.analysisOptions = options; 556 context.analysisOptions = options;
547 } 557 }
548 } 558 }
549 } 559 }
550 560
551 void _applyLanguageOption( 561 void _applyLanguageOption(
552 AnalysisOptionsImpl options, Object feature, Object value) { 562 AnalysisOptionsImpl options, Object feature, Object value) {
553 bool boolValue = toBool(value); 563 bool boolValue = toBool(value);
554 if (boolValue != null) { 564 if (boolValue != null) {
555 if (feature == AnalyzerOptions.enableAsync) { 565 if (feature == AnalyzerOptions.enableAssertInitializer) {
566 options.enableAssertInitializer = boolValue;
567 } else if (feature == AnalyzerOptions.enableAsync) {
556 options.enableAsync = boolValue; 568 options.enableAsync = boolValue;
557 } 569 } else if (feature == AnalyzerOptions.enableSuperMixins) {
558 if (feature == AnalyzerOptions.enableSuperMixins) {
559 options.enableSuperMixins = boolValue; 570 options.enableSuperMixins = boolValue;
560 } 571 } else if (feature == AnalyzerOptions.enableGenericMethods) {
561 if (feature == AnalyzerOptions.enableGenericMethods) {
562 options.enableGenericMethods = boolValue; 572 options.enableGenericMethods = boolValue;
563 } 573 }
564 } 574 }
565 } 575 }
566 576
567 void _applyLanguageOptions(AnalysisOptionsImpl options, Object configs) { 577 void _applyLanguageOptions(AnalysisOptionsImpl options, Object configs) {
568 if (configs is YamlMap) { 578 if (configs is YamlMap) {
569 configs.nodes.forEach((key, value) { 579 configs.nodes.forEach((key, value) {
570 if (key is YamlScalar && value is YamlScalar) { 580 if (key is YamlScalar && value is YamlScalar) {
571 String feature = key.value?.toString(); 581 String feature = key.value?.toString();
(...skipping 28 matching lines...) Expand all
600 } 610 }
601 }); 611 });
602 } else if (config is Map) { 612 } else if (config is Map) {
603 options.strongMode = true; 613 options.strongMode = true;
604 config.forEach((k, v) => _applyStrongModeOption(options, k, v)); 614 config.forEach((k, v) => _applyStrongModeOption(options, k, v));
605 } else { 615 } else {
606 options.strongMode = config is bool ? config : false; 616 options.strongMode = config is bool ? config : false;
607 } 617 }
608 } 618 }
609 } 619 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698