| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/protocol/protocol.dart'; | 7 import 'package:analysis_server/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/protocol/protocol_constants.dart'; | 8 import 'package:analysis_server/protocol/protocol_constants.dart'; |
| 9 import 'package:analysis_server/protocol/protocol_generated.dart'; | 9 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 void processNotification(Notification notification) { | 383 void processNotification(Notification notification) { |
| 384 if (notification.event == ANALYSIS_NOTIFICATION_ERRORS) { | 384 if (notification.event == ANALYSIS_NOTIFICATION_ERRORS) { |
| 385 var decoded = new AnalysisErrorsParams.fromNotification(notification); | 385 var decoded = new AnalysisErrorsParams.fromNotification(notification); |
| 386 filesErrors[decoded.file] = decoded.errors; | 386 filesErrors[decoded.file] = decoded.errors; |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 test_setRoots_packages() { | 390 test_setRoots_packages() { |
| 391 // prepare package | 391 // prepare package |
| 392 String pkgFile = '/packages/pkgA/libA.dart'; | 392 String pkgFile = '/packages/pkgA/libA.dart'; |
| 393 resourceProvider.newFile( | 393 resourceProvider.newFile(pkgFile, ''' |
| 394 pkgFile, | |
| 395 ''' | |
| 396 library lib_a; | 394 library lib_a; |
| 397 class A {} | 395 class A {} |
| 398 '''); | 396 '''); |
| 399 resourceProvider.newFile( | 397 resourceProvider.newFile( |
| 400 '/project/.packages', 'pkgA:file:///packages/pkgA'); | 398 '/project/.packages', 'pkgA:file:///packages/pkgA'); |
| 401 addTestFile(''' | 399 addTestFile(''' |
| 402 import 'package:pkgA/libA.dart'; | 400 import 'package:pkgA/libA.dart'; |
| 403 main(A a) { | 401 main(A a) { |
| 404 } | 402 } |
| 405 '''); | 403 '''); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 expect(filesHighlights[testFile], isNull); | 671 expect(filesHighlights[testFile], isNull); |
| 674 // subscribe | 672 // subscribe |
| 675 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, file); | 673 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, file); |
| 676 await server.onAnalysisComplete; | 674 await server.onAnalysisComplete; |
| 677 // there are results | 675 // there are results |
| 678 expect(filesHighlights[file], isNull); | 676 expect(filesHighlights[file], isNull); |
| 679 } | 677 } |
| 680 | 678 |
| 681 test_afterAnalysis_packageFile_external() async { | 679 test_afterAnalysis_packageFile_external() async { |
| 682 String pkgFile = '/packages/pkgA/lib/libA.dart'; | 680 String pkgFile = '/packages/pkgA/lib/libA.dart'; |
| 683 resourceProvider.newFile( | 681 resourceProvider.newFile(pkgFile, ''' |
| 684 pkgFile, | |
| 685 ''' | |
| 686 library lib_a; | 682 library lib_a; |
| 687 class A {} | 683 class A {} |
| 688 '''); | 684 '''); |
| 689 resourceProvider.newFile( | 685 resourceProvider.newFile( |
| 690 '/project/.packages', 'pkgA:file:///packages/pkgA/lib'); | 686 '/project/.packages', 'pkgA:file:///packages/pkgA/lib'); |
| 691 // | 687 // |
| 692 addTestFile(''' | 688 addTestFile(''' |
| 693 import 'package:pkgA/libA.dart'; | 689 import 'package:pkgA/libA.dart'; |
| 694 main() { | 690 main() { |
| 695 new A(); | 691 new A(); |
| 696 } | 692 } |
| 697 '''); | 693 '''); |
| 698 createProject(); | 694 createProject(); |
| 699 // wait for analysis, no results initially | 695 // wait for analysis, no results initially |
| 700 await waitForTasksFinished(); | 696 await waitForTasksFinished(); |
| 701 expect(filesHighlights[pkgFile], isNull); | 697 expect(filesHighlights[pkgFile], isNull); |
| 702 // subscribe | 698 // subscribe |
| 703 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, pkgFile); | 699 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, pkgFile); |
| 704 await _resultsAvailable.future; | 700 await _resultsAvailable.future; |
| 705 // there are results | 701 // there are results |
| 706 expect(filesHighlights[pkgFile], isNotEmpty); | 702 expect(filesHighlights[pkgFile], isNotEmpty); |
| 707 } | 703 } |
| 708 | 704 |
| 709 test_afterAnalysis_packageFile_inRoot() async { | 705 test_afterAnalysis_packageFile_inRoot() async { |
| 710 String pkgA = '/pkgA'; | 706 String pkgA = '/pkgA'; |
| 711 String pkgB = '/pkgA'; | 707 String pkgB = '/pkgA'; |
| 712 String pkgFileA = '$pkgA/lib/libA.dart'; | 708 String pkgFileA = '$pkgA/lib/libA.dart'; |
| 713 String pkgFileB = '$pkgA/lib/libB.dart'; | 709 String pkgFileB = '$pkgA/lib/libB.dart'; |
| 714 resourceProvider.newFile( | 710 resourceProvider.newFile(pkgFileA, ''' |
| 715 pkgFileA, | |
| 716 ''' | |
| 717 library lib_a; | 711 library lib_a; |
| 718 class A {} | 712 class A {} |
| 719 '''); | 713 '''); |
| 720 resourceProvider.newFile( | 714 resourceProvider.newFile(pkgFileB, ''' |
| 721 pkgFileB, | |
| 722 ''' | |
| 723 import 'package:pkgA/libA.dart'; | 715 import 'package:pkgA/libA.dart'; |
| 724 main() { | 716 main() { |
| 725 new A(); | 717 new A(); |
| 726 } | 718 } |
| 727 '''); | 719 '''); |
| 728 packageMapProvider.packageMap = { | 720 packageMapProvider.packageMap = { |
| 729 'pkgA': [ | 721 'pkgA': [ |
| 730 resourceProvider.newFolder('$pkgA/lib'), | 722 resourceProvider.newFolder('$pkgA/lib'), |
| 731 resourceProvider.newFolder('$pkgB/lib') | 723 resourceProvider.newFolder('$pkgB/lib') |
| 732 ] | 724 ] |
| 733 }; | 725 }; |
| 734 // add 'pkgA' and 'pkgB' as projects | 726 // add 'pkgA' and 'pkgB' as projects |
| 735 { | 727 { |
| 736 resourceProvider.newFolder(projectPath); | 728 resourceProvider.newFolder(projectPath); |
| 737 handleSuccessfulRequest( | 729 handleSuccessfulRequest( |
| 738 new AnalysisSetAnalysisRootsParams([pkgA, pkgB], []).toRequest('0')); | 730 new AnalysisSetAnalysisRootsParams([pkgA, pkgB], []).toRequest('0')); |
| 739 } | 731 } |
| 740 // wait for analysis, no results initially | 732 // wait for analysis, no results initially |
| 741 await waitForTasksFinished(); | 733 await waitForTasksFinished(); |
| 742 expect(filesHighlights[pkgFileA], isNull); | 734 expect(filesHighlights[pkgFileA], isNull); |
| 743 // subscribe | 735 // subscribe |
| 744 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, pkgFileA); | 736 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, pkgFileA); |
| 745 await _resultsAvailable.future; | 737 await _resultsAvailable.future; |
| 746 // there are results | 738 // there are results |
| 747 expect(filesHighlights[pkgFileA], isNotEmpty); | 739 expect(filesHighlights[pkgFileA], isNotEmpty); |
| 748 } | 740 } |
| 749 | 741 |
| 750 test_afterAnalysis_packageFile_notUsed() async { | 742 test_afterAnalysis_packageFile_notUsed() async { |
| 751 String pkgFile = '/packages/pkgA/lib/libA.dart'; | 743 String pkgFile = '/packages/pkgA/lib/libA.dart'; |
| 752 resourceProvider.newFile( | 744 resourceProvider.newFile(pkgFile, ''' |
| 753 pkgFile, | |
| 754 ''' | |
| 755 library lib_a; | 745 library lib_a; |
| 756 class A {} | 746 class A {} |
| 757 '''); | 747 '''); |
| 758 resourceProvider.newFile('/project/.packages', 'pkgA:/packages/pkgA/lib'); | 748 resourceProvider.newFile('/project/.packages', 'pkgA:/packages/pkgA/lib'); |
| 759 // | 749 // |
| 760 addTestFile('// no "pkgA" reference'); | 750 addTestFile('// no "pkgA" reference'); |
| 761 createProject(); | 751 createProject(); |
| 762 // wait for analysis, no results initially | 752 // wait for analysis, no results initially |
| 763 await waitForTasksFinished(); | 753 await waitForTasksFinished(); |
| 764 expect(filesHighlights[pkgFile], isNull); | 754 expect(filesHighlights[pkgFile], isNull); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 plugin.AnalysisSetSubscriptionsParams params = | 795 plugin.AnalysisSetSubscriptionsParams params = |
| 806 pluginManager.analysisSetSubscriptionsParams; | 796 pluginManager.analysisSetSubscriptionsParams; |
| 807 expect(params, isNotNull); | 797 expect(params, isNotNull); |
| 808 Map<plugin.AnalysisService, List<String>> subscriptions = | 798 Map<plugin.AnalysisService, List<String>> subscriptions = |
| 809 params.subscriptions; | 799 params.subscriptions; |
| 810 expect(subscriptions, hasLength(1)); | 800 expect(subscriptions, hasLength(1)); |
| 811 List<String> files = subscriptions[plugin.AnalysisService.HIGHLIGHTS]; | 801 List<String> files = subscriptions[plugin.AnalysisService.HIGHLIGHTS]; |
| 812 expect(files, [testFile]); | 802 expect(files, [testFile]); |
| 813 } | 803 } |
| 814 } | 804 } |
| OLD | NEW |