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/source/optimizing_pub_package_map_provider.d
art'; | 10 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d
art'; |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 | 919 |
920 class TestContextManager extends ContextManager { | 920 class TestContextManager extends ContextManager { |
921 /** | 921 /** |
922 * Source of timestamps stored in [currentContextFilePaths]. | 922 * Source of timestamps stored in [currentContextFilePaths]. |
923 */ | 923 */ |
924 int now = 0; | 924 int now = 0; |
925 | 925 |
926 /** | 926 /** |
927 * The analysis context that was created. | 927 * The analysis context that was created. |
928 */ | 928 */ |
929 AnalysisContextImpl currentContext; | 929 AnalysisContext currentContext; |
930 | 930 |
931 /** | 931 /** |
932 * Map from context to the timestamp when the context was created. | 932 * Map from context to the timestamp when the context was created. |
933 */ | 933 */ |
934 Map<String, int> currentContextTimestamps = <String, int>{}; | 934 Map<String, int> currentContextTimestamps = <String, int>{}; |
935 | 935 |
936 /** | 936 /** |
937 * Map from context to (map from file path to timestamp of last event). | 937 * Map from context to (map from file path to timestamp of last event). |
938 */ | 938 */ |
939 final Map<String, Map<String, int>> currentContextFilePaths = | 939 final Map<String, Map<String, int>> currentContextFilePaths = |
(...skipping 23 matching lines...) Expand all Loading... |
963 Iterable<String> get currentContextPaths => currentContextTimestamps.keys; | 963 Iterable<String> get currentContextPaths => currentContextTimestamps.keys; |
964 | 964 |
965 @override | 965 @override |
966 AnalysisContext addContext(Folder folder, UriResolver packageUriResolver) { | 966 AnalysisContext addContext(Folder folder, UriResolver packageUriResolver) { |
967 String path = folder.path; | 967 String path = folder.path; |
968 expect(currentContextPaths, isNot(contains(path))); | 968 expect(currentContextPaths, isNot(contains(path))); |
969 currentContextTimestamps[path] = now; | 969 currentContextTimestamps[path] = now; |
970 currentContextFilePaths[path] = <String, int>{}; | 970 currentContextFilePaths[path] = <String, int>{}; |
971 currentContextSources[path] = new HashSet<Source>(); | 971 currentContextSources[path] = new HashSet<Source>(); |
972 currentContextPackageUriResolvers[path] = packageUriResolver; | 972 currentContextPackageUriResolvers[path] = packageUriResolver; |
973 currentContext = new AnalysisContextImpl(); | 973 currentContext = AnalysisEngine.instance.createAnalysisContext(); |
974 currentContext.sourceFactory = new SourceFactory( | 974 currentContext.sourceFactory = new SourceFactory( |
975 packageUriResolver == null ? [] : [packageUriResolver]); | 975 packageUriResolver == null ? [] : [packageUriResolver]); |
976 return currentContext; | 976 return currentContext; |
977 } | 977 } |
978 | 978 |
979 @override | 979 @override |
980 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 980 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
981 Map<String, int> filePaths = currentContextFilePaths[contextFolder.path]; | 981 Map<String, int> filePaths = currentContextFilePaths[contextFolder.path]; |
982 Set<Source> sources = currentContextSources[contextFolder.path]; | 982 Set<Source> sources = currentContextSources[contextFolder.path]; |
983 | 983 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 // causing the analyzer to thrash, just ignore links to non-existent files. | 1031 // causing the analyzer to thrash, just ignore links to non-existent files. |
1032 return file.exists; | 1032 return file.exists; |
1033 } | 1033 } |
1034 | 1034 |
1035 @override | 1035 @override |
1036 void updateContextPackageUriResolver( | 1036 void updateContextPackageUriResolver( |
1037 Folder contextFolder, UriResolver packageUriResolver) { | 1037 Folder contextFolder, UriResolver packageUriResolver) { |
1038 currentContextPackageUriResolvers[contextFolder.path] = packageUriResolver; | 1038 currentContextPackageUriResolvers[contextFolder.path] = packageUriResolver; |
1039 } | 1039 } |
1040 } | 1040 } |
OLD | NEW |