| 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/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 class AnalysisDomainTest extends AbstractAnalysisTest { | 280 class AnalysisDomainTest extends AbstractAnalysisTest { |
| 281 Map<String, List<AnalysisError>> filesErrors = {}; | 281 Map<String, List<AnalysisError>> filesErrors = {}; |
| 282 | 282 |
| 283 void processNotification(Notification notification) { | 283 void processNotification(Notification notification) { |
| 284 if (notification.event == ANALYSIS_ERRORS) { | 284 if (notification.event == ANALYSIS_ERRORS) { |
| 285 var decoded = new AnalysisErrorsParams.fromNotification(notification); | 285 var decoded = new AnalysisErrorsParams.fromNotification(notification); |
| 286 filesErrors[decoded.file] = decoded.errors; | 286 filesErrors[decoded.file] = decoded.errors; |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 test_packageMapDependencies() { | 290 test_packageMapDependencies() async { |
| 291 // Prepare a source file that has errors because it refers to an unknown | 291 // Prepare a source file that has errors because it refers to an unknown |
| 292 // package. | 292 // package. |
| 293 String pkgFile = '/packages/pkgA/libA.dart'; | 293 String pkgFile = '/packages/pkgA/libA.dart'; |
| 294 resourceProvider.newFile(pkgFile, ''' | 294 resourceProvider.newFile(pkgFile, ''' |
| 295 library lib_a; | 295 library lib_a; |
| 296 class A {} | 296 class A {} |
| 297 '''); | 297 '''); |
| 298 addTestFile(''' | 298 addTestFile(''' |
| 299 import 'package:pkgA/libA.dart'; | 299 import 'package:pkgA/libA.dart'; |
| 300 f(A a) { | 300 f(A a) { |
| 301 } | 301 } |
| 302 '''); | 302 '''); |
| 303 String pkgDependency = posix.join(projectPath, 'package_dep'); | 303 String pkgDependency = posix.join(projectPath, 'package_dep'); |
| 304 resourceProvider.newFile(pkgDependency, 'contents'); | 304 resourceProvider.newFile(pkgDependency, 'contents'); |
| 305 packageMapProvider.dependencies.add(pkgDependency); | 305 packageMapProvider.dependencies.add(pkgDependency); |
| 306 // Create project and wait for analysis | 306 // Create project and wait for analysis |
| 307 createProject(); | 307 createProject(); |
| 308 return waitForTasksFinished().then((_) { | 308 await waitForTasksFinished(); |
| 309 expect(filesErrors[testFile], isNotEmpty); | 309 expect(filesErrors[testFile], isNotEmpty); |
| 310 // Add the package to the package map and tickle the package dependency. | 310 // Add the package to the package map and tickle the package dependency. |
| 311 packageMapProvider.packageMap = { | 311 packageMapProvider.packageMap = { |
| 312 'pkgA': [resourceProvider.getResource('/packages/pkgA')] | 312 'pkgA': [resourceProvider.getResource('/packages/pkgA')] |
| 313 }; | 313 }; |
| 314 resourceProvider.modifyFile(pkgDependency, 'new contents'); | 314 resourceProvider.modifyFile(pkgDependency, 'new contents'); |
| 315 // Give the server time to notice the file has changed, then let | 315 // Give the server time to notice the file has changed, then let |
| 316 // analysis complete. There should now be no error. | 316 // analysis complete. There should now be no error. |
| 317 return pumpEventQueue().then((_) => waitForTasksFinished()).then((_) { | 317 await pumpEventQueue(); |
| 318 expect(filesErrors[testFile], isEmpty); | 318 await waitForTasksFinished(); |
| 319 }); | 319 expect(filesErrors[testFile], isEmpty); |
| 320 }); | |
| 321 } | 320 } |
| 322 | 321 |
| 323 test_setRoots_packages() { | 322 test_setRoots_packages() { |
| 324 // prepare package | 323 // prepare package |
| 325 String pkgFile = '/packages/pkgA/libA.dart'; | 324 String pkgFile = '/packages/pkgA/libA.dart'; |
| 326 resourceProvider.newFile(pkgFile, ''' | 325 resourceProvider.newFile(pkgFile, ''' |
| 327 library lib_a; | 326 library lib_a; |
| 328 class A {} | 327 class A {} |
| 329 '''); | 328 '''); |
| 330 packageMapProvider.packageMap['pkgA'] = | 329 packageMapProvider.packageMap['pkgA'] = |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 test_beforeAnalysis() async { | 696 test_beforeAnalysis() async { |
| 698 addTestFile('int V = 42;'); | 697 addTestFile('int V = 42;'); |
| 699 createProject(); | 698 createProject(); |
| 700 // subscribe | 699 // subscribe |
| 701 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile); | 700 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile); |
| 702 // wait for analysis | 701 // wait for analysis |
| 703 await waitForTasksFinished(); | 702 await waitForTasksFinished(); |
| 704 expect(filesHighlights[testFile], isNotEmpty); | 703 expect(filesHighlights[testFile], isNotEmpty); |
| 705 } | 704 } |
| 706 } | 705 } |
| OLD | NEW |