| 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/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| 11 import 'package:analysis_server/src/constants.dart'; | 11 import 'package:analysis_server/src/constants.dart'; |
| 12 import 'package:analysis_server/src/context_manager.dart'; |
| 12 import 'package:analysis_server/src/domain_analysis.dart'; | 13 import 'package:analysis_server/src/domain_analysis.dart'; |
| 13 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 14 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 14 import 'package:analyzer/file_system/file_system.dart'; | 15 import 'package:analyzer/file_system/file_system.dart'; |
| 15 import 'package:analyzer/file_system/memory_file_system.dart'; | 16 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 16 import 'package:analyzer/instrumentation/instrumentation.dart'; | 17 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 17 import 'package:analyzer/src/generated/sdk.dart'; | 18 import 'package:analyzer/src/generated/sdk.dart'; |
| 18 import 'package:path/path.dart'; | 19 import 'package:path/path.dart'; |
| 19 import 'package:plugin/manager.dart'; | 20 import 'package:plugin/manager.dart'; |
| 20 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 21 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 21 import 'package:unittest/unittest.dart'; | 22 import 'package:unittest/unittest.dart'; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 class AnalysisDomainTest extends AbstractAnalysisTest { | 380 class AnalysisDomainTest extends AbstractAnalysisTest { |
| 380 Map<String, List<AnalysisError>> filesErrors = {}; | 381 Map<String, List<AnalysisError>> filesErrors = {}; |
| 381 | 382 |
| 382 void processNotification(Notification notification) { | 383 void processNotification(Notification notification) { |
| 383 if (notification.event == ANALYSIS_ERRORS) { | 384 if (notification.event == ANALYSIS_ERRORS) { |
| 384 var decoded = new AnalysisErrorsParams.fromNotification(notification); | 385 var decoded = new AnalysisErrorsParams.fromNotification(notification); |
| 385 filesErrors[decoded.file] = decoded.errors; | 386 filesErrors[decoded.file] = decoded.errors; |
| 386 } | 387 } |
| 387 } | 388 } |
| 388 | 389 |
| 389 test_packageMapDependencies() async { | |
| 390 // Prepare a source file that has errors because it refers to an unknown | |
| 391 // package. | |
| 392 String pkgFile = '/packages/pkgA/libA.dart'; | |
| 393 resourceProvider.newFile( | |
| 394 pkgFile, | |
| 395 ''' | |
| 396 library lib_a; | |
| 397 class A {} | |
| 398 '''); | |
| 399 addTestFile(''' | |
| 400 import 'package:pkgA/libA.dart'; | |
| 401 f(A a) { | |
| 402 } | |
| 403 '''); | |
| 404 String pkgDependency = posix.join(projectPath, 'package_dep'); | |
| 405 resourceProvider.newFile(pkgDependency, 'contents'); | |
| 406 packageMapProvider.dependencies.add(pkgDependency); | |
| 407 // Create project and wait for analysis | |
| 408 createProject(); | |
| 409 await waitForTasksFinished(); | |
| 410 expect(filesErrors[testFile], isNotEmpty); | |
| 411 // Add the package to the package map and tickle the package dependency. | |
| 412 packageMapProvider.packageMap = { | |
| 413 'pkgA': <Folder>[resourceProvider.getResource('/packages/pkgA')] | |
| 414 }; | |
| 415 resourceProvider.modifyFile(pkgDependency, 'new contents'); | |
| 416 // Give the server time to notice the file has changed, then let | |
| 417 // analysis complete. There should now be no error. | |
| 418 await pumpEventQueue(); | |
| 419 await waitForTasksFinished(); | |
| 420 expect(filesErrors[testFile], isEmpty); | |
| 421 } | |
| 422 | |
| 423 test_setRoots_packages() { | 390 test_setRoots_packages() { |
| 424 // prepare package | 391 // prepare package |
| 425 String pkgFile = '/packages/pkgA/libA.dart'; | 392 String pkgFile = '/packages/pkgA/libA.dart'; |
| 426 resourceProvider.newFile( | 393 resourceProvider.newFile( |
| 427 pkgFile, | 394 pkgFile, |
| 428 ''' | 395 ''' |
| 429 library lib_a; | 396 library lib_a; |
| 430 class A {} | 397 class A {} |
| 431 '''); | 398 '''); |
| 432 resourceProvider.newFile( | 399 resourceProvider.newFile( |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 test_beforeAnalysis() async { | 777 test_beforeAnalysis() async { |
| 811 addTestFile('int V = 42;'); | 778 addTestFile('int V = 42;'); |
| 812 createProject(); | 779 createProject(); |
| 813 // subscribe | 780 // subscribe |
| 814 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile); | 781 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile); |
| 815 // wait for analysis | 782 // wait for analysis |
| 816 await waitForTasksFinished(); | 783 await waitForTasksFinished(); |
| 817 expect(filesHighlights[testFile], isNotEmpty); | 784 expect(filesHighlights[testFile], isNotEmpty); |
| 818 } | 785 } |
| 819 } | 786 } |
| OLD | NEW |