| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.src.task.abstract_context_test; | 5 library test.src.task.abstract_context_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/src/context/context.dart'; | 9 import 'package:analyzer/src/context/context.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| 11 import 'package:analyzer/src/generated/engine.dart' | 11 import 'package:analyzer/src/generated/engine.dart' |
| 12 hide AnalysisContextImpl, AnalysisTask; | 12 hide AnalysisContextImpl, AnalysisTask; |
| 13 import 'package:analyzer/src/generated/sdk.dart'; | 13 import 'package:analyzer/src/generated/sdk.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; | 14 import 'package:analyzer/src/generated/source.dart'; |
| 15 import 'package:analyzer/src/plugin/engine_plugin.dart'; | 15 import 'package:analyzer/src/plugin/engine_plugin.dart'; |
| 16 import 'package:analyzer/src/task/driver.dart'; | 16 import 'package:analyzer/src/task/driver.dart'; |
| 17 import 'package:analyzer/src/task/manager.dart'; | 17 import 'package:analyzer/src/task/manager.dart'; |
| 18 import 'package:plugin/manager.dart'; | 18 import 'package:plugin/manager.dart'; |
| 19 import 'package:unittest/unittest.dart'; | 19 import 'package:unittest/unittest.dart'; |
| 20 | 20 |
| 21 import 'mock_sdk.dart'; | 21 import 'mock_sdk.dart'; |
| 22 | 22 |
| 23 class AbstractContextTest { | 23 class AbstractContextTest { |
| 24 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); | 24 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); |
| 25 | 25 |
| 26 ExtensionManager extensionManager = new ExtensionManager(); | 26 ExtensionManager extensionManager = new ExtensionManager(); |
| 27 | 27 |
| 28 DartSdk sdk = new MockSdk(); | 28 DartSdk sdk = new MockSdk(); |
| 29 SourceFactory sourceFactory; |
| 29 AnalysisContextImpl context; | 30 AnalysisContextImpl context; |
| 30 | 31 |
| 31 TaskManager taskManager = new TaskManager(); | 32 TaskManager taskManager = new TaskManager(); |
| 32 AnalysisDriver analysisDriver; | 33 AnalysisDriver analysisDriver; |
| 33 | 34 |
| 35 Source addSource(String path, String contents) { |
| 36 Source source = newSource(path, contents); |
| 37 ChangeSet changeSet = new ChangeSet(); |
| 38 changeSet.addedSource(source); |
| 39 context.applyChanges(changeSet); |
| 40 context.setContents(source, contents); |
| 41 return source; |
| 42 } |
| 43 |
| 34 /** | 44 /** |
| 35 * Assert that the given [elements] has the same number of items as the number | 45 * Assert that the given [elements] has the same number of items as the number |
| 36 * of specified [names], and that for each specified name, a corresponding | 46 * of specified [names], and that for each specified name, a corresponding |
| 37 * element can be found in the given collection with that name. | 47 * element can be found in the given collection with that name. |
| 38 */ | 48 */ |
| 39 void assertNamedElements(List<Element> elements, List<String> names) { | 49 void assertNamedElements(List<Element> elements, List<String> names) { |
| 40 for (String elemName in names) { | 50 for (String elemName in names) { |
| 41 bool found = false; | 51 bool found = false; |
| 42 for (Element elem in elements) { | 52 for (Element elem in elements) { |
| 43 if (elem.name == elemName) { | 53 if (elem.name == elemName) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 Source source = newSource(path, content); | 85 Source source = newSource(path, content); |
| 76 sources.add(source); | 86 sources.add(source); |
| 77 }); | 87 }); |
| 78 return sources; | 88 return sources; |
| 79 } | 89 } |
| 80 | 90 |
| 81 void setUp() { | 91 void setUp() { |
| 82 // configure TaskManager | 92 // configure TaskManager |
| 83 { | 93 { |
| 84 EnginePlugin plugin = AnalysisEngine.instance.enginePlugin; | 94 EnginePlugin plugin = AnalysisEngine.instance.enginePlugin; |
| 85 extensionManager.processPlugins([plugin]); | 95 if (plugin.taskExtensionPoint == null) { |
| 96 extensionManager.processPlugins([plugin]); |
| 97 } |
| 86 taskManager.addTaskDescriptors(plugin.taskDescriptors); | 98 taskManager.addTaskDescriptors(plugin.taskDescriptors); |
| 87 } | 99 } |
| 88 // prepare AnalysisContext | 100 // prepare AnalysisContext |
| 89 context = createAnalysisContext(); | 101 sourceFactory = new SourceFactory(<UriResolver>[ |
| 90 context.sourceFactory = new SourceFactory(<UriResolver>[ | |
| 91 new DartUriResolver(sdk), | 102 new DartUriResolver(sdk), |
| 92 new ResourceUriResolver(resourceProvider) | 103 new ResourceUriResolver(resourceProvider) |
| 93 ]); | 104 ]); |
| 105 context = createAnalysisContext(); |
| 106 context.sourceFactory = sourceFactory; |
| 94 // prepare AnalysisDriver | 107 // prepare AnalysisDriver |
| 95 analysisDriver = new AnalysisDriver(taskManager, context); | 108 analysisDriver = new AnalysisDriver(taskManager, context); |
| 96 } | 109 } |
| 97 | 110 |
| 98 void tearDown() {} | 111 void tearDown() {} |
| 99 } | 112 } |
| OLD | NEW |