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.navigation; | 5 library test.integration.analysis.navigation; |
6 | 6 |
7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 ElementKind expectedKind) { | 93 ElementKind expectedKind) { |
94 int sourceIndex = text1.indexOf(source); | 94 int sourceIndex = text1.indexOf(source); |
95 NavigationTarget element = findTargetElement(sourceIndex); | 95 NavigationTarget element = findTargetElement(sourceIndex); |
96 expect(targetFiles[element.fileIndex], matches(expectedTargetRegexp)); | 96 expect(targetFiles[element.fileIndex], matches(expectedTargetRegexp)); |
97 expect(element.kind, equals(expectedKind)); | 97 expect(element.kind, equals(expectedKind)); |
98 } | 98 } |
99 // TODO(paulberry): will the element type 'CLASS_TYPE_ALIAS' ever appear | 99 // TODO(paulberry): will the element type 'CLASS_TYPE_ALIAS' ever appear |
100 // as a navigation target? | 100 // as a navigation target? |
101 checkLocal('Class<int>', 'Class<TypeParameter>', ElementKind.CLASS); | 101 checkLocal('Class<int>', 'Class<TypeParameter>', ElementKind.CLASS); |
102 checkRemote( | 102 checkRemote( |
103 "part 'test2.dart';", r'test2.dart$', ElementKind.COMPILATION_UNIT); | 103 "'test2.dart';", r'test2.dart$', ElementKind.COMPILATION_UNIT); |
104 checkLocal('Class<int>.constructor', | 104 checkLocal('Class<int>.constructor', |
105 'constructor(); /* constructor declaration */', | 105 'constructor(); /* constructor declaration */', |
106 ElementKind.CONSTRUCTOR); | 106 ElementKind.CONSTRUCTOR); |
107 checkLocal('constructor(); // usage', | 107 checkLocal('constructor(); // usage', |
108 'constructor(); /* constructor declaration */', | 108 'constructor(); /* constructor declaration */', |
109 ElementKind.CONSTRUCTOR); | 109 ElementKind.CONSTRUCTOR); |
110 checkLocal('field;', 'field;', ElementKind.FIELD); | 110 checkLocal('field;', 'field;', ElementKind.FIELD); |
111 checkLocal('function(() => localVariable.field)', | 111 checkLocal('function(() => localVariable.field)', |
112 'function(FunctionTypeAlias parameter)', ElementKind.FUNCTION); | 112 'function(FunctionTypeAlias parameter)', ElementKind.FUNCTION); |
113 checkLocal('FunctionTypeAlias parameter', 'FunctionTypeAlias();', | 113 checkLocal('FunctionTypeAlias parameter', 'FunctionTypeAlias();', |
114 ElementKind.FUNCTION_TYPE_ALIAS); | 114 ElementKind.FUNCTION_TYPE_ALIAS); |
115 checkLocal('field)', 'field;', ElementKind.GETTER); | 115 checkLocal('field)', 'field;', ElementKind.GETTER); |
116 checkRemote("import 'dart:async'", r'async\.dart$', ElementKind.LIBRARY); | 116 checkRemote("'dart:async'", r'async\.dart$', ElementKind.LIBRARY); |
117 checkLocal( | 117 checkLocal( |
118 'localVariable.field', 'localVariable =', ElementKind.LOCAL_VARIABLE); | 118 'localVariable.field', 'localVariable =', ElementKind.LOCAL_VARIABLE); |
119 checkLocal('method();', 'method() {', ElementKind.METHOD); | 119 checkLocal('method();', 'method() {', ElementKind.METHOD); |
120 checkLocal('parameter());', 'parameter) {', ElementKind.PARAMETER); | 120 checkLocal('parameter());', 'parameter) {', ElementKind.PARAMETER); |
121 checkLocal('field = 1', 'field;', ElementKind.SETTER); | 121 checkLocal('field = 1', 'field;', ElementKind.SETTER); |
122 checkLocal('topLevelVariable;', 'topLevelVariable;', | 122 checkLocal('topLevelVariable;', 'topLevelVariable;', |
123 ElementKind.TOP_LEVEL_VARIABLE); | 123 ElementKind.TOP_LEVEL_VARIABLE); |
124 checkLocal( | 124 checkLocal( |
125 'TypeParameter field;', 'TypeParameter>', ElementKind.TYPE_PARAMETER); | 125 'TypeParameter field;', 'TypeParameter>', ElementKind.TYPE_PARAMETER); |
126 }); | 126 }); |
127 } | 127 } |
128 } | 128 } |
OLD | NEW |