| 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/navigation_mixin.dart'; | 10 import 'package:analyzer_plugin/plugin/navigation_mixin.dart'; |
| 11 import 'package:analyzer_plugin/protocol/protocol.dart'; |
| 11 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 12 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| 12 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; | 13 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; |
| 13 import 'package:analyzer_plugin/src/utilities/navigation/navigation.dart'; | 14 import 'package:analyzer_plugin/src/utilities/navigation/navigation.dart'; |
| 14 import 'package:analyzer_plugin/utilities/navigation/navigation.dart'; | 15 import 'package:analyzer_plugin/utilities/navigation/navigation.dart'; |
| 15 import 'package:path/src/context.dart'; | 16 import 'package:path/src/context.dart'; |
| 16 import 'package:test/test.dart'; | 17 import 'package:test/test.dart'; |
| 17 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 18 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 18 | 19 |
| 19 import 'mocks.dart'; | 20 import 'mocks.dart'; |
| 20 | 21 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 43 | 44 |
| 44 channel = new MockChannel(); | 45 channel = new MockChannel(); |
| 45 plugin = new _TestServerPlugin(resourceProvider); | 46 plugin = new _TestServerPlugin(resourceProvider); |
| 46 plugin.start(channel); | 47 plugin.start(channel); |
| 47 } | 48 } |
| 48 | 49 |
| 49 test_handleAnalysisGetNavigation() async { | 50 test_handleAnalysisGetNavigation() async { |
| 50 await plugin.handleAnalysisSetContextRoots( | 51 await plugin.handleAnalysisSetContextRoots( |
| 51 new AnalysisSetContextRootsParams([contextRoot1])); | 52 new AnalysisSetContextRootsParams([contextRoot1])); |
| 52 | 53 |
| 53 var result = await plugin.handleAnalysisGetNavigation( | 54 AnalysisGetNavigationResult result = |
| 54 new AnalysisGetNavigationParams(filePath1, 1, 2)); | 55 await plugin.handleAnalysisGetNavigation( |
| 56 new AnalysisGetNavigationParams(filePath1, 1, 2)); |
| 55 expect(result, isNotNull); | 57 expect(result, isNotNull); |
| 56 expect(result.files, hasLength(1)); | 58 expect(result.files, hasLength(1)); |
| 57 expect(result.targets, hasLength(1)); | 59 expect(result.targets, hasLength(1)); |
| 58 expect(result.regions, hasLength(2)); | 60 expect(result.regions, hasLength(2)); |
| 59 } | 61 } |
| 62 |
| 63 test_sendNavigationNotification() async { |
| 64 await plugin.handleAnalysisSetContextRoots( |
| 65 new AnalysisSetContextRootsParams([contextRoot1])); |
| 66 |
| 67 plugin.mockChannel.listen(null, |
| 68 onNotification: (Notification notification) { |
| 69 expect(notification, isNotNull); |
| 70 AnalysisNavigationParams params = |
| 71 new AnalysisNavigationParams.fromNotification(notification); |
| 72 expect(params.files, hasLength(1)); |
| 73 expect(params.targets, hasLength(1)); |
| 74 expect(params.regions, hasLength(2)); |
| 75 }); |
| 76 await plugin.sendNavigationNotification(filePath1); |
| 77 } |
| 60 } | 78 } |
| 61 | 79 |
| 62 class _TestNavigationContributor implements NavigationContributor { | 80 class _TestNavigationContributor implements NavigationContributor { |
| 63 int regionCount; | 81 int regionCount; |
| 64 | 82 |
| 65 _TestNavigationContributor(this.regionCount); | 83 _TestNavigationContributor(this.regionCount); |
| 66 | 84 |
| 67 @override | 85 @override |
| 68 void computeNavigation( | 86 void computeNavigation( |
| 69 NavigationRequest request, NavigationCollector collector) { | 87 NavigationRequest request, NavigationCollector collector) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 82 List<NavigationContributor> getNavigationContributors(String path) { | 100 List<NavigationContributor> getNavigationContributors(String path) { |
| 83 return <NavigationContributor>[ | 101 return <NavigationContributor>[ |
| 84 new _TestNavigationContributor(2), | 102 new _TestNavigationContributor(2), |
| 85 new _TestNavigationContributor(1) | 103 new _TestNavigationContributor(1) |
| 86 ]; | 104 ]; |
| 87 } | 105 } |
| 88 | 106 |
| 89 @override | 107 @override |
| 90 Future<NavigationRequest> getNavigationRequest( | 108 Future<NavigationRequest> getNavigationRequest( |
| 91 AnalysisGetNavigationParams parameters) async { | 109 AnalysisGetNavigationParams parameters) async { |
| 92 AnalysisResult result = new AnalysisResult( | 110 AnalysisResult result = new AnalysisResult(null, null, parameters.file, |
| 93 null, null, null, null, null, null, null, null, null, null, null); | 111 null, null, null, null, null, null, null, null); |
| 94 return new DartNavigationRequestImpl( | 112 return new DartNavigationRequestImpl( |
| 95 resourceProvider, parameters.offset, parameters.length, result); | 113 resourceProvider, parameters.offset, parameters.length, result); |
| 96 } | 114 } |
| 97 } | 115 } |
| OLD | NEW |