Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: pkg/analysis_server/test/analysis_notification_navigation_test.dart

Issue 479683005: Make more use of generated code in analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.domain.analysis.notification.navigation; 5 library test.domain.analysis.notification.navigation;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/computer/element.dart';
10 import 'package:analysis_server/src/constants.dart'; 9 import 'package:analysis_server/src/constants.dart';
11 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
12 import 'package:analysis_server/src/protocol2.dart' show AnalysisService, 11 import 'package:analysis_server/src/protocol2.dart';
13 ElementKind;
14 import 'package:analysis_testing/reflective_tests.dart'; 12 import 'package:analysis_testing/reflective_tests.dart';
15 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
16 14
17 import 'analysis_abstract.dart'; 15 import 'analysis_abstract.dart';
18 16
19 17
20 main() { 18 main() {
21 groupSep = ' | '; 19 groupSep = ' | ';
22 runReflectiveTests(AnalysisNotificationNavigationTest); 20 runReflectiveTests(AnalysisNotificationNavigationTest);
23 } 21 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 155 }
158 } 156 }
159 157
160 Future prepareNavigation() { 158 Future prepareNavigation() {
161 addAnalysisSubscription(AnalysisService.NAVIGATION, testFile); 159 addAnalysisSubscription(AnalysisService.NAVIGATION, testFile);
162 return waitForTasksFinished(); 160 return waitForTasksFinished();
163 } 161 }
164 162
165 void processNotification(Notification notification) { 163 void processNotification(Notification notification) {
166 if (notification.event == ANALYSIS_NAVIGATION) { 164 if (notification.event == ANALYSIS_NAVIGATION) {
167 String file = notification.getParameter(FILE); 165 var params = new AnalysisNavigationParams.fromNotification(notification);
scheglov 2014/08/21 18:03:22 Great!
168 if (file == testFile) { 166 if (params.file == testFile) {
169 regions = <NavigationRegion>[]; 167 regions = params.regions;
170 List<Map<String, Object>> regionsJson =
171 notification.getParameter(REGIONS);
172 for (Map<String, Object> regionJson in regionsJson) {
173 var regionOffset = regionJson[OFFSET];
174 var regionLength = regionJson[LENGTH];
175 List<Element> targets = <Element>[];
176 for (Map<String, Object> targetJson in regionJson[TARGETS]) {
177 targets.add(new Element.fromJson(targetJson));
178 }
179 var region =
180 new NavigationRegion(regionOffset, regionLength, targets);
181 regions.add(region);
182 }
183 } 168 }
184 } 169 }
185 } 170 }
186 171
187 @override 172 @override
188 void setUp() { 173 void setUp() {
189 super.setUp(); 174 super.setUp();
190 createProject(); 175 createProject();
191 } 176 }
192 177
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 test_type_void() { 472 test_type_void() {
488 addTestFile(''' 473 addTestFile('''
489 void main() { 474 void main() {
490 } 475 }
491 '''); 476 ''');
492 return prepareNavigation().then((_) { 477 return prepareNavigation().then((_) {
493 assertNoRegionAt('void'); 478 assertNoRegionAt('void');
494 }); 479 });
495 } 480 }
496 } 481 }
497
498
499 class NavigationRegion {
500 final int offset;
501 final int length;
502 final List<Element> targets;
503
504 NavigationRegion(this.offset, this.length, this.targets);
505
506 @override
507 String toString() {
508 return 'NavigationRegion(offset=$offset; length=$length; targets=$targets';
509 }
510 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698