OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 context.directory.manager; | 5 library context.directory.manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:core' hide Resource; | 10 import 'dart:core' hide Resource; |
11 | 11 |
12 import 'package:analysis_server/src/analysis_server.dart'; | 12 import 'package:analysis_server/src/analysis_server.dart'; |
13 import 'package:analysis_server/src/server_options.dart'; | 13 import 'package:analysis_server/src/server_options.dart'; |
14 import 'package:analysis_server/uri/resolver_provider.dart'; | 14 import 'package:analysis_server/uri/resolver_provider.dart'; |
15 import 'package:analyzer/file_system/file_system.dart'; | 15 import 'package:analyzer/file_system/file_system.dart'; |
16 import 'package:analyzer/instrumentation/instrumentation.dart'; | 16 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 17 import 'package:analyzer/plugin/options.dart'; |
17 import 'package:analyzer/source/analysis_options_provider.dart'; | 18 import 'package:analyzer/source/analysis_options_provider.dart'; |
18 import 'package:analyzer/source/package_map_provider.dart'; | 19 import 'package:analyzer/source/package_map_provider.dart'; |
19 import 'package:analyzer/source/package_map_resolver.dart'; | 20 import 'package:analyzer/source/package_map_resolver.dart'; |
20 import 'package:analyzer/source/path_filter.dart'; | 21 import 'package:analyzer/source/path_filter.dart'; |
21 import 'package:analyzer/source/pub_package_map_provider.dart'; | 22 import 'package:analyzer/source/pub_package_map_provider.dart'; |
22 import 'package:analyzer/source/sdk_ext.dart'; | 23 import 'package:analyzer/source/sdk_ext.dart'; |
23 import 'package:analyzer/src/generated/engine.dart'; | 24 import 'package:analyzer/src/generated/engine.dart'; |
24 import 'package:analyzer/src/generated/java_io.dart'; | 25 import 'package:analyzer/src/generated/java_io.dart'; |
25 import 'package:analyzer/src/generated/source.dart'; | 26 import 'package:analyzer/src/generated/source.dart'; |
26 import 'package:analyzer/src/generated/source_io.dart'; | 27 import 'package:analyzer/src/generated/source_io.dart'; |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 460 } |
460 // no | 461 // no |
461 return false; | 462 return false; |
462 } | 463 } |
463 | 464 |
464 /** | 465 /** |
465 * Process [options] for the context having info [info]. | 466 * Process [options] for the context having info [info]. |
466 */ | 467 */ |
467 void processOptionsForContext( | 468 void processOptionsForContext( |
468 ContextInfo info, Map<String, YamlNode> options) { | 469 ContextInfo info, Map<String, YamlNode> options) { |
| 470 //TODO(pquitslund): push handling into an options processor plugin contribut
ed to engine. |
| 471 //AnalysisEngine.instance.optionsPlugin.optionsProcessors |
| 472 // .forEach((OptionsProcessor p) => p.optionsProcessed(options)); |
| 473 if (options == null) { |
| 474 return; |
| 475 } |
469 YamlMap analyzer = options['analyzer']; | 476 YamlMap analyzer = options['analyzer']; |
470 if (analyzer == null) { | 477 if (analyzer == null) { |
471 // No options for analyzer. | 478 // No options for analyzer. |
472 return; | 479 return; |
473 } | 480 } |
474 | 481 |
475 // Set ignore patterns. | 482 // Set ignore patterns. |
476 YamlList exclude = analyzer['exclude']; | 483 YamlList exclude = analyzer['exclude']; |
477 if (exclude != null) { | 484 if (exclude != null) { |
478 setIgnorePatternsForContext(info, exclude); | 485 setIgnorePatternsForContext(info, exclude); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 } | 808 } |
802 | 809 |
803 /** | 810 /** |
804 * Create a new empty context associated with [folder], having parent | 811 * Create a new empty context associated with [folder], having parent |
805 * [parent] and using [packagespecFile] to resolve package URI's. | 812 * [parent] and using [packagespecFile] to resolve package URI's. |
806 */ | 813 */ |
807 ContextInfo _createContext( | 814 ContextInfo _createContext( |
808 ContextInfo parent, Folder folder, File packagespecFile) { | 815 ContextInfo parent, Folder folder, File packagespecFile) { |
809 ContextInfo info = new ContextInfo(this, parent, folder, packagespecFile, | 816 ContextInfo info = new ContextInfo(this, parent, folder, packagespecFile, |
810 normalizedPackageRoots[folder.path]); | 817 normalizedPackageRoots[folder.path]); |
811 Map<String, YamlNode> options = analysisOptionsProvider.getOptions(folder); | 818 |
812 processOptionsForContext(info, options); | 819 try { |
| 820 Map<String, YamlNode> options = |
| 821 analysisOptionsProvider.getOptions(folder); |
| 822 processOptionsForContext(info, options); |
| 823 } on Exception catch (e) { |
| 824 // TODO(pquitslund): contribute plugin that sends error notification on op
tions file. |
| 825 // Related test: context_manager_test.test_analysis_options_parse_failure(
) |
| 826 // AnalysisEngine.instance.optionsPlugin.optionsProcessors |
| 827 // .forEach((OptionsProcessor p) => p.onError(e)); |
| 828 } |
| 829 |
813 FolderDisposition disposition; | 830 FolderDisposition disposition; |
814 List<String> dependencies = <String>[]; | 831 List<String> dependencies = <String>[]; |
815 | 832 |
816 // Next resort to a package uri resolver. | 833 // Next resort to a package uri resolver. |
817 if (disposition == null) { | 834 if (disposition == null) { |
818 disposition = | 835 disposition = |
819 _computeFolderDisposition(folder, dependencies.add, packagespecFile); | 836 _computeFolderDisposition(folder, dependencies.add, packagespecFile); |
820 } | 837 } |
821 | 838 |
822 info.setDependencies(dependencies); | 839 info.setDependencies(dependencies); |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 var path = resourceProvider.pathContext.fromUri(uri); | 1404 var path = resourceProvider.pathContext.fromUri(uri); |
1388 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; | 1405 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; |
1389 } | 1406 } |
1390 }); | 1407 }); |
1391 return <UriResolver>[new SdkExtUriResolver(packageMap)]; | 1408 return <UriResolver>[new SdkExtUriResolver(packageMap)]; |
1392 } else { | 1409 } else { |
1393 return const <UriResolver>[]; | 1410 return const <UriResolver>[]; |
1394 } | 1411 } |
1395 } | 1412 } |
1396 } | 1413 } |
OLD | NEW |