| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 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/dart/analysis/driver.dart'; | 9 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 10 import 'package:analyzer_plugin/plugin/plugin.dart'; | 10 import 'package:analyzer_plugin/plugin/plugin.dart'; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 contextRoot1 = new ContextRoot(packagePath1, <String>[]); | 57 contextRoot1 = new ContextRoot(packagePath1, <String>[]); |
| 58 | 58 |
| 59 packagePath2 = resourceProvider.convertPath('/package2'); | 59 packagePath2 = resourceProvider.convertPath('/package2'); |
| 60 filePath2 = pathContext.join(packagePath2, 'lib', 'test.dart'); | 60 filePath2 = pathContext.join(packagePath2, 'lib', 'test.dart'); |
| 61 resourceProvider.newFile(filePath2, ''); | 61 resourceProvider.newFile(filePath2, ''); |
| 62 contextRoot2 = new ContextRoot(packagePath2, <String>[]); | 62 contextRoot2 = new ContextRoot(packagePath2, <String>[]); |
| 63 | 63 |
| 64 plugin = new TestServerPlugin(resourceProvider); | 64 plugin = new TestServerPlugin(resourceProvider); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void test_contextRootContaining_insideRoot() { | 67 test_contextRootContaining_insideRoot() async { |
| 68 plugin.handleAnalysisSetContextRoots( | 68 await plugin.handleAnalysisSetContextRoots( |
| 69 new AnalysisSetContextRootsParams([contextRoot1])); | 69 new AnalysisSetContextRootsParams([contextRoot1])); |
| 70 | 70 |
| 71 expect(plugin.contextRootContaining(filePath1), isNotNull); | 71 expect(plugin.contextRootContaining(filePath1), isNotNull); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void test_contextRootContaining_noRoots() { | 74 void test_contextRootContaining_noRoots() { |
| 75 expect(plugin.contextRootContaining(filePath1), isNull); | 75 expect(plugin.contextRootContaining(filePath1), isNull); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void test_contextRootContaining_outsideRoot() { | 78 test_contextRootContaining_outsideRoot() async { |
| 79 plugin.handleAnalysisSetContextRoots( | 79 await plugin.handleAnalysisSetContextRoots( |
| 80 new AnalysisSetContextRootsParams([contextRoot1])); | 80 new AnalysisSetContextRootsParams([contextRoot1])); |
| 81 | 81 |
| 82 expect(plugin.contextRootContaining(filePath2), isNull); | 82 expect(plugin.contextRootContaining(filePath2), isNull); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void test_handleAnalysisHandleWatchEvents() { | 85 test_handleAnalysisHandleWatchEvents() async { |
| 86 var result = plugin.handleAnalysisHandleWatchEvents( | 86 var result = await plugin.handleAnalysisHandleWatchEvents( |
| 87 new AnalysisHandleWatchEventsParams([])); | 87 new AnalysisHandleWatchEventsParams([])); |
| 88 expect(result, isNotNull); | 88 expect(result, isNotNull); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void test_handleAnalysisReanalyze_all() { | 91 test_handleAnalysisReanalyze_all() async { |
| 92 plugin.handleAnalysisSetContextRoots( | 92 await plugin.handleAnalysisSetContextRoots( |
| 93 new AnalysisSetContextRootsParams([contextRoot1])); | 93 new AnalysisSetContextRootsParams([contextRoot1])); |
| 94 var result = plugin.handleAnalysisReanalyze(new AnalysisReanalyzeParams()); | 94 var result = |
| 95 await plugin.handleAnalysisReanalyze(new AnalysisReanalyzeParams()); |
| 95 expect(result, isNotNull); | 96 expect(result, isNotNull); |
| 96 } | 97 } |
| 97 | 98 |
| 98 @failingTest | 99 @failingTest |
| 99 void test_handleAnalysisReanalyze_subset() { | 100 test_handleAnalysisReanalyze_subset() async { |
| 100 plugin.handleAnalysisSetContextRoots( | 101 await plugin.handleAnalysisSetContextRoots( |
| 101 new AnalysisSetContextRootsParams([contextRoot1])); | 102 new AnalysisSetContextRootsParams([contextRoot1])); |
| 102 plugin.handleAnalysisSetContextRoots( | 103 await plugin.handleAnalysisSetContextRoots( |
| 103 new AnalysisSetContextRootsParams([contextRoot2])); | 104 new AnalysisSetContextRootsParams([contextRoot2])); |
| 104 var result = plugin.handleAnalysisReanalyze( | 105 var result = await plugin.handleAnalysisReanalyze( |
| 105 new AnalysisReanalyzeParams(roots: [packagePath2])); | 106 new AnalysisReanalyzeParams(roots: [packagePath2])); |
| 106 expect(result, isNotNull); | 107 expect(result, isNotNull); |
| 107 } | 108 } |
| 108 | 109 |
| 109 @failingTest | 110 @failingTest |
| 110 void test_handleAnalysisSetContextBuilderOptions() { | 111 test_handleAnalysisSetContextBuilderOptions() async { |
| 111 var result = plugin.handleAnalysisSetContextBuilderOptions( | 112 var result = await plugin.handleAnalysisSetContextBuilderOptions( |
| 112 new AnalysisSetContextBuilderOptionsParams( | 113 new AnalysisSetContextBuilderOptionsParams( |
| 113 new ContextBuilderOptions())); | 114 new ContextBuilderOptions())); |
| 114 expect(result, isNotNull); | 115 expect(result, isNotNull); |
| 115 } | 116 } |
| 116 | 117 |
| 117 void test_handleAnalysisSetContextRoots() { | 118 test_handleAnalysisSetContextRoots() async { |
| 118 var result = plugin.handleAnalysisSetContextRoots( | 119 var result = await plugin.handleAnalysisSetContextRoots( |
| 119 new AnalysisSetContextRootsParams([contextRoot1])); | 120 new AnalysisSetContextRootsParams([contextRoot1])); |
| 120 expect(result, isNotNull); | 121 expect(result, isNotNull); |
| 121 expect(plugin.driverMap[contextRoot1], isNotNull); | 122 expect(plugin.driverMap[contextRoot1], isNotNull); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void test_handleAnalysisSetPriorityFiles() { | 125 test_handleAnalysisSetPriorityFiles() async { |
| 125 plugin.handleAnalysisSetContextRoots( | 126 await plugin.handleAnalysisSetContextRoots( |
| 126 new AnalysisSetContextRootsParams([contextRoot1])); | 127 new AnalysisSetContextRootsParams([contextRoot1])); |
| 127 | 128 |
| 128 var result = plugin.handleAnalysisSetPriorityFiles( | 129 var result = await plugin.handleAnalysisSetPriorityFiles( |
| 129 new AnalysisSetPriorityFilesParams([filePath1])); | 130 new AnalysisSetPriorityFilesParams([filePath1])); |
| 130 expect(result, isNotNull); | 131 expect(result, isNotNull); |
| 131 } | 132 } |
| 132 | 133 |
| 133 void test_handleAnalysisSetSubscriptions() { | 134 test_handleAnalysisSetSubscriptions() async { |
| 134 plugin.handleAnalysisSetContextRoots( | 135 await plugin.handleAnalysisSetContextRoots( |
| 135 new AnalysisSetContextRootsParams([contextRoot1])); | 136 new AnalysisSetContextRootsParams([contextRoot1])); |
| 136 expect(plugin.subscriptionManager.servicesForFile(filePath1), isEmpty); | 137 expect(plugin.subscriptionManager.servicesForFile(filePath1), isEmpty); |
| 137 | 138 |
| 138 AnalysisSetSubscriptionsResult result = plugin | 139 AnalysisSetSubscriptionsResult result = await plugin |
| 139 .handleAnalysisSetSubscriptions(new AnalysisSetSubscriptionsParams({ | 140 .handleAnalysisSetSubscriptions(new AnalysisSetSubscriptionsParams({ |
| 140 AnalysisService.OUTLINE: [filePath1] | 141 AnalysisService.OUTLINE: [filePath1] |
| 141 })); | 142 })); |
| 142 expect(result, isNotNull); | 143 expect(result, isNotNull); |
| 143 expect(plugin.subscriptionManager.servicesForFile(filePath1), | 144 expect(plugin.subscriptionManager.servicesForFile(filePath1), |
| 144 [AnalysisService.OUTLINE]); | 145 [AnalysisService.OUTLINE]); |
| 145 } | 146 } |
| 146 | 147 |
| 147 void test_handleAnalysisUpdateContent() { | 148 test_handleAnalysisUpdateContent() async { |
| 148 plugin.handleAnalysisSetContextRoots( | 149 await plugin.handleAnalysisSetContextRoots( |
| 149 new AnalysisSetContextRootsParams([contextRoot1])); | 150 new AnalysisSetContextRootsParams([contextRoot1])); |
| 150 var addResult = plugin.handleAnalysisUpdateContent( | 151 var addResult = await plugin.handleAnalysisUpdateContent( |
| 151 new AnalysisUpdateContentParams( | 152 new AnalysisUpdateContentParams( |
| 152 {filePath1: new AddContentOverlay('class C {}')})); | 153 {filePath1: new AddContentOverlay('class C {}')})); |
| 153 expect(addResult, isNotNull); | 154 expect(addResult, isNotNull); |
| 154 var changeResult = | 155 var changeResult = await plugin |
| 155 plugin.handleAnalysisUpdateContent(new AnalysisUpdateContentParams({ | 156 .handleAnalysisUpdateContent(new AnalysisUpdateContentParams({ |
| 156 filePath1: | 157 filePath1: |
| 157 new ChangeContentOverlay([new SourceEdit(7, 0, ' extends Object')]) | 158 new ChangeContentOverlay([new SourceEdit(7, 0, ' extends Object')]) |
| 158 })); | 159 })); |
| 159 expect(changeResult, isNotNull); | 160 expect(changeResult, isNotNull); |
| 160 var removeResult = plugin.handleAnalysisUpdateContent( | 161 var removeResult = await plugin.handleAnalysisUpdateContent( |
| 161 new AnalysisUpdateContentParams( | 162 new AnalysisUpdateContentParams( |
| 162 {filePath1: new RemoveContentOverlay()})); | 163 {filePath1: new RemoveContentOverlay()})); |
| 163 expect(removeResult, isNotNull); | 164 expect(removeResult, isNotNull); |
| 164 } | 165 } |
| 165 | 166 |
| 166 void test_handleCompletionGetSuggestions() { | 167 test_handleCompletionGetSuggestions() async { |
| 167 plugin.handleAnalysisSetContextRoots( | 168 await plugin.handleAnalysisSetContextRoots( |
| 168 new AnalysisSetContextRootsParams([contextRoot1])); | 169 new AnalysisSetContextRootsParams([contextRoot1])); |
| 169 | 170 |
| 170 CompletionGetSuggestionsResult result = | 171 CompletionGetSuggestionsResult result = |
| 171 plugin.handleCompletionGetSuggestions( | 172 await plugin.handleCompletionGetSuggestions( |
| 172 new CompletionGetSuggestionsParams(filePath1, 12)); | 173 new CompletionGetSuggestionsParams(filePath1, 12)); |
| 173 expect(result, isNotNull); | 174 expect(result, isNotNull); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void test_handleEditGetAssists() { | 177 test_handleEditGetAssists() async { |
| 177 plugin.handleAnalysisSetContextRoots( | 178 await plugin.handleAnalysisSetContextRoots( |
| 178 new AnalysisSetContextRootsParams([contextRoot1])); | 179 new AnalysisSetContextRootsParams([contextRoot1])); |
| 179 | 180 |
| 180 EditGetAssistsResult result = | 181 EditGetAssistsResult result = await plugin |
| 181 plugin.handleEditGetAssists(new EditGetAssistsParams(filePath1, 10, 0)); | 182 .handleEditGetAssists(new EditGetAssistsParams(filePath1, 10, 0)); |
| 182 expect(result, isNotNull); | 183 expect(result, isNotNull); |
| 183 } | 184 } |
| 184 | 185 |
| 185 void test_handleEditGetAvailableRefactorings() { | 186 test_handleEditGetAvailableRefactorings() async { |
| 186 plugin.handleAnalysisSetContextRoots( | 187 await plugin.handleAnalysisSetContextRoots( |
| 187 new AnalysisSetContextRootsParams([contextRoot1])); | 188 new AnalysisSetContextRootsParams([contextRoot1])); |
| 188 | 189 |
| 189 EditGetAvailableRefactoringsResult result = | 190 EditGetAvailableRefactoringsResult result = |
| 190 plugin.handleEditGetAvailableRefactorings( | 191 await plugin.handleEditGetAvailableRefactorings( |
| 191 new EditGetAvailableRefactoringsParams(filePath1, 10, 0)); | 192 new EditGetAvailableRefactoringsParams(filePath1, 10, 0)); |
| 192 expect(result, isNotNull); | 193 expect(result, isNotNull); |
| 193 } | 194 } |
| 194 | 195 |
| 195 void test_handleEditGetFixes() { | 196 test_handleEditGetFixes() async { |
| 196 plugin.handleAnalysisSetContextRoots( | 197 await plugin.handleAnalysisSetContextRoots( |
| 197 new AnalysisSetContextRootsParams([contextRoot1])); | 198 new AnalysisSetContextRootsParams([contextRoot1])); |
| 198 | 199 |
| 199 EditGetFixesResult result = | 200 EditGetFixesResult result = |
| 200 plugin.handleEditGetFixes(new EditGetFixesParams(filePath1, 13)); | 201 await plugin.handleEditGetFixes(new EditGetFixesParams(filePath1, 13)); |
| 201 expect(result, isNotNull); | 202 expect(result, isNotNull); |
| 202 } | 203 } |
| 203 | 204 |
| 204 @failingTest | 205 @failingTest |
| 205 void test_handleEditGetRefactoring() { | 206 test_handleEditGetRefactoring() async { |
| 206 plugin.handleAnalysisSetContextRoots( | 207 await plugin.handleAnalysisSetContextRoots( |
| 207 new AnalysisSetContextRootsParams([contextRoot1])); | 208 new AnalysisSetContextRootsParams([contextRoot1])); |
| 208 | 209 |
| 209 EditGetRefactoringResult result = plugin.handleEditGetRefactoring( | 210 EditGetRefactoringResult result = await plugin.handleEditGetRefactoring( |
| 210 new EditGetRefactoringParams( | 211 new EditGetRefactoringParams( |
| 211 RefactoringKind.RENAME, filePath1, 7, 0, false)); | 212 RefactoringKind.RENAME, filePath1, 7, 0, false)); |
| 212 expect(result, isNotNull); | 213 expect(result, isNotNull); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void test_handlePluginShutdown() { | 216 test_handlePluginShutdown() async { |
| 216 var result = plugin.handlePluginShutdown(new PluginShutdownParams()); | 217 var result = await plugin.handlePluginShutdown(new PluginShutdownParams()); |
| 217 expect(result, isNotNull); | 218 expect(result, isNotNull); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void test_handlePluginVersionCheck() { | 221 test_handlePluginVersionCheck() async { |
| 221 PluginVersionCheckResult result = plugin.handlePluginVersionCheck( | 222 PluginVersionCheckResult result = await plugin.handlePluginVersionCheck( |
| 222 new PluginVersionCheckParams('path', '0.1.0')); | 223 new PluginVersionCheckParams('path', '0.1.0')); |
| 223 expect(result, isNotNull); | 224 expect(result, isNotNull); |
| 224 expect(result.interestingFiles, ['*.dart']); | 225 expect(result.interestingFiles, ['*.dart']); |
| 225 expect(result.isCompatible, isTrue); | 226 expect(result.isCompatible, isTrue); |
| 226 expect(result.name, 'Test Plugin'); | 227 expect(result.name, 'Test Plugin'); |
| 227 expect(result.version, '0.1.0'); | 228 expect(result.version, '0.1.0'); |
| 228 } | 229 } |
| 229 | 230 |
| 230 @failingTest | 231 @failingTest |
| 231 void test_isCompatibleWith() { | 232 void test_isCompatibleWith() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 AnalysisDriverGeneric createAnalysisDriver(ContextRoot contextRoot) { | 270 AnalysisDriverGeneric createAnalysisDriver(ContextRoot contextRoot) { |
| 270 return new MockAnalysisDriver(); | 271 return new MockAnalysisDriver(); |
| 271 } | 272 } |
| 272 | 273 |
| 273 @override | 274 @override |
| 274 void sendNotificationsForSubscriptions( | 275 void sendNotificationsForSubscriptions( |
| 275 Map<String, List<AnalysisService>> subscriptions) { | 276 Map<String, List<AnalysisService>> subscriptions) { |
| 276 latestSubscriptions = subscriptions; | 277 latestSubscriptions = subscriptions; |
| 277 } | 278 } |
| 278 } | 279 } |
| OLD | NEW |