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

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

Issue 2666693002: detect flutter and use default analysis options for flutter (Closed)
Patch Set: Created 3 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 | « no previous file | pkg/analyzer/lib/src/generated/workspace.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) 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/declared_variables.dart'; 10 import 'package:analyzer/context/declared_variables.dart';
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 Map<String, YamlNode> optionMap; 396 Map<String, YamlNode> optionMap;
397 397
398 if (optionsFile != null) { 398 if (optionsFile != null) {
399 try { 399 try {
400 optionMap = optionsProvider.getOptionsFromFile(optionsFile); 400 optionMap = optionsProvider.getOptionsFromFile(optionsFile);
401 } catch (_) { 401 } catch (_) {
402 // Ignore exceptions thrown while trying to load the options file. 402 // Ignore exceptions thrown while trying to load the options file.
403 } 403 }
404 } else { 404 } else {
405 // Search for the default analysis options 405 // Search for the default analysis options
406 // TODO(danrubel) check for flutter and use default flutter options 406 Source source;
407 Source source = 407 // TODO(danrubel) determine if bazel or gn project depends upon flutter
408 sourceFactory.forUri('package:dart.analysis_options/default.yaml'); 408 if (workspace.hasFlutterDependency) {
409 source =
410 sourceFactory.forUri('package:flutter/analysis_options_user.yaml');
411 }
412 if (source == null || !source.exists()) {
413 source =
414 sourceFactory.forUri('package:dart.analysis_options/default.yaml');
415 }
409 if (source.exists()) { 416 if (source.exists()) {
410 try { 417 try {
411 optionMap = optionsProvider.getOptionsFromSource(source); 418 optionMap = optionsProvider.getOptionsFromSource(source);
412 } catch (_) { 419 } catch (_) {
413 // Ignore exceptions thrown while trying to load the options file. 420 // Ignore exceptions thrown while trying to load the options file.
414 } 421 }
415 } 422 }
416 } 423 }
417 424
418 if (optionMap != null) { 425 if (optionMap != null) {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 Packages _packages; 734 Packages _packages;
728 735
729 _BasicWorkspace._(this.provider, this.root, this._builder); 736 _BasicWorkspace._(this.provider, this.root, this._builder);
730 737
731 @override 738 @override
732 Map<String, List<Folder>> get packageMap { 739 Map<String, List<Folder>> get packageMap {
733 _packageMap ??= _builder.convertPackagesToMap(packages); 740 _packageMap ??= _builder.convertPackagesToMap(packages);
734 return _packageMap; 741 return _packageMap;
735 } 742 }
736 743
744 @override
745 // Alternately, we could check the pubspec for "sdk: flutter"
Brian Wilkerson 2017/01/30 20:40:47 Personally, I think checking the package map is be
danrubel 2017/01/30 20:47:11 Agreed.
746 bool get hasFlutterDependency => packageMap.containsKey('flutter');
747
737 Packages get packages { 748 Packages get packages {
738 _packages ??= _builder.createPackageMap(root); 749 _packages ??= _builder.createPackageMap(root);
739 return _packages; 750 return _packages;
740 } 751 }
741 752
742 @override 753 @override
743 UriResolver get packageUriResolver => 754 UriResolver get packageUriResolver =>
744 new PackageMapUriResolver(provider, packageMap); 755 new PackageMapUriResolver(provider, packageMap);
745 756
746 @override 757 @override
747 SourceFactory createSourceFactory(DartSdk sdk) { 758 SourceFactory createSourceFactory(DartSdk sdk) {
748 List<UriResolver> resolvers = <UriResolver>[]; 759 List<UriResolver> resolvers = <UriResolver>[];
749 if (sdk != null) { 760 if (sdk != null) {
750 resolvers.add(new DartUriResolver(sdk)); 761 resolvers.add(new DartUriResolver(sdk));
751 } 762 }
752 resolvers.add(packageUriResolver); 763 resolvers.add(packageUriResolver);
753 resolvers.add(new ResourceUriResolver(provider)); 764 resolvers.add(new ResourceUriResolver(provider));
754 return new SourceFactory(resolvers, packages, provider); 765 return new SourceFactory(resolvers, packages, provider);
755 } 766 }
756 767
757 /** 768 /**
758 * Find the basic workspace that contains the given [path]. 769 * Find the basic workspace that contains the given [path].
759 */ 770 */
760 static _BasicWorkspace find( 771 static _BasicWorkspace find(
761 ResourceProvider resourceProvider, String path, ContextBuilder builder) { 772 ResourceProvider resourceProvider, String path, ContextBuilder builder) {
762 return new _BasicWorkspace._(resourceProvider, path, builder); 773 return new _BasicWorkspace._(resourceProvider, path, builder);
763 } 774 }
764 } 775 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/workspace.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698