| 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.analysis.reanalyze; | 5 library test.analysis.reanalyze; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/constants.dart'; | 7 import 'package:analysis_server/src/constants.dart'; |
| 8 import 'package:analysis_server/src/protocol.dart'; | 8 import 'package:analysis_server/src/protocol.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 import '../analysis_abstract.dart'; | 12 import '../analysis_abstract.dart'; |
| 13 import '../reflective_tests.dart'; | 13 import '../reflective_tests.dart'; |
| 14 | 14 |
| 15 | |
| 16 main() { | 15 main() { |
| 17 groupSep = ' | '; | 16 groupSep = ' | '; |
| 18 runReflectiveTests(ReanalyzeTest); | 17 runReflectiveTests(ReanalyzeTest); |
| 19 } | 18 } |
| 20 | 19 |
| 21 | |
| 22 @reflectiveTest | 20 @reflectiveTest |
| 23 class ReanalyzeTest extends AbstractAnalysisTest { | 21 class ReanalyzeTest extends AbstractAnalysisTest { |
| 24 Map<String, List<AnalysisError>> filesErrors = {}; | 22 Map<String, List<AnalysisError>> filesErrors = {}; |
| 25 | 23 |
| 26 @override | 24 @override |
| 27 void processNotification(Notification notification) { | 25 void processNotification(Notification notification) { |
| 28 if (notification.event == ANALYSIS_ERRORS) { | 26 if (notification.event == ANALYSIS_ERRORS) { |
| 29 var decoded = new AnalysisErrorsParams.fromNotification(notification); | 27 var decoded = new AnalysisErrorsParams.fromNotification(notification); |
| 30 filesErrors[decoded.file] = decoded.errors; | 28 filesErrors[decoded.file] = decoded.errors; |
| 31 } | 29 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 44 AnalysisContext newContext = contexts[0]; | 42 AnalysisContext newContext = contexts[0]; |
| 45 expect(newContext, isNot(same(oldContext))); | 43 expect(newContext, isNot(same(oldContext))); |
| 46 } | 44 } |
| 47 | 45 |
| 48 test_reanalyze_with_overlay() { | 46 test_reanalyze_with_overlay() { |
| 49 createProject(); | 47 createProject(); |
| 50 resourceProvider.newFolder(testFolder); | 48 resourceProvider.newFolder(testFolder); |
| 51 resourceProvider.newFile(testFile, 'main() {}'); | 49 resourceProvider.newFile(testFile, 'main() {}'); |
| 52 return waitForTasksFinished().then((_) { | 50 return waitForTasksFinished().then((_) { |
| 53 // Update the content with an overlay that contains a syntax error. | 51 // Update the content with an overlay that contains a syntax error. |
| 54 server.updateContent('1', { | 52 server.updateContent('1', {testFile: new AddContentOverlay('main() {')}); |
| 55 testFile: new AddContentOverlay('main() {') | |
| 56 }); | |
| 57 return waitForTasksFinished(); | 53 return waitForTasksFinished(); |
| 58 }).then((_) { | 54 }).then((_) { |
| 59 // Verify that the syntax error was detected. | 55 // Verify that the syntax error was detected. |
| 60 List<AnalysisError> errors = filesErrors[testFile]; | 56 List<AnalysisError> errors = filesErrors[testFile]; |
| 61 expect(errors, hasLength(1)); | 57 expect(errors, hasLength(1)); |
| 62 // Remove testFile from filesErrors so that we'll notice when the file is | 58 // Remove testFile from filesErrors so that we'll notice when the file is |
| 63 // re-analyzed. | 59 // re-analyzed. |
| 64 filesErrors.remove(testFile); | 60 filesErrors.remove(testFile); |
| 65 // Reanalyze. | 61 // Reanalyze. |
| 66 server.reanalyze(); | 62 server.reanalyze(); |
| 67 return waitForTasksFinished(); | 63 return waitForTasksFinished(); |
| 68 }).then((_) { | 64 }).then((_) { |
| 69 // The file should have been reanalyzed. | 65 // The file should have been reanalyzed. |
| 70 expect(filesErrors, contains(testFile)); | 66 expect(filesErrors, contains(testFile)); |
| 71 // Verify that the syntax error is present (this indicates that the | 67 // Verify that the syntax error is present (this indicates that the |
| 72 // content introduced by the call to updateContent is still in effect). | 68 // content introduced by the call to updateContent is still in effect). |
| 73 List<AnalysisError> errors = filesErrors[testFile]; | 69 List<AnalysisError> errors = filesErrors[testFile]; |
| 74 expect(errors, hasLength(1)); | 70 expect(errors, hasLength(1)); |
| 75 }); | 71 }); |
| 76 } | 72 } |
| 77 } | 73 } |
| OLD | NEW |