| 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 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2303 final ResourceProvider resourceProvider; | 2303 final ResourceProvider resourceProvider; |
| 2304 | 2304 |
| 2305 TestContextManagerCallbacks(this.resourceProvider); | 2305 TestContextManagerCallbacks(this.resourceProvider); |
| 2306 | 2306 |
| 2307 /** | 2307 /** |
| 2308 * Iterable of the paths to contexts that currently exist. | 2308 * Iterable of the paths to contexts that currently exist. |
| 2309 */ | 2309 */ |
| 2310 Iterable<String> get currentContextPaths => currentContextTimestamps.keys; | 2310 Iterable<String> get currentContextPaths => currentContextTimestamps.keys; |
| 2311 | 2311 |
| 2312 @override | 2312 @override |
| 2313 AnalysisContext addContext(Folder folder, FolderDisposition disposition) { | 2313 AnalysisOptions get defaultAnalysisOptions => new AnalysisOptionsImpl(); |
| 2314 |
| 2315 @override |
| 2316 AnalysisContext addContext( |
| 2317 Folder folder, AnalysisOptions options, FolderDisposition disposition) { |
| 2314 String path = folder.path; | 2318 String path = folder.path; |
| 2315 expect(currentContextPaths, isNot(contains(path))); | 2319 expect(currentContextPaths, isNot(contains(path))); |
| 2316 currentContextTimestamps[path] = now; | 2320 currentContextTimestamps[path] = now; |
| 2317 currentContextFilePaths[path] = <String, int>{}; | 2321 currentContextFilePaths[path] = <String, int>{}; |
| 2318 currentContextSources[path] = new HashSet<Source>(); | 2322 currentContextSources[path] = new HashSet<Source>(); |
| 2319 currentContextDispositions[path] = disposition; | 2323 currentContextDispositions[path] = disposition; |
| 2320 currentContext = AnalysisEngine.instance.createAnalysisContext(); | 2324 currentContext = AnalysisEngine.instance.createAnalysisContext(); |
| 2321 _locateEmbedderYamls(currentContext, disposition); | 2325 _locateEmbedderYamls(currentContext, disposition); |
| 2322 List<UriResolver> resolvers = []; | 2326 List<UriResolver> resolvers = []; |
| 2323 if (currentContext is InternalAnalysisContext) { | 2327 if (currentContext is InternalAnalysisContext) { |
| 2324 EmbedderYamlLocator embedderYamlLocator = | 2328 EmbedderYamlLocator embedderYamlLocator = |
| 2325 (currentContext as InternalAnalysisContext).embedderYamlLocator; | 2329 (currentContext as InternalAnalysisContext).embedderYamlLocator; |
| 2326 EmbedderUriResolver embedderUriResolver = | 2330 EmbedderUriResolver embedderUriResolver = |
| 2327 new EmbedderUriResolver(embedderYamlLocator.embedderYamls); | 2331 new EmbedderUriResolver(embedderYamlLocator.embedderYamls); |
| 2328 if (embedderUriResolver.length > 0) { | 2332 if (embedderUriResolver.length > 0) { |
| 2329 // We have some embedder dart: uri mappings, add the resolver | 2333 // We have some embedder dart: uri mappings, add the resolver |
| 2330 // to the list. | 2334 // to the list. |
| 2331 resolvers.add(embedderUriResolver); | 2335 resolvers.add(embedderUriResolver); |
| 2332 } | 2336 } |
| 2333 } | 2337 } |
| 2334 resolvers.addAll(disposition.createPackageUriResolvers(resourceProvider)); | 2338 resolvers.addAll(disposition.createPackageUriResolvers(resourceProvider)); |
| 2335 resolvers.add(new FileUriResolver()); | 2339 resolvers.add(new FileUriResolver()); |
| 2340 currentContext.analysisOptions = options; |
| 2336 currentContext.sourceFactory = | 2341 currentContext.sourceFactory = |
| 2337 new SourceFactory(resolvers, disposition.packages); | 2342 new SourceFactory(resolvers, disposition.packages); |
| 2338 return currentContext; | 2343 return currentContext; |
| 2339 } | 2344 } |
| 2340 | 2345 |
| 2341 @override | 2346 @override |
| 2342 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 2347 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
| 2343 Map<String, int> filePaths = currentContextFilePaths[contextFolder.path]; | 2348 Map<String, int> filePaths = currentContextFilePaths[contextFolder.path]; |
| 2344 Set<Source> sources = currentContextSources[contextFolder.path]; | 2349 Set<Source> sources = currentContextSources[contextFolder.path]; |
| 2345 | 2350 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2427 class TestUriResolver extends UriResolver { | 2432 class TestUriResolver extends UriResolver { |
| 2428 Map<Uri, Source> uriMap; | 2433 Map<Uri, Source> uriMap; |
| 2429 | 2434 |
| 2430 TestUriResolver(this.uriMap); | 2435 TestUriResolver(this.uriMap); |
| 2431 | 2436 |
| 2432 @override | 2437 @override |
| 2433 Source resolveAbsolute(Uri uri, [Uri actualUri]) { | 2438 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 2434 return uriMap[uri]; | 2439 return uriMap[uri]; |
| 2435 } | 2440 } |
| 2436 } | 2441 } |
| OLD | NEW |