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

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

Issue 2947743002: Add support to pass the location of the analysis options file to plugins (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/plugin/plugin_manager.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 2f115f671677a67e3585cfa789dea89e79d93357..d7a903ad387ebc3c20fdd4e92a2bff8346d3df3b 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -750,30 +750,6 @@ class ContextManagerImpl implements ContextManager {
}
}
- /**
- * Return the options from the analysis options file in the given [folder]
- * if exists, or in one of the parent folders, or `null` if no analysis
- * options file is found or if the contents of the file are not valid YAML.
- */
- Map<String, Object> readOptions(Folder folder, Packages packages) {
- try {
- Map<String, List<Folder>> packageMap =
- new ContextBuilder(resourceProvider, null, null)
- .convertPackagesToMap(packages);
- List<UriResolver> resolvers = <UriResolver>[
- new ResourceUriResolver(resourceProvider),
- new PackageMapUriResolver(resourceProvider, packageMap),
- ];
- SourceFactory sourceFactory =
- new SourceFactory(resolvers, packages, resourceProvider);
- return new AnalysisOptionsProvider(sourceFactory)
- .getOptions(folder, crawlUp: true);
- } catch (_) {
- // Parse errors are reported by GenerateOptionsErrorsTask.
- }
- return null;
- }
-
@override
void refresh(List<Resource> roots) {
// Destroy old contexts
@@ -1119,6 +1095,23 @@ class ContextManagerImpl implements ContextManager {
}
/**
+ * Create an object that can be used to find and read the analysis options
+ * file for code being analyzed using the given [packages].
+ */
+ AnalysisOptionsProvider _createAnalysisOptionsProvider(Packages packages) {
+ Map<String, List<Folder>> packageMap =
+ new ContextBuilder(resourceProvider, null, null)
+ .convertPackagesToMap(packages);
+ List<UriResolver> resolvers = <UriResolver>[
+ new ResourceUriResolver(resourceProvider),
+ new PackageMapUriResolver(resourceProvider, packageMap),
+ ];
+ SourceFactory sourceFactory =
+ new SourceFactory(resolvers, packages, resourceProvider);
+ return new AnalysisOptionsProvider(sourceFactory);
+ }
+
+ /**
* Create a new empty context associated with [folder], having parent
* [parent] and using [packagesFile] to resolve package URI's.
*/
@@ -1130,8 +1123,18 @@ class ContextManagerImpl implements ContextManager {
ContextInfo info = new ContextInfo(this, parent, folder, packagesFile,
normalizedPackageRoots[folder.path], disposition);
- Map<String, Object> optionMap =
- readOptions(info.folder, disposition.packages);
+ File optionsFile = null;
+ Map<String, Object> optionMap = null;
+ try {
+ AnalysisOptionsProvider provider =
+ _createAnalysisOptionsProvider(disposition.packages);
+ optionsFile = provider.getOptionsFile(info.folder, crawlUp: true);
+ if (optionsFile != null) {
+ optionMap = provider.getOptionsFromFile(optionsFile);
+ }
+ } catch (_) {
+ // Parse errors are reported elsewhere.
+ }
AnalysisOptions options =
new AnalysisOptionsImpl.from(defaultContextOptions);
applyToAnalysisOptions(options, optionMap);
@@ -1143,8 +1146,13 @@ class ContextManagerImpl implements ContextManager {
pathContext.isWithin(includedPath, excludedPath))
.toList();
processOptionsForDriver(info, options, optionMap);
- info.analysisDriver = callbacks.addAnalysisDriver(
- folder, new ContextRoot(folder.path, containedExcludedPaths), options);
+ ContextRoot contextRoot =
+ new ContextRoot(folder.path, containedExcludedPaths);
+ if (optionsFile != null) {
+ contextRoot.optionsFilePath = optionsFile.path;
+ }
+ info.analysisDriver =
+ callbacks.addAnalysisDriver(folder, contextRoot, options);
return info;
}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/plugin/plugin_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698