| 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.highlights; | 5 library test.integration.analysis.highlights; |
| 6 | 6 |
| 7 import '../../reflective_tests.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 import '../../reflective_tests.dart'; |
| 10 import '../integration_tests.dart'; | 11 import '../integration_tests.dart'; |
| 11 | 12 |
| 12 @ReflectiveTestCase() | 13 @ReflectiveTestCase() |
| 13 class AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest { | 14 class AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest { |
| 14 test_highlights() { | 15 test_highlights() { |
| 15 String pathname = sourcePath('test.dart'); | 16 String pathname = sourcePath('test.dart'); |
| 16 String text = | 17 String text = |
| 17 r''' | 18 r''' |
| 18 import 'dart:async' as async; | 19 import 'dart:async' as async; |
| 19 | 20 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 function(dynamicType) { | 60 function(dynamicType) { |
| 60 print('string'); | 61 print('string'); |
| 61 unresolvedIdentifier = 42; | 62 unresolvedIdentifier = 42; |
| 62 return async.Future.wait([]); | 63 return async.Future.wait([]); |
| 63 } | 64 } |
| 64 | 65 |
| 65 int topLevelVariable; | 66 int topLevelVariable; |
| 66 '''; | 67 '''; |
| 67 writeFile(pathname, text); | 68 writeFile(pathname, text); |
| 68 standardAnalysisSetup(); | 69 standardAnalysisSetup(); |
| 69 sendAnalysisSetSubscriptions({'HIGHLIGHTS': [pathname]}); | 70 sendAnalysisSetSubscriptions({AnalysisService.HIGHLIGHTS: [pathname]}); |
| 70 // Map from highlight type to highlighted text | 71 // Map from highlight type to highlighted text |
| 71 Map<String, Set<String>> highlights; | 72 Map<String, Set<String>> highlights; |
| 72 onAnalysisHighlights.listen((params) { | 73 onAnalysisHighlights.listen((params) { |
| 73 expect(params['file'], equals(pathname)); | 74 expect(params['file'], equals(pathname)); |
| 74 highlights = <String, Set<String>>{}; | 75 highlights = <String, Set<String>>{}; |
| 75 for (var region in params['regions']) { | 76 for (var region in params['regions']) { |
| 76 int startIndex = region['offset']; | 77 int startIndex = region['offset']; |
| 77 int endIndex = startIndex + region['length']; | 78 int endIndex = startIndex + region['length']; |
| 78 String highlightedText = text.substring(startIndex, endIndex); | 79 String highlightedText = text.substring(startIndex, endIndex); |
| 79 String type = region['type']; | 80 String type = region['type']; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 check('TYPE_NAME_DYNAMIC', ['dynamic']); | 128 check('TYPE_NAME_DYNAMIC', ['dynamic']); |
| 128 check('TYPE_PARAMETER', ['TypeParameter']); | 129 check('TYPE_PARAMETER', ['TypeParameter']); |
| 129 expect(highlights, isEmpty); | 130 expect(highlights, isEmpty); |
| 130 }); | 131 }); |
| 131 } | 132 } |
| 132 } | 133 } |
| 133 | 134 |
| 134 main() { | 135 main() { |
| 135 runReflectiveTests(AnalysisHighlightsTest); | 136 runReflectiveTests(AnalysisHighlightsTest); |
| 136 } | 137 } |
| OLD | NEW |