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

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

Issue 2946313003: Restore partial analysis of analysis options files (Closed)
Patch Set: Created 3 years, 6 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
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 226 }
227 227
228 @override 228 @override
229 TaskDescriptor get descriptor => DESCRIPTOR; 229 TaskDescriptor get descriptor => DESCRIPTOR;
230 230
231 Source get source => target.source; 231 Source get source => target.source;
232 232
233 @override 233 @override
234 void internalPerform() { 234 void internalPerform() {
235 String content = getRequiredInput(CONTENT_INPUT_NAME); 235 String content = getRequiredInput(CONTENT_INPUT_NAME);
236 //
237 // Record outputs.
238 //
239 outputs[ANALYSIS_OPTIONS_ERRORS] =
240 analyzeAnalysisOptions(source, content, context?.sourceFactory);
241 outputs[LINE_INFO] = computeLineInfo(content);
242 }
236 243
244 static List<AnalysisError> analyzeAnalysisOptions(
245 Source source, String content, SourceFactory sourceFactory) {
237 List<AnalysisError> errors = <AnalysisError>[]; 246 List<AnalysisError> errors = <AnalysisError>[];
238 Source initialSource = source; 247 Source initialSource = source;
239 SourceSpan initialIncludeSpan; 248 SourceSpan initialIncludeSpan;
249 AnalysisOptionsProvider optionsProvider =
250 new AnalysisOptionsProvider(sourceFactory);
240 251
241 // Validate the specified options and any included option files 252 // Validate the specified options and any included option files
242 void validate(Source source, Map<String, YamlNode> options) { 253 void validate(Source source, Map<String, YamlNode> options) {
243 List<AnalysisError> validationErrors = 254 List<AnalysisError> validationErrors =
244 new OptionsFileValidator(source).validate(options); 255 new OptionsFileValidator(source).validate(options);
245 if (initialIncludeSpan != null && validationErrors.isNotEmpty) { 256 if (initialIncludeSpan != null && validationErrors.isNotEmpty) {
246 for (AnalysisError error in validationErrors) { 257 for (AnalysisError error in validationErrors) {
247 var args = [ 258 var args = [
248 source.fullName, 259 source.fullName,
249 error.offset.toString(), 260 error.offset.toString(),
(...skipping 11 matching lines...) Expand all
261 errors.addAll(validationErrors); 272 errors.addAll(validationErrors);
262 } 273 }
263 274
264 YamlNode node = options[AnalyzerOptions.include]; 275 YamlNode node = options[AnalyzerOptions.include];
265 if (node == null) { 276 if (node == null) {
266 return; 277 return;
267 } 278 }
268 SourceSpan span = node.span; 279 SourceSpan span = node.span;
269 initialIncludeSpan ??= span; 280 initialIncludeSpan ??= span;
270 String includeUri = span.text; 281 String includeUri = span.text;
271 Source includedSource = 282 Source includedSource = sourceFactory.resolveUri(source, includeUri);
272 context.sourceFactory.resolveUri(source, includeUri);
273 if (!includedSource.exists()) { 283 if (!includedSource.exists()) {
274 errors.add(new AnalysisError( 284 errors.add(new AnalysisError(
275 initialSource, 285 initialSource,
276 initialIncludeSpan.start.column + 1, 286 initialIncludeSpan.start.column + 1,
277 initialIncludeSpan.length, 287 initialIncludeSpan.length,
278 AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND, 288 AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND,
279 [includeUri, source.fullName])); 289 [includeUri, source.fullName]));
280 return; 290 return;
281 } 291 }
282 try { 292 try {
(...skipping 20 matching lines...) Expand all
303 313
304 try { 314 try {
305 Map<String, YamlNode> options = 315 Map<String, YamlNode> options =
306 optionsProvider.getOptionsFromString(content); 316 optionsProvider.getOptionsFromString(content);
307 validate(source, options); 317 validate(source, options);
308 } on OptionsFormatException catch (e) { 318 } on OptionsFormatException catch (e) {
309 SourceSpan span = e.span; 319 SourceSpan span = e.span;
310 errors.add(new AnalysisError(source, span.start.column + 1, span.length, 320 errors.add(new AnalysisError(source, span.start.column + 1, span.length,
311 AnalysisOptionsErrorCode.PARSE_ERROR, [e.message])); 321 AnalysisOptionsErrorCode.PARSE_ERROR, [e.message]));
312 } 322 }
313 323 return errors;
314 //
315 // Record outputs.
316 //
317 outputs[ANALYSIS_OPTIONS_ERRORS] = errors;
318 outputs[LINE_INFO] = computeLineInfo(content);
319 } 324 }
320 325
321 /// Return a map from the names of the inputs of this kind of task to the 326 /// Return a map from the names of the inputs of this kind of task to the
322 /// task input descriptors describing those inputs for a task with the 327 /// task input descriptors describing those inputs for a task with the
323 /// given [target]. 328 /// given [target].
324 static Map<String, TaskInput> buildInputs(AnalysisTarget source) => 329 static Map<String, TaskInput> buildInputs(AnalysisTarget source) =>
325 <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)}; 330 <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)};
326 331
327 /// Compute [LineInfo] for the given [content]. 332 /// Compute [LineInfo] for the given [content].
328 static LineInfo computeLineInfo(String content) { 333 static LineInfo computeLineInfo(String content) {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 591 }
587 }); 592 });
588 } else if (config is Map) { 593 } else if (config is Map) {
589 options.strongMode = true; 594 options.strongMode = true;
590 config.forEach((k, v) => _applyStrongModeOption(options, k, v)); 595 config.forEach((k, v) => _applyStrongModeOption(options, k, v));
591 } else { 596 } else {
592 options.strongMode = config is bool ? config : false; 597 options.strongMode = config is bool ? config : false;
593 } 598 }
594 } 599 }
595 } 600 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698