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

Unified Diff: pkg/analysis_server/lib/src/context_manager.dart

Issue 1923973004: Pubspec-specified analysis configuration (#26359). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: typeo Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/context_manager_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/context_manager.dart
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index a87fdc546126042aa999be776648881e43167456..9b68388aacdf2815bbcb8a512f1c8bc07fb83163 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -16,6 +16,7 @@ import 'package:analyzer/plugin/embedded_resolver_provider.dart';
import 'package:analyzer/plugin/options.dart';
import 'package:analyzer/plugin/resolver_provider.dart';
import 'package:analyzer/source/analysis_options_provider.dart';
+import 'package:analyzer/source/config.dart';
import 'package:analyzer/source/embedder.dart';
import 'package:analyzer/source/package_map_provider.dart';
import 'package:analyzer/source/package_map_resolver.dart';
@@ -597,7 +598,7 @@ class ContextManagerImpl implements ContextManager {
}
} else {
// Check for embedded options.
- YamlMap embeddedOptions = _getEmbeddedOptions(info.context);
+ Map embeddedOptions = _getEmbeddedOptions(info.context);
if (embeddedOptions != null) {
options = _toStringMap(new Merger().merge(embeddedOptions, options));
}
@@ -1072,6 +1073,27 @@ class ContextManagerImpl implements ContextManager {
folderMap[folder] = info.context;
info.context.name = folder.path;
+ // Look for pubspec-specified analysis configuration.
+ File pubspec;
+ if (packagespecFile?.exists == true) {
+ if (packagespecFile.shortName == PUBSPEC_NAME) {
+ pubspec = packagespecFile;
+ }
+ }
+ if (pubspec == null) {
+ Resource child = folder.getChild(PUBSPEC_NAME);
+ if (child.exists && child is File) {
+ pubspec = child;
+ }
+ }
+ if (pubspec != null) {
+ File pubSource = resourceProvider.getFile(pubspec.path);
+ setConfiguration(
+ info.context,
+ new AnalysisConfiguration.fromPubspec(
+ pubSource, resourceProvider, disposition.packages));
+ }
+
processOptionsForContext(info, optionMap);
return info;
@@ -1235,18 +1257,39 @@ class ContextManagerImpl implements ContextManager {
return packageSpec;
}
- /// Get analysis options associated with an `_embedder.yaml`. If there is
- /// more than one `_embedder.yaml` associated with the given context, `null`
- /// is returned.
- YamlMap _getEmbeddedOptions(AnalysisContext context) {
- if (context is InternalAnalysisContext) {
- EmbedderYamlLocator locator = context.embedderYamlLocator;
- Iterable<YamlMap> maps = locator.embedderYamls.values;
- if (maps.length == 1) {
- return maps.first;
+ /// Get analysis options inherited from an `_embedder.yaml` (deprecated)
+ /// and/or a package specified configuration. If more than one
+ /// `_embedder.yaml` is associated with the given context, the embedder is
+ /// skipped.
+ ///
+ /// Returns null if there are no embedded/configured options.
+ Map _getEmbeddedOptions(AnalysisContext context) {
+ if (context is! InternalAnalysisContext) {
Brian Wilkerson 2016/04/28 18:05:59 While I appreciate the fact that this style remove
pquitslund 2016/04/28 18:13:42 Done.
+ return null;
+ }
+
+ InternalAnalysisContext internalContext = context;
+
+ Map embeddedOptions;
+ EmbedderYamlLocator locator = internalContext.embedderYamlLocator;
+ Iterable<YamlMap> maps = locator.embedderYamls.values;
+ if (maps.length == 1) {
+ embeddedOptions = maps.first;
+ }
+
+ AnalysisConfiguration configuration = getConfiguration(context);
+ if (configuration != null) {
+ Map configMap = configuration.options;
+ if (configMap != null) {
+ if (embeddedOptions != null) {
+ embeddedOptions = new Merger().merge(embeddedOptions, configMap);
+ } else {
+ embeddedOptions = configMap;
+ }
}
}
- return null;
+
+ return embeddedOptions;
}
/**
« no previous file with comments | « no previous file | pkg/analysis_server/test/context_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698