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 test.context.directory.manager; | 5 library test.context.directory.manager; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analysis_server/src/context_manager.dart'; | 9 import 'package:analysis_server/src/context_manager.dart'; |
10 import 'package:analysis_server/src/utilities/null_string_sink.dart'; | 10 import 'package:analysis_server/src/utilities/null_string_sink.dart'; |
| 11 import 'package:analyzer/context/context_root.dart'; |
11 import 'package:analyzer/error/error.dart'; | 12 import 'package:analyzer/error/error.dart'; |
12 import 'package:analyzer/file_system/file_system.dart'; | 13 import 'package:analyzer/file_system/file_system.dart'; |
13 import 'package:analyzer/file_system/memory_file_system.dart'; | 14 import 'package:analyzer/file_system/memory_file_system.dart'; |
14 import 'package:analyzer/instrumentation/instrumentation.dart'; | 15 import 'package:analyzer/instrumentation/instrumentation.dart'; |
15 import 'package:analyzer/source/error_processor.dart'; | 16 import 'package:analyzer/source/error_processor.dart'; |
16 import 'package:analyzer/src/context/builder.dart'; | 17 import 'package:analyzer/src/context/builder.dart'; |
17 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | 18 import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
18 import 'package:analyzer/src/dart/analysis/driver.dart'; | 19 import 'package:analyzer/src/dart/analysis/driver.dart'; |
19 import 'package:analyzer/src/dart/analysis/file_state.dart'; | 20 import 'package:analyzer/src/dart/analysis/file_state.dart'; |
20 import 'package:analyzer/src/error/codes.dart'; | 21 import 'package:analyzer/src/error/codes.dart'; |
(...skipping 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2699 } | 2700 } |
2700 | 2701 |
2701 /** | 2702 /** |
2702 * Return the current source factory. | 2703 * Return the current source factory. |
2703 */ | 2704 */ |
2704 SourceFactory get sourceFactory => currentDriver == null | 2705 SourceFactory get sourceFactory => currentDriver == null |
2705 ? currentContext.sourceFactory | 2706 ? currentContext.sourceFactory |
2706 : currentDriver.sourceFactory; | 2707 : currentDriver.sourceFactory; |
2707 | 2708 |
2708 @override | 2709 @override |
2709 AnalysisDriver addAnalysisDriver(Folder folder, AnalysisOptions options) { | 2710 AnalysisDriver addAnalysisDriver( |
| 2711 Folder folder, ContextRoot contextRoot, AnalysisOptions options) { |
2710 String path = folder.path; | 2712 String path = folder.path; |
2711 expect(currentContextRoots, isNot(contains(path))); | 2713 expect(currentContextRoots, isNot(contains(path))); |
| 2714 expect(contextRoot, isNotNull); |
| 2715 expect(contextRoot.root, path); |
2712 currentContextTimestamps[path] = now; | 2716 currentContextTimestamps[path] = now; |
2713 | 2717 |
2714 ContextBuilder builder = | 2718 ContextBuilder builder = |
2715 createContextBuilder(folder, options, useSummaries: true); | 2719 createContextBuilder(folder, options, useSummaries: true); |
2716 AnalysisContext context = builder.buildContext(folder.path); | 2720 AnalysisContext context = builder.buildContext(folder.path); |
2717 SourceFactory sourceFactory = context.sourceFactory; | 2721 SourceFactory sourceFactory = context.sourceFactory; |
2718 AnalysisOptions analysisOptions = context.analysisOptions; | 2722 AnalysisOptions analysisOptions = context.analysisOptions; |
2719 context.dispose(); | 2723 context.dispose(); |
2720 | 2724 |
2721 currentDriver = new AnalysisDriver( | 2725 currentDriver = new AnalysisDriver( |
2722 scheduler, | 2726 scheduler, |
2723 logger, | 2727 logger, |
2724 resourceProvider, | 2728 resourceProvider, |
2725 new MemoryByteStore(), | 2729 new MemoryByteStore(), |
2726 new FileContentOverlay(), | 2730 new FileContentOverlay(), |
2727 path, | 2731 contextRoot, |
2728 sourceFactory, | 2732 sourceFactory, |
2729 analysisOptions); | 2733 analysisOptions); |
2730 driverMap[path] = currentDriver; | 2734 driverMap[path] = currentDriver; |
2731 currentDriver.exceptions.listen((ExceptionResult result) { | 2735 currentDriver.exceptions.listen((ExceptionResult result) { |
2732 AnalysisEngine.instance.logger | 2736 AnalysisEngine.instance.logger |
2733 .logError('Analysis failed: ${result.path}', result.exception); | 2737 .logError('Analysis failed: ${result.path}', result.exception); |
2734 }); | 2738 }); |
2735 return currentDriver; | 2739 return currentDriver; |
2736 } | 2740 } |
2737 | 2741 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2896 class TestUriResolver extends UriResolver { | 2900 class TestUriResolver extends UriResolver { |
2897 Map<Uri, Source> uriMap; | 2901 Map<Uri, Source> uriMap; |
2898 | 2902 |
2899 TestUriResolver(this.uriMap); | 2903 TestUriResolver(this.uriMap); |
2900 | 2904 |
2901 @override | 2905 @override |
2902 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 2906 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
2903 return uriMap[uri]; | 2907 return uriMap[uri]; |
2904 } | 2908 } |
2905 } | 2909 } |
OLD | NEW |