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

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

Issue 2559523005: Remove the AnalysisOptionsProcessor (Closed)
Patch Set: Created 4 years 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 | « pkg/analyzer/lib/plugin/options.dart ('k') | pkg/analyzer/lib/src/plugin/options_plugin.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';
11 import 'package:analyzer/file_system/file_system.dart'; 11 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/plugin/options.dart';
13 import 'package:analyzer/plugin/resolver_provider.dart'; 12 import 'package:analyzer/plugin/resolver_provider.dart';
14 import 'package:analyzer/source/analysis_options_provider.dart'; 13 import 'package:analyzer/source/analysis_options_provider.dart';
15 import 'package:analyzer/source/package_map_resolver.dart'; 14 import 'package:analyzer/source/package_map_resolver.dart';
16 import 'package:analyzer/src/dart/sdk/sdk.dart'; 15 import 'package:analyzer/src/dart/sdk/sdk.dart';
17 import 'package:analyzer/src/generated/bazel.dart'; 16 import 'package:analyzer/src/generated/bazel.dart';
18 import 'package:analyzer/src/generated/engine.dart'; 17 import 'package:analyzer/src/generated/engine.dart';
19 import 'package:analyzer/src/generated/sdk.dart'; 18 import 'package:analyzer/src/generated/sdk.dart';
20 import 'package:analyzer/src/generated/source.dart'; 19 import 'package:analyzer/src/generated/source.dart';
21 import 'package:analyzer/src/summary/package_bundle_reader.dart'; 20 import 'package:analyzer/src/summary/package_bundle_reader.dart';
22 import 'package:analyzer/src/summary/pub_summary.dart'; 21 import 'package:analyzer/src/summary/pub_summary.dart';
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 94
96 /** 95 /**
97 * Return an analysis context that is configured correctly to analyze code in 96 * Return an analysis context that is configured correctly to analyze code in
98 * the directory with the given [path]. 97 * the directory with the given [path].
99 * 98 *
100 * *Note:* This method is not yet fully implemented and should not be used. 99 * *Note:* This method is not yet fully implemented and should not be used.
101 */ 100 */
102 AnalysisContext buildContext(String path) { 101 AnalysisContext buildContext(String path) {
103 InternalAnalysisContext context = 102 InternalAnalysisContext context =
104 AnalysisEngine.instance.createAnalysisContext(); 103 AnalysisEngine.instance.createAnalysisContext();
105 AnalysisOptions options = getAnalysisOptions(context, path); 104 AnalysisOptions options = getAnalysisOptions(path);
106 context.contentCache = contentCache; 105 context.contentCache = contentCache;
107 context.sourceFactory = createSourceFactory(path, options); 106 context.sourceFactory = createSourceFactory(path, options);
108 context.analysisOptions = options; 107 context.analysisOptions = options;
109 context.name = path; 108 context.name = path;
110 //_processAnalysisOptions(context, optionMap); 109 //_processAnalysisOptions(context, optionMap);
111 declareVariables(context); 110 declareVariables(context);
112 configureSummaries(context); 111 configureSummaries(context);
113 return context; 112 return context;
114 } 113 }
115 114
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 return sdkManager.getSdk(description, () { 317 return sdkManager.getSdk(description, () {
319 FolderBasedDartSdk sdk = new FolderBasedDartSdk(resourceProvider, 318 FolderBasedDartSdk sdk = new FolderBasedDartSdk(resourceProvider,
320 resourceProvider.getFolder(sdkPath), analysisOptions.strongMode); 319 resourceProvider.getFolder(sdkPath), analysisOptions.strongMode);
321 sdk.analysisOptions = analysisOptions; 320 sdk.analysisOptions = analysisOptions;
322 sdk.useSummary = sdkManager.canUseSummaries; 321 sdk.useSummary = sdkManager.canUseSummaries;
323 return sdk; 322 return sdk;
324 }); 323 });
325 } 324 }
326 325
327 /** 326 /**
328 * Return the analysis options that should be used when the given [context] is 327 * Return the analysis options that should be used to analyze code in the
329 * used to analyze code in the directory with the given [path]. 328 * directory with the given [path].
330 */ 329 */
331 AnalysisOptions getAnalysisOptions(AnalysisContext context, String path) { 330 AnalysisOptions getAnalysisOptions(String path) {
332 AnalysisOptionsImpl options = createDefaultOptions(); 331 AnalysisOptionsImpl options = createDefaultOptions();
333 File optionsFile = getOptionsFile(path); 332 File optionsFile = getOptionsFile(path);
334 if (optionsFile != null) { 333 if (optionsFile != null) {
335 List<OptionsProcessor> optionsProcessors =
336 AnalysisEngine.instance.optionsPlugin.optionsProcessors;
337 // TODO(danrubel) restructure so that we don't recalculate the package map 334 // TODO(danrubel) restructure so that we don't recalculate the package map
338 // more than once per path. 335 // more than once per path.
339 Packages packages = createPackageMap(path); 336 Packages packages = createPackageMap(path);
340 Map<String, List<Folder>> packageMap = convertPackagesToMap(packages); 337 Map<String, List<Folder>> packageMap = convertPackagesToMap(packages);
341 List<UriResolver> resolvers = <UriResolver>[ 338 List<UriResolver> resolvers = <UriResolver>[
342 new ResourceUriResolver(resourceProvider), 339 new ResourceUriResolver(resourceProvider),
343 new PackageMapUriResolver(resourceProvider, packageMap), 340 new PackageMapUriResolver(resourceProvider, packageMap),
344 ]; 341 ];
345 SourceFactory sourceFactory = 342 SourceFactory sourceFactory =
346 new SourceFactory(resolvers, packages, resourceProvider); 343 new SourceFactory(resolvers, packages, resourceProvider);
347 try { 344 try {
348 Map<String, YamlNode> optionMap = 345 Map<String, YamlNode> optionMap =
349 new AnalysisOptionsProvider(sourceFactory) 346 new AnalysisOptionsProvider(sourceFactory)
350 .getOptionsFromFile(optionsFile); 347 .getOptionsFromFile(optionsFile);
351 optionsProcessors.forEach(
352 (OptionsProcessor p) => p.optionsProcessed(context, optionMap));
353 applyToAnalysisOptions(options, optionMap); 348 applyToAnalysisOptions(options, optionMap);
354 } on Exception catch (exception) { 349 } catch (_) {
355 optionsProcessors.forEach((OptionsProcessor p) => p.onError(exception)); 350 // Ignore exceptions thrown while trying to load the options file.
356 } 351 }
357 } 352 }
358 return options; 353 return options;
359 } 354 }
360 355
361 /** 356 /**
362 * Return the analysis options file that should be used when analyzing code in 357 * Return the analysis options file that should be used when analyzing code in
363 * the directory with the given [path]. 358 * the directory with the given [path].
364 */ 359 */
365 File getOptionsFile(String path) { 360 File getOptionsFile(String path) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 String _readEmbedderYaml(Folder libDir) { 619 String _readEmbedderYaml(Folder libDir) {
625 File file = libDir.getChild(EMBEDDER_FILE_NAME); 620 File file = libDir.getChild(EMBEDDER_FILE_NAME);
626 try { 621 try {
627 return file.readAsStringSync(); 622 return file.readAsStringSync();
628 } on FileSystemException { 623 } on FileSystemException {
629 // File can't be read. 624 // File can't be read.
630 return null; 625 return null;
631 } 626 }
632 } 627 }
633 } 628 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/plugin/options.dart ('k') | pkg/analyzer/lib/src/plugin/options_plugin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698