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

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

Issue 1645643002: Replace isAppropriateFor with suitabilityFor and start using it (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/model.dart ('k') | pkg/analyzer/lib/src/task/yaml.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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 /// A task that generates errors for an `.analysis_options` file. 195 /// A task that generates errors for an `.analysis_options` file.
196 class GenerateOptionsErrorsTask extends SourceBasedAnalysisTask { 196 class GenerateOptionsErrorsTask extends SourceBasedAnalysisTask {
197 /// The name of the input whose value is the content of the file. 197 /// The name of the input whose value is the content of the file.
198 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; 198 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME';
199 199
200 /// The task descriptor describing this kind of task. 200 /// The task descriptor describing this kind of task.
201 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 201 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
202 'GenerateOptionsErrorsTask', 202 'GenerateOptionsErrorsTask',
203 createTask, 203 createTask,
204 buildInputs, 204 buildInputs,
205 <ResultDescriptor>[ANALYSIS_OPTIONS_ERRORS, LINE_INFO]); 205 <ResultDescriptor>[ANALYSIS_OPTIONS_ERRORS, LINE_INFO],
206 suitabilityFor: suitabilityFor);
206 207
207 final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider(); 208 final AnalysisOptionsProvider optionsProvider = new AnalysisOptionsProvider();
208 209
209 GenerateOptionsErrorsTask(AnalysisContext context, AnalysisTarget target) 210 GenerateOptionsErrorsTask(AnalysisContext context, AnalysisTarget target)
210 : super(context, target); 211 : super(context, target);
211 212
212 @override 213 @override
213 TaskDescriptor get descriptor => DESCRIPTOR; 214 TaskDescriptor get descriptor => DESCRIPTOR;
214 215
215 Source get source => target.source; 216 Source get source => target.source;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 /// Compute [LineInfo] for the given [content]. 251 /// Compute [LineInfo] for the given [content].
251 static LineInfo computeLineInfo(String content) { 252 static LineInfo computeLineInfo(String content) {
252 List<int> lineStarts = StringUtilities.computeLineStarts(content); 253 List<int> lineStarts = StringUtilities.computeLineStarts(content);
253 return new LineInfo(lineStarts); 254 return new LineInfo(lineStarts);
254 } 255 }
255 256
256 /// Create a task based on the given [target] in the given [context]. 257 /// Create a task based on the given [target] in the given [context].
257 static GenerateOptionsErrorsTask createTask( 258 static GenerateOptionsErrorsTask createTask(
258 AnalysisContext context, AnalysisTarget target) => 259 AnalysisContext context, AnalysisTarget target) =>
259 new GenerateOptionsErrorsTask(context, target); 260 new GenerateOptionsErrorsTask(context, target);
261
262 /**
263 * Return an indication of how suitable this task is for the given [target].
264 */
265 static TaskSuitability suitabilityFor(AnalysisTarget target) {
266 if (target is Source &&
267 target.shortName == AnalysisEngine.ANALYSIS_OPTIONS_FILE) {
268 return TaskSuitability.HIGHEST;
269 }
270 return TaskSuitability.NONE;
271 }
260 } 272 }
261 273
262 /// Validates `analyzer` language configuration options. 274 /// Validates `analyzer` language configuration options.
263 class LanguageOptionValidator extends OptionsValidator { 275 class LanguageOptionValidator extends OptionsValidator {
264 ErrorBuilder builder = new ErrorBuilder(AnalyzerOptions.languageOptions); 276 ErrorBuilder builder = new ErrorBuilder(AnalyzerOptions.languageOptions);
265 ErrorBuilder trueOrFalseBuilder = new TrueOrFalseValueErrorBuilder(); 277 ErrorBuilder trueOrFalseBuilder = new TrueOrFalseValueErrorBuilder();
266 278
267 @override 279 @override
268 void validate(ErrorReporter reporter, Map<String, YamlNode> options) { 280 void validate(ErrorReporter reporter, Map<String, YamlNode> options) {
269 var analyzer = options[AnalyzerOptions.analyzer]; 281 var analyzer = options[AnalyzerOptions.analyzer];
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 void setStrongMode(AnalysisContext context, Object strongMode) { 487 void setStrongMode(AnalysisContext context, Object strongMode) {
476 bool strong = strongMode is bool ? strongMode : false; 488 bool strong = strongMode is bool ? strongMode : false;
477 if (context.analysisOptions.strongMode != strong) { 489 if (context.analysisOptions.strongMode != strong) {
478 AnalysisOptionsImpl options = 490 AnalysisOptionsImpl options =
479 new AnalysisOptionsImpl.from(context.analysisOptions); 491 new AnalysisOptionsImpl.from(context.analysisOptions);
480 options.strongMode = strong; 492 options.strongMode = strong;
481 context.analysisOptions = options; 493 context.analysisOptions = options;
482 } 494 }
483 } 495 }
484 } 496 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/model.dart ('k') | pkg/analyzer/lib/src/task/yaml.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698