| 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:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 2630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2641 | 2641 |
| 2642 @override | 2642 @override |
| 2643 AnalysisContext addContext( | 2643 AnalysisContext addContext( |
| 2644 Folder folder, AnalysisOptions options, FolderDisposition disposition) { | 2644 Folder folder, AnalysisOptions options, FolderDisposition disposition) { |
| 2645 String path = folder.path; | 2645 String path = folder.path; |
| 2646 expect(currentContextPaths, isNot(contains(path))); | 2646 expect(currentContextPaths, isNot(contains(path))); |
| 2647 currentContextTimestamps[path] = now; | 2647 currentContextTimestamps[path] = now; |
| 2648 currentContextFilePaths[path] = <String, int>{}; | 2648 currentContextFilePaths[path] = <String, int>{}; |
| 2649 currentContextSources[path] = new HashSet<Source>(); | 2649 currentContextSources[path] = new HashSet<Source>(); |
| 2650 currentContext = AnalysisEngine.instance.createAnalysisContext(); | 2650 currentContext = AnalysisEngine.instance.createAnalysisContext(); |
| 2651 _locateEmbedderYamls(currentContext, disposition); | |
| 2652 List<UriResolver> resolvers = []; | 2651 List<UriResolver> resolvers = []; |
| 2653 if (currentContext is InternalAnalysisContext) { | 2652 if (currentContext is InternalAnalysisContext) { |
| 2654 EmbedderYamlLocator embedderYamlLocator = | 2653 EmbedderYamlLocator embedderYamlLocator = |
| 2655 (currentContext as InternalAnalysisContext).embedderYamlLocator; | 2654 disposition.getEmbedderLocator(resourceProvider); |
| 2656 EmbedderSdk sdk = new EmbedderSdk(embedderYamlLocator.embedderYamls); | 2655 EmbedderSdk sdk = new EmbedderSdk(embedderYamlLocator.embedderYamls); |
| 2657 if (sdk.libraryMap.size() > 0) { | 2656 if (sdk.libraryMap.size() > 0) { |
| 2658 // We have some embedder dart: uri mappings, add the resolver | 2657 // We have some embedder dart: uri mappings, add the resolver |
| 2659 // to the list. | 2658 // to the list. |
| 2660 resolvers.add(new DartUriResolver(sdk)); | 2659 resolvers.add(new DartUriResolver(sdk)); |
| 2661 } | 2660 } |
| 2662 } | 2661 } |
| 2663 resolvers.addAll(disposition.createPackageUriResolvers(resourceProvider)); | 2662 resolvers.addAll(disposition.createPackageUriResolvers(resourceProvider)); |
| 2664 resolvers.add(new ResourceUriResolver(PhysicalResourceProvider.INSTANCE)); | 2663 resolvers.add(new ResourceUriResolver(PhysicalResourceProvider.INSTANCE)); |
| 2665 currentContext.analysisOptions = options; | 2664 currentContext.analysisOptions = options; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2727 currentContextTimestamps.remove(path); | 2726 currentContextTimestamps.remove(path); |
| 2728 currentContextFilePaths.remove(path); | 2727 currentContextFilePaths.remove(path); |
| 2729 currentContextSources.remove(path); | 2728 currentContextSources.remove(path); |
| 2730 lastFlushedFiles = flushedFiles; | 2729 lastFlushedFiles = flushedFiles; |
| 2731 } | 2730 } |
| 2732 | 2731 |
| 2733 @override | 2732 @override |
| 2734 void updateContextPackageUriResolver(AnalysisContext context) { | 2733 void updateContextPackageUriResolver(AnalysisContext context) { |
| 2735 // Nothing to do. | 2734 // Nothing to do. |
| 2736 } | 2735 } |
| 2737 | |
| 2738 /// If [disposition] has a package map, attempt to locate `_embedder.yaml` | |
| 2739 /// files. | |
| 2740 void _locateEmbedderYamls( | |
| 2741 InternalAnalysisContext context, FolderDisposition disposition) { | |
| 2742 Map<String, List<Folder>> packageMap; | |
| 2743 if (disposition is PackageMapDisposition) { | |
| 2744 packageMap = disposition.packageMap; | |
| 2745 } else if (disposition is PackagesFileDisposition) { | |
| 2746 packageMap = disposition.buildPackageMap(resourceProvider); | |
| 2747 } | |
| 2748 context.embedderYamlLocator.refresh(packageMap); | |
| 2749 } | |
| 2750 } | 2736 } |
| 2751 | 2737 |
| 2752 /** | 2738 /** |
| 2753 * A [Source] that knows it's [fullName]. | 2739 * A [Source] that knows it's [fullName]. |
| 2754 */ | 2740 */ |
| 2755 class TestSource implements Source { | 2741 class TestSource implements Source { |
| 2756 TestSource(); | 2742 TestSource(); |
| 2757 | 2743 |
| 2758 @override | 2744 @override |
| 2759 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2745 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2760 } | 2746 } |
| 2761 | 2747 |
| 2762 class TestUriResolver extends UriResolver { | 2748 class TestUriResolver extends UriResolver { |
| 2763 Map<Uri, Source> uriMap; | 2749 Map<Uri, Source> uriMap; |
| 2764 | 2750 |
| 2765 TestUriResolver(this.uriMap); | 2751 TestUriResolver(this.uriMap); |
| 2766 | 2752 |
| 2767 @override | 2753 @override |
| 2768 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 2754 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 2769 return uriMap[uri]; | 2755 return uriMap[uri]; |
| 2770 } | 2756 } |
| 2771 } | 2757 } |
| OLD | NEW |