| 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.integration.analysis.highlights2; | 5 library test.integration.analysis.highlights2; |
| 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:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 | 12 |
| 13 import '../../utils.dart'; | 13 import '../../utils.dart'; |
| 14 import '../integration_tests.dart'; | 14 import '../integration_tests.dart'; |
| 15 | 15 |
| 16 main() { | 16 main() { |
| 17 initializeTestEnvironment(); | 17 initializeTestEnvironment(); |
| 18 defineReflectiveTests(AnalysisHighlightsTest); | 18 defineReflectiveTests(AnalysisHighlightsTest); |
| 19 } | 19 } |
| 20 | 20 |
| 21 @reflectiveTest | 21 @reflectiveTest |
| 22 class AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest { | 22 class AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest { |
| 23 Future startServer({int servicesPort, bool checked: true}) { | 23 Future startServer( |
| 24 {bool checked: true, int diagnosticPort, int servicesPort}) { |
| 24 return server.start( | 25 return server.start( |
| 26 checked: checked, |
| 27 diagnosticPort: diagnosticPort, |
| 25 servicesPort: servicesPort, | 28 servicesPort: servicesPort, |
| 26 checked: checked, | |
| 27 useAnalysisHighlight2: true); | 29 useAnalysisHighlight2: true); |
| 28 } | 30 } |
| 29 | 31 |
| 30 test_highlights() { | 32 test_highlights() { |
| 31 String pathname = sourcePath('test.dart'); | 33 String pathname = sourcePath('test.dart'); |
| 32 String text = r''' | 34 String text = r''' |
| 33 import 'dart:async' as async; | 35 import 'dart:async' as async; |
| 34 | 36 |
| 35 /** | 37 /** |
| 36 * Doc comment | 38 * Doc comment |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 104 } |
| 103 }); | 105 }); |
| 104 return analysisFinished.then((_) { | 106 return analysisFinished.then((_) { |
| 105 // There should be 1 error due to the fact that unresolvedIdentifier is | 107 // There should be 1 error due to the fact that unresolvedIdentifier is |
| 106 // unresolved. | 108 // unresolved. |
| 107 expect(currentAnalysisErrors[pathname], hasLength(1)); | 109 expect(currentAnalysisErrors[pathname], hasLength(1)); |
| 108 void check(HighlightRegionType type, List<String> expected) { | 110 void check(HighlightRegionType type, List<String> expected) { |
| 109 expect(highlights[type], equals(expected.toSet())); | 111 expect(highlights[type], equals(expected.toSet())); |
| 110 highlights.remove(type); | 112 highlights.remove(type); |
| 111 } | 113 } |
| 114 |
| 112 check(HighlightRegionType.ANNOTATION, ['@override']); | 115 check(HighlightRegionType.ANNOTATION, ['@override']); |
| 113 check(HighlightRegionType.BUILT_IN, | 116 check(HighlightRegionType.BUILT_IN, |
| 114 ['as', 'get', 'import', 'set', 'static', 'typedef']); | 117 ['as', 'get', 'import', 'set', 'static', 'typedef']); |
| 115 check(HighlightRegionType.CLASS, | 118 check(HighlightRegionType.CLASS, |
| 116 ['Class', 'Class2', 'Future', 'Map', 'int']); | 119 ['Class', 'Class2', 'Future', 'Map', 'int']); |
| 117 check(HighlightRegionType.COMMENT_BLOCK, ['/* Block comment */']); | 120 check(HighlightRegionType.COMMENT_BLOCK, ['/* Block comment */']); |
| 118 check(HighlightRegionType.COMMENT_DOCUMENTATION, | 121 check(HighlightRegionType.COMMENT_DOCUMENTATION, |
| 119 ['/**\n * Doc comment\n */']); | 122 ['/**\n * Doc comment\n */']); |
| 120 check( | 123 check( |
| 121 HighlightRegionType.COMMENT_END_OF_LINE, ['// End of line comment']); | 124 HighlightRegionType.COMMENT_END_OF_LINE, ['// End of line comment']); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 150 check(HighlightRegionType.INSTANCE_SETTER_DECLARATION, ['setter']); | 153 check(HighlightRegionType.INSTANCE_SETTER_DECLARATION, ['setter']); |
| 151 check(HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE, ['override']); | 154 check(HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE, ['override']); |
| 152 check(HighlightRegionType.TOP_LEVEL_VARIABLE_DECLARATION, | 155 check(HighlightRegionType.TOP_LEVEL_VARIABLE_DECLARATION, |
| 153 ['topLevelVariable']); | 156 ['topLevelVariable']); |
| 154 check(HighlightRegionType.TYPE_NAME_DYNAMIC, ['dynamic']); | 157 check(HighlightRegionType.TYPE_NAME_DYNAMIC, ['dynamic']); |
| 155 check(HighlightRegionType.TYPE_PARAMETER, ['TypeParameter']); | 158 check(HighlightRegionType.TYPE_PARAMETER, ['TypeParameter']); |
| 156 expect(highlights, isEmpty); | 159 expect(highlights, isEmpty); |
| 157 }); | 160 }); |
| 158 } | 161 } |
| 159 } | 162 } |
| OLD | NEW |