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

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

Issue 497393002: 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; 5 library test.domain.analysis;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 */ 414 */
415 class AnalysisTestHelper { 415 class AnalysisTestHelper {
416 MockServerChannel serverChannel; 416 MockServerChannel serverChannel;
417 MemoryResourceProvider resourceProvider; 417 MemoryResourceProvider resourceProvider;
418 AnalysisServer server; 418 AnalysisServer server;
419 AnalysisDomainHandler handler; 419 AnalysisDomainHandler handler;
420 420
421 Map<AnalysisService, List<String>> analysisSubscriptions = {}; 421 Map<AnalysisService, List<String>> analysisSubscriptions = {};
422 422
423 Map<String, List<AnalysisError>> filesErrors = {}; 423 Map<String, List<AnalysisError>> filesErrors = {};
424 Map<String, List<Map<String, Object>>> filesHighlights = {}; 424 Map<String, List<HighlightRegion>> filesHighlights = {};
425 Map<String, List<Map<String, Object>>> filesNavigation = {}; 425 Map<String, List<NavigationRegion>> filesNavigation = {};
426 426
427 String testFile = '/project/bin/test.dart'; 427 String testFile = '/project/bin/test.dart';
428 String testCode; 428 String testCode;
429 429
430 AnalysisTestHelper() { 430 AnalysisTestHelper() {
431 serverChannel = new MockServerChannel(); 431 serverChannel = new MockServerChannel();
432 resourceProvider = new MemoryResourceProvider(); 432 resourceProvider = new MemoryResourceProvider();
433 server = new AnalysisServer( 433 server = new AnalysisServer(
434 serverChannel, 434 serverChannel,
435 resourceProvider, 435 resourceProvider,
436 new MockPackageMapProvider(), 436 new MockPackageMapProvider(),
437 null, 437 null,
438 new MockSdk()); 438 new MockSdk());
439 handler = new AnalysisDomainHandler(server); 439 handler = new AnalysisDomainHandler(server);
440 // listen for notifications 440 // listen for notifications
441 Stream<Notification> notificationStream = 441 Stream<Notification> notificationStream =
442 serverChannel.notificationController.stream; 442 serverChannel.notificationController.stream;
443 notificationStream.listen((Notification notification) { 443 notificationStream.listen((Notification notification) {
444 if (notification.event == ANALYSIS_ERRORS) { 444 if (notification.event == ANALYSIS_ERRORS) {
445 var decoded = new AnalysisErrorsParams.fromNotification(notification); 445 var decoded = new AnalysisErrorsParams.fromNotification(notification);
446 filesErrors[decoded.file] = decoded.errors; 446 filesErrors[decoded.file] = decoded.errors;
447 } 447 }
448 if (notification.event == ANALYSIS_HIGHLIGHTS) { 448 if (notification.event == ANALYSIS_HIGHLIGHTS) {
449 String file = notification.getParameter(FILE); 449 var params = new AnalysisHighlightsParams.fromNotification(notification) ;
450 filesHighlights[file] = notification.getParameter(REGIONS); 450 filesHighlights[params.file] = params.regions;
451 } 451 }
452 if (notification.event == ANALYSIS_NAVIGATION) { 452 if (notification.event == ANALYSIS_NAVIGATION) {
453 String file = notification.getParameter(FILE); 453 var params = new AnalysisNavigationParams.fromNotification(notification) ;
454 filesNavigation[file] = notification.getParameter(REGIONS); 454 filesNavigation[params.file] = params.regions;
455 } 455 }
456 }); 456 });
457 } 457 }
458 458
459 void addAnalysisSubscription(AnalysisService service, String file) { 459 void addAnalysisSubscription(AnalysisService service, String file) {
460 // add file to subscription 460 // add file to subscription
461 var files = analysisSubscriptions[service]; 461 var files = analysisSubscriptions[service];
462 if (files == null) { 462 if (files == null) {
463 files = <String>[]; 463 files = <String>[];
464 analysisSubscriptions[service] = files; 464 analysisSubscriptions[service] = files;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 if (errors != null) { 520 if (errors != null) {
521 return errors; 521 return errors;
522 } 522 }
523 return <AnalysisError>[]; 523 return <AnalysisError>[];
524 } 524 }
525 525
526 /** 526 /**
527 * Returns highlights recorded for the given [file]. 527 * Returns highlights recorded for the given [file].
528 * May be empty, but not `null`. 528 * May be empty, but not `null`.
529 */ 529 */
530 List<Map<String, Object>> getHighlights(String file) { 530 List<HighlightRegion> getHighlights(String file) {
531 List<Map<String, Object>> highlights = filesHighlights[file]; 531 List<HighlightRegion> highlights = filesHighlights[file];
532 if (highlights != null) { 532 if (highlights != null) {
533 return highlights; 533 return highlights;
534 } 534 }
535 return []; 535 return [];
536 } 536 }
537 537
538 /** 538 /**
539 * Returns navigation regions recorded for the given [file]. 539 * Returns navigation regions recorded for the given [file].
540 * May be empty, but not `null`. 540 * May be empty, but not `null`.
541 */ 541 */
542 List<Map<String, Object>> getNavigation(String file) { 542 List<NavigationRegion> getNavigation(String file) {
543 List<Map<String, Object>> navigation = filesNavigation[file]; 543 List<NavigationRegion> navigation = filesNavigation[file];
544 if (navigation != null) { 544 if (navigation != null) {
545 return navigation; 545 return navigation;
546 } 546 }
547 return []; 547 return [];
548 } 548 }
549 549
550 /** 550 /**
551 * Returns [AnalysisError]s recorded for the [testFile]. 551 * Returns [AnalysisError]s recorded for the [testFile].
552 * May be empty, but not `null`. 552 * May be empty, but not `null`.
553 */ 553 */
554 List<AnalysisError> getTestErrors() { 554 List<AnalysisError> getTestErrors() {
555 return getErrors(testFile); 555 return getErrors(testFile);
556 } 556 }
557 557
558 /** 558 /**
559 * Returns highlights recorded for the given [testFile]. 559 * Returns highlights recorded for the given [testFile].
560 * May be empty, but not `null`. 560 * May be empty, but not `null`.
561 */ 561 */
562 List<Map<String, Object>> getTestHighlights() { 562 List<HighlightRegion> getTestHighlights() {
563 return getHighlights(testFile); 563 return getHighlights(testFile);
564 } 564 }
565 565
566 /** 566 /**
567 * Returns navigation information recorded for the given [testFile]. 567 * Returns navigation information recorded for the given [testFile].
568 * May be empty, but not `null`. 568 * May be empty, but not `null`.
569 */ 569 */
570 List<Map<String, Object>> getTestNavigation() { 570 List<NavigationRegion> getTestNavigation() {
571 return getNavigation(testFile); 571 return getNavigation(testFile);
572 } 572 }
573 573
574 /** 574 /**
575 * Validates that the given [request] is handled successfully. 575 * Validates that the given [request] is handled successfully.
576 */ 576 */
577 void handleSuccessfulRequest(Request request) { 577 void handleSuccessfulRequest(Request request) {
578 Response response = handler.handleRequest(request); 578 Response response = handler.handleRequest(request);
579 expect(response, isResponseSuccess('0')); 579 expect(response, isResponseSuccess('0'));
580 } 580 }
(...skipping 27 matching lines...) Expand all
608 return waitForServerOperationsPerformed(server); 608 return waitForServerOperationsPerformed(server);
609 } 609 }
610 610
611 static String _getCodeString(code) { 611 static String _getCodeString(code) {
612 if (code is List<String>) { 612 if (code is List<String>) {
613 code = code.join('\n'); 613 code = code.join('\n');
614 } 614 }
615 return code as String; 615 return code as String;
616 } 616 }
617 } 617 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | pkg/analysis_server/test/domain_completion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698