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

Side by Side Diff: pkg/analyzer/lib/src/context/builder.dart

Issue 2913493002: Add the analysis options path to the diagnostics page. (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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.context.context_builder; 5 library analyzer.src.context.context_builder;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:core'; 8 import 'dart:core';
9 9
10 import 'package:analyzer/context/context_root.dart'; 10 import 'package:analyzer/context/context_root.dart';
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // TODO(danrubel) restructure so that we don't create a workspace 400 // TODO(danrubel) restructure so that we don't create a workspace
401 // both here and in createSourceFactory 401 // both here and in createSourceFactory
402 Workspace workspace = createWorkspace(path); 402 Workspace workspace = createWorkspace(path);
403 SourceFactory sourceFactory = workspace.createSourceFactory(null); 403 SourceFactory sourceFactory = workspace.createSourceFactory(null);
404 AnalysisOptionsProvider optionsProvider = 404 AnalysisOptionsProvider optionsProvider =
405 new AnalysisOptionsProvider(sourceFactory); 405 new AnalysisOptionsProvider(sourceFactory);
406 406
407 AnalysisOptionsImpl options = createDefaultOptions(); 407 AnalysisOptionsImpl options = createDefaultOptions();
408 File optionsFile = getOptionsFile(path); 408 File optionsFile = getOptionsFile(path);
409 Map<String, YamlNode> optionMap; 409 Map<String, YamlNode> optionMap;
410 String optionsFilePath;
410 411
411 if (optionsFile != null) { 412 if (optionsFile != null) {
412 try { 413 try {
413 optionMap = optionsProvider.getOptionsFromFile(optionsFile); 414 optionMap = optionsProvider.getOptionsFromFile(optionsFile);
415 optionsFilePath = optionsFile.path;
414 verbose('Loaded analysis options from ${optionsFile.path}'); 416 verbose('Loaded analysis options from ${optionsFile.path}');
415 } catch (e) { 417 } catch (e) {
416 // Ignore exceptions thrown while trying to load the options file. 418 // Ignore exceptions thrown while trying to load the options file.
417 verbose('Exception: $e\n when loading ${optionsFile.path}'); 419 verbose('Exception: $e\n when loading ${optionsFile.path}');
418 } 420 }
419 } else { 421 } else {
420 // Search for the default analysis options 422 // Search for the default analysis options
421 // unless explicitly directed not to do so. 423 // unless explicitly directed not to do so.
422 Source source; 424 Source source;
423 if (builderOptions.packageDefaultAnalysisOptions) { 425 if (builderOptions.packageDefaultAnalysisOptions) {
424 // TODO(danrubel) determine if bazel or gn project depends upon flutter 426 // TODO(danrubel) determine if bazel or gn project depends upon flutter
425 if (workspace.hasFlutterDependency) { 427 if (workspace.hasFlutterDependency) {
426 source = sourceFactory.forUri(flutterAnalysisOptionsPath); 428 source = sourceFactory.forUri(flutterAnalysisOptionsPath);
427 } 429 }
428 if (source == null || !source.exists()) { 430 if (source == null || !source.exists()) {
429 source = sourceFactory.forUri(bazelAnalysisOptionsPath); 431 source = sourceFactory.forUri(bazelAnalysisOptionsPath);
430 } 432 }
431 if (source != null && source.exists()) { 433 if (source != null && source.exists()) {
432 try { 434 try {
433 optionMap = optionsProvider.getOptionsFromSource(source); 435 optionMap = optionsProvider.getOptionsFromSource(source);
436 optionsFilePath = source.fullName;
434 verbose('Loaded analysis options from ${source.fullName}'); 437 verbose('Loaded analysis options from ${source.fullName}');
435 } catch (e) { 438 } catch (e) {
436 // Ignore exceptions thrown while trying to load the options file. 439 // Ignore exceptions thrown while trying to load the options file.
437 verbose('Exception: $e\n when loading ${source.fullName}'); 440 verbose('Exception: $e\n when loading ${source.fullName}');
438 } 441 }
439 } 442 }
440 } 443 }
441 } 444 }
442 445
443 if (optionMap != null) { 446 if (optionMap != null) {
444 applyToAnalysisOptions(options, optionMap); 447 applyToAnalysisOptions(options, optionMap);
448 options.optionsFilePath = optionsFilePath;
445 if (builderOptions.argResults != null) { 449 if (builderOptions.argResults != null) {
446 applyAnalysisOptionFlags(options, builderOptions.argResults, 450 applyAnalysisOptionFlags(options, builderOptions.argResults,
447 verbosePrint: verbosePrint); 451 verbosePrint: verbosePrint);
448 // If lints turned on but none specified, then enable default lints 452 // If lints turned on but none specified, then enable default lints
449 if (options.lint && options.lintRules.isEmpty) { 453 if (options.lint && options.lintRules.isEmpty) {
450 options.lintRules = Registry.ruleRegistry.defaultRules; 454 options.lintRules = Registry.ruleRegistry.defaultRules;
451 verbose('Using default lint rules'); 455 verbose('Using default lint rules');
452 } 456 }
453 } 457 }
454 } else { 458 } else {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 throw new ArgumentError('not absolute: $path'); 822 throw new ArgumentError('not absolute: $path');
819 } 823 }
820 path = context.normalize(path); 824 path = context.normalize(path);
821 Resource resource = provider.getResource(path); 825 Resource resource = provider.getResource(path);
822 if (resource is File) { 826 if (resource is File) {
823 path = resource.parent.path; 827 path = resource.parent.path;
824 } 828 }
825 return new _BasicWorkspace._(provider, path, builder); 829 return new _BasicWorkspace._(provider, path, builder);
826 } 830 }
827 } 831 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698