| OLD | NEW |
| 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/computer/error.dart'; | |
| 11 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| 12 import 'package:analysis_server/src/domain_analysis.dart'; | 11 import 'package:analysis_server/src/domain_analysis.dart'; |
| 13 import 'package:analysis_server/src/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
| 13 import 'package:analysis_server/src/protocol2.dart' show AnalysisService, |
| 14 AnalysisError, AnalysisErrorsParams; |
| 14 import 'package:analysis_testing/mock_sdk.dart'; | 15 import 'package:analysis_testing/mock_sdk.dart'; |
| 15 import 'package:analysis_testing/reflective_tests.dart'; | 16 import 'package:analysis_testing/reflective_tests.dart'; |
| 16 import 'package:analyzer/file_system/memory_file_system.dart'; | 17 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 17 import 'package:analyzer/src/generated/engine.dart'; | 18 import 'package:analyzer/src/generated/engine.dart'; |
| 18 import 'package:path/path.dart'; | 19 import 'package:path/path.dart'; |
| 19 import 'package:unittest/unittest.dart'; | 20 import 'package:unittest/unittest.dart'; |
| 20 | 21 |
| 21 import 'analysis_abstract.dart'; | 22 import 'analysis_abstract.dart'; |
| 22 import 'mocks.dart'; | 23 import 'mocks.dart'; |
| 23 | 24 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 return defaultValue; | 354 return defaultValue; |
| 354 } | 355 } |
| 355 | 356 |
| 356 | 357 |
| 357 @ReflectiveTestCase() | 358 @ReflectiveTestCase() |
| 358 class AnalysisDomainTest extends AbstractAnalysisTest { | 359 class AnalysisDomainTest extends AbstractAnalysisTest { |
| 359 Map<String, List<AnalysisError>> filesErrors = {}; | 360 Map<String, List<AnalysisError>> filesErrors = {}; |
| 360 | 361 |
| 361 void processNotification(Notification notification) { | 362 void processNotification(Notification notification) { |
| 362 if (notification.event == ANALYSIS_ERRORS) { | 363 if (notification.event == ANALYSIS_ERRORS) { |
| 363 String file = notification.getParameter(FILE); | 364 var decoded = new AnalysisErrorsParams.fromNotification(notification); |
| 364 List<Map<String, Object>> errorMaps = notification.getParameter(ERRORS); | 365 filesErrors[decoded.file] = decoded.errors; |
| 365 filesErrors[file] = errorMaps.map(AnalysisError.fromJson).toList(); | |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 | 368 |
| 369 test_packageMapDependencies() { | 369 test_packageMapDependencies() { |
| 370 // Prepare a source file that has errors because it refers to an unknown | 370 // Prepare a source file that has errors because it refers to an unknown |
| 371 // package. | 371 // package. |
| 372 String pkgFile = '/packages/pkgA/libA.dart'; | 372 String pkgFile = '/packages/pkgA/libA.dart'; |
| 373 resourceProvider.newFile(pkgFile, ''' | 373 resourceProvider.newFile(pkgFile, ''' |
| 374 library lib_a; | 374 library lib_a; |
| 375 class A {} | 375 class A {} |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 resourceProvider, | 451 resourceProvider, |
| 452 new MockPackageMapProvider(), | 452 new MockPackageMapProvider(), |
| 453 null, | 453 null, |
| 454 new MockSdk()); | 454 new MockSdk()); |
| 455 handler = new AnalysisDomainHandler(server); | 455 handler = new AnalysisDomainHandler(server); |
| 456 // listen for notifications | 456 // listen for notifications |
| 457 Stream<Notification> notificationStream = | 457 Stream<Notification> notificationStream = |
| 458 serverChannel.notificationController.stream; | 458 serverChannel.notificationController.stream; |
| 459 notificationStream.listen((Notification notification) { | 459 notificationStream.listen((Notification notification) { |
| 460 if (notification.event == ANALYSIS_ERRORS) { | 460 if (notification.event == ANALYSIS_ERRORS) { |
| 461 String file = notification.getParameter(FILE); | 461 var decoded = new AnalysisErrorsParams.fromNotification(notification); |
| 462 List<Map<String, Object>> errorMaps = notification.getParameter(ERRORS); | 462 filesErrors[decoded.file] = decoded.errors; |
| 463 filesErrors[file] = errorMaps.map(AnalysisError.fromJson).toList(); | |
| 464 } | 463 } |
| 465 if (notification.event == ANALYSIS_HIGHLIGHTS) { | 464 if (notification.event == ANALYSIS_HIGHLIGHTS) { |
| 466 String file = notification.getParameter(FILE); | 465 String file = notification.getParameter(FILE); |
| 467 filesHighlights[file] = notification.getParameter(REGIONS); | 466 filesHighlights[file] = notification.getParameter(REGIONS); |
| 468 } | 467 } |
| 469 if (notification.event == ANALYSIS_NAVIGATION) { | 468 if (notification.event == ANALYSIS_NAVIGATION) { |
| 470 String file = notification.getParameter(FILE); | 469 String file = notification.getParameter(FILE); |
| 471 filesNavigation[file] = notification.getParameter(REGIONS); | 470 filesNavigation[file] = notification.getParameter(REGIONS); |
| 472 } | 471 } |
| 473 }); | 472 }); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 return waitForServerOperationsPerformed(server); | 628 return waitForServerOperationsPerformed(server); |
| 630 } | 629 } |
| 631 | 630 |
| 632 static String _getCodeString(code) { | 631 static String _getCodeString(code) { |
| 633 if (code is List<String>) { | 632 if (code is List<String>) { |
| 634 code = code.join('\n'); | 633 code = code.join('\n'); |
| 635 } | 634 } |
| 636 return code as String; | 635 return code as String; |
| 637 } | 636 } |
| 638 } | 637 } |
| OLD | NEW |