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.notification.outline; | 5 library test.analysis.notification.outline; |
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:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
(...skipping 29 matching lines...) Expand all Loading... |
40 } | 40 } |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 @override | 44 @override |
45 void setUp() { | 45 void setUp() { |
46 super.setUp(); | 46 super.setUp(); |
47 createProject(); | 47 createProject(); |
48 } | 48 } |
49 | 49 |
50 test_afterAnalysis() { | 50 test_afterAnalysis() async { |
51 addTestFile(''' | 51 addTestFile(''' |
52 class AAA { | 52 class AAA { |
53 } | 53 } |
54 class BBB { | 54 class BBB { |
55 } | 55 } |
56 '''); | 56 '''); |
57 return waitForTasksFinished().then((_) { | 57 await waitForTasksFinished(); |
58 expect(outline, isNull); | 58 expect(outline, isNull); |
59 return prepareOutline().then((_) { | 59 await prepareOutline(); |
60 Outline unitOutline = outline; | 60 Outline unitOutline = outline; |
61 List<Outline> outlines = unitOutline.children; | 61 List<Outline> outlines = unitOutline.children; |
62 expect(outlines, hasLength(2)); | 62 expect(outlines, hasLength(2)); |
63 }); | |
64 }); | |
65 } | 63 } |
66 | 64 |
67 test_class() { | 65 test_class() async { |
68 addTestFile(''' | 66 addTestFile(''' |
69 class A<K, V> { | 67 class A<K, V> { |
70 int fa, fb; | 68 int fa, fb; |
71 String fc; | 69 String fc; |
72 A(int i, String s); | 70 A(int i, String s); |
73 A.name(num p); | 71 A.name(num p); |
74 A._privateName(num p); | 72 A._privateName(num p); |
75 static String ma(int pa) => null; | 73 static String ma(int pa) => null; |
76 _mb(int pb); | 74 _mb(int pb); |
77 String get propA => null; | 75 String get propA => null; |
78 set propB(int v) {} | 76 set propB(int v) {} |
79 } | 77 } |
80 class B { | 78 class B { |
81 B(int p); | 79 B(int p); |
82 }"); | 80 }"); |
83 '''); | 81 '''); |
84 return prepareOutline().then((_) { | 82 await prepareOutline(); |
85 Outline unitOutline = outline; | 83 Outline unitOutline = outline; |
86 List<Outline> topOutlines = unitOutline.children; | 84 List<Outline> topOutlines = unitOutline.children; |
87 expect(topOutlines, hasLength(2)); | 85 expect(topOutlines, hasLength(2)); |
88 // A | 86 // A |
89 { | 87 { |
90 Outline outline_A = topOutlines[0]; | 88 Outline outline_A = topOutlines[0]; |
91 Element element_A = outline_A.element; | 89 Element element_A = outline_A.element; |
92 expect(element_A.kind, ElementKind.CLASS); | 90 expect(element_A.kind, ElementKind.CLASS); |
93 expect(element_A.name, "A"); | 91 expect(element_A.name, "A"); |
94 expect(element_A.typeParameters, "<K, V>"); | 92 expect(element_A.typeParameters, "<K, V>"); |
95 { | 93 { |
96 Location location = element_A.location; | 94 Location location = element_A.location; |
97 expect(location.offset, testCode.indexOf("A<K, V> {")); | 95 expect(location.offset, testCode.indexOf("A<K, V> {")); |
98 expect(location.length, 1); | 96 expect(location.length, 1); |
99 } | 97 } |
100 expect(element_A.parameters, null); | 98 expect(element_A.parameters, null); |
101 expect(element_A.returnType, null); | 99 expect(element_A.returnType, null); |
102 // A children | 100 // A children |
103 List<Outline> outlines_A = outline_A.children; | 101 List<Outline> outlines_A = outline_A.children; |
104 expect(outlines_A, hasLength(10)); | 102 expect(outlines_A, hasLength(10)); |
105 { | 103 { |
106 Outline outline = outlines_A[0]; | 104 Outline outline = outlines_A[0]; |
107 Element element = outline.element; | 105 Element element = outline.element; |
108 expect(element.kind, ElementKind.FIELD); | 106 expect(element.kind, ElementKind.FIELD); |
109 expect(element.name, "fa"); | 107 expect(element.name, "fa"); |
110 expect(element.parameters, isNull); | 108 expect(element.parameters, isNull); |
111 expect(element.returnType, "int"); | 109 expect(element.returnType, "int"); |
112 } | 110 } |
113 { | 111 { |
114 Outline outline = outlines_A[1]; | 112 Outline outline = outlines_A[1]; |
115 Element element = outline.element; | 113 Element element = outline.element; |
116 expect(element.kind, ElementKind.FIELD); | 114 expect(element.kind, ElementKind.FIELD); |
117 expect(element.name, "fb"); | 115 expect(element.name, "fb"); |
118 expect(element.parameters, isNull); | 116 expect(element.parameters, isNull); |
119 expect(element.returnType, "int"); | 117 expect(element.returnType, "int"); |
120 } | 118 } |
121 { | 119 { |
122 Outline outline = outlines_A[2]; | 120 Outline outline = outlines_A[2]; |
123 Element element = outline.element; | 121 Element element = outline.element; |
124 expect(element.kind, ElementKind.FIELD); | 122 expect(element.kind, ElementKind.FIELD); |
125 expect(element.name, "fc"); | 123 expect(element.name, "fc"); |
126 expect(element.parameters, isNull); | 124 expect(element.parameters, isNull); |
127 expect(element.returnType, "String"); | 125 expect(element.returnType, "String"); |
128 } | 126 } |
129 { | 127 { |
130 Outline outline = outlines_A[3]; | 128 Outline outline = outlines_A[3]; |
131 Element element = outline.element; | 129 Element element = outline.element; |
132 expect(element.kind, ElementKind.CONSTRUCTOR); | 130 expect(element.kind, ElementKind.CONSTRUCTOR); |
133 expect(element.name, "A"); | 131 expect(element.name, "A"); |
134 { | 132 { |
135 Location location = element.location; | 133 Location location = element.location; |
136 expect(location.offset, testCode.indexOf("A(int i, String s);")); | 134 expect(location.offset, testCode.indexOf("A(int i, String s);")); |
137 expect(location.length, "A".length); | 135 expect(location.length, "A".length); |
138 } | 136 } |
139 expect(element.parameters, "(int i, String s)"); | 137 expect(element.parameters, "(int i, String s)"); |
140 expect(element.returnType, isNull); | 138 expect(element.returnType, isNull); |
141 expect(element.isAbstract, isFalse); | 139 expect(element.isAbstract, isFalse); |
142 expect(element.isStatic, isFalse); | 140 expect(element.isStatic, isFalse); |
143 } | 141 } |
144 { | 142 { |
145 Outline outline = outlines_A[4]; | 143 Outline outline = outlines_A[4]; |
146 Element element = outline.element; | 144 Element element = outline.element; |
147 expect(element.kind, ElementKind.CONSTRUCTOR); | 145 expect(element.kind, ElementKind.CONSTRUCTOR); |
148 expect(element.name, "A.name"); | 146 expect(element.name, "A.name"); |
149 { | 147 { |
150 Location location = element.location; | 148 Location location = element.location; |
151 expect(location.offset, testCode.indexOf("name(num p);")); | 149 expect(location.offset, testCode.indexOf("name(num p);")); |
152 expect(location.length, "name".length); | 150 expect(location.length, "name".length); |
153 } | 151 } |
154 expect(element.parameters, "(num p)"); | 152 expect(element.parameters, "(num p)"); |
155 expect(element.returnType, isNull); | 153 expect(element.returnType, isNull); |
156 expect(element.isAbstract, isFalse); | 154 expect(element.isAbstract, isFalse); |
157 expect(element.isStatic, isFalse); | 155 expect(element.isStatic, isFalse); |
158 } | 156 } |
159 { | 157 { |
160 Outline outline = outlines_A[5]; | 158 Outline outline = outlines_A[5]; |
161 Element element = outline.element; | 159 Element element = outline.element; |
162 expect(element.kind, ElementKind.CONSTRUCTOR); | 160 expect(element.kind, ElementKind.CONSTRUCTOR); |
163 expect(element.name, "A._privateName"); | 161 expect(element.name, "A._privateName"); |
164 { | 162 { |
165 Location location = element.location; | 163 Location location = element.location; |
166 expect(location.offset, testCode.indexOf("_privateName(num p);")); | 164 expect(location.offset, testCode.indexOf("_privateName(num p);")); |
167 expect(location.length, "_privateName".length); | 165 expect(location.length, "_privateName".length); |
168 } | 166 } |
169 expect(element.parameters, "(num p)"); | 167 expect(element.parameters, "(num p)"); |
170 expect(element.returnType, isNull); | 168 expect(element.returnType, isNull); |
171 expect(element.isAbstract, isFalse); | 169 expect(element.isAbstract, isFalse); |
172 expect(element.isStatic, isFalse); | 170 expect(element.isStatic, isFalse); |
173 } | 171 } |
174 { | 172 { |
175 Outline outline = outlines_A[6]; | 173 Outline outline = outlines_A[6]; |
176 Element element = outline.element; | 174 Element element = outline.element; |
177 expect(element.kind, ElementKind.METHOD); | 175 expect(element.kind, ElementKind.METHOD); |
178 expect(element.name, "ma"); | 176 expect(element.name, "ma"); |
179 { | 177 { |
180 Location location = element.location; | 178 Location location = element.location; |
181 expect(location.offset, testCode.indexOf("ma(int pa) => null;")); | 179 expect(location.offset, testCode.indexOf("ma(int pa) => null;")); |
182 expect(location.length, "ma".length); | 180 expect(location.length, "ma".length); |
183 } | 181 } |
184 expect(element.parameters, "(int pa)"); | 182 expect(element.parameters, "(int pa)"); |
185 expect(element.returnType, "String"); | 183 expect(element.returnType, "String"); |
186 expect(element.isAbstract, isFalse); | 184 expect(element.isAbstract, isFalse); |
187 expect(element.isStatic, isTrue); | 185 expect(element.isStatic, isTrue); |
188 } | 186 } |
189 { | 187 { |
190 Outline outline = outlines_A[7]; | 188 Outline outline = outlines_A[7]; |
191 Element element = outline.element; | 189 Element element = outline.element; |
192 expect(element.kind, ElementKind.METHOD); | 190 expect(element.kind, ElementKind.METHOD); |
193 expect(element.name, "_mb"); | 191 expect(element.name, "_mb"); |
194 { | 192 { |
195 Location location = element.location; | 193 Location location = element.location; |
196 expect(location.offset, testCode.indexOf("_mb(int pb);")); | 194 expect(location.offset, testCode.indexOf("_mb(int pb);")); |
197 expect(location.length, "_mb".length); | 195 expect(location.length, "_mb".length); |
198 } | 196 } |
199 expect(element.parameters, "(int pb)"); | 197 expect(element.parameters, "(int pb)"); |
200 expect(element.returnType, ""); | 198 expect(element.returnType, ""); |
201 expect(element.isAbstract, isTrue); | 199 expect(element.isAbstract, isTrue); |
202 expect(element.isStatic, isFalse); | 200 expect(element.isStatic, isFalse); |
203 } | 201 } |
204 { | 202 { |
205 Outline outline = outlines_A[8]; | 203 Outline outline = outlines_A[8]; |
206 Element element = outline.element; | 204 Element element = outline.element; |
207 expect(element.kind, ElementKind.GETTER); | 205 expect(element.kind, ElementKind.GETTER); |
208 expect(element.name, "propA"); | 206 expect(element.name, "propA"); |
209 { | 207 { |
210 Location location = element.location; | 208 Location location = element.location; |
211 expect(location.offset, testCode.indexOf("propA => null;")); | 209 expect(location.offset, testCode.indexOf("propA => null;")); |
212 expect(location.length, "propA".length); | 210 expect(location.length, "propA".length); |
213 } | 211 } |
214 expect(element.parameters, isNull); | 212 expect(element.parameters, isNull); |
215 expect(element.returnType, "String"); | 213 expect(element.returnType, "String"); |
216 } | 214 } |
217 { | 215 { |
218 Outline outline = outlines_A[9]; | 216 Outline outline = outlines_A[9]; |
219 Element element = outline.element; | 217 Element element = outline.element; |
220 expect(element.kind, ElementKind.SETTER); | 218 expect(element.kind, ElementKind.SETTER); |
221 expect(element.name, "propB"); | 219 expect(element.name, "propB"); |
222 { | 220 { |
223 Location location = element.location; | 221 Location location = element.location; |
224 expect(location.offset, testCode.indexOf("propB(int v) {}")); | 222 expect(location.offset, testCode.indexOf("propB(int v) {}")); |
225 expect(location.length, "propB".length); | 223 expect(location.length, "propB".length); |
226 } | 224 } |
227 expect(element.parameters, "(int v)"); | 225 expect(element.parameters, "(int v)"); |
228 expect(element.returnType, ""); | 226 expect(element.returnType, ""); |
229 } | 227 } |
230 } | 228 } |
231 // B | 229 // B |
232 { | 230 { |
233 Outline outline_B = topOutlines[1]; | 231 Outline outline_B = topOutlines[1]; |
234 Element element_B = outline_B.element; | 232 Element element_B = outline_B.element; |
235 expect(element_B.kind, ElementKind.CLASS); | 233 expect(element_B.kind, ElementKind.CLASS); |
236 expect(element_B.name, "B"); | 234 expect(element_B.name, "B"); |
237 expect(element_B.typeParameters, isNull); | 235 expect(element_B.typeParameters, isNull); |
238 { | 236 { |
239 Location location = element_B.location; | 237 Location location = element_B.location; |
240 expect(location.offset, testCode.indexOf("B {")); | 238 expect(location.offset, testCode.indexOf("B {")); |
241 expect(location.length, 1); | 239 expect(location.length, 1); |
242 } | 240 } |
243 expect(element_B.parameters, null); | 241 expect(element_B.parameters, null); |
244 expect(element_B.returnType, null); | 242 expect(element_B.returnType, null); |
245 // B children | 243 // B children |
246 List<Outline> outlines_B = outline_B.children; | 244 List<Outline> outlines_B = outline_B.children; |
247 expect(outlines_B, hasLength(1)); | 245 expect(outlines_B, hasLength(1)); |
248 { | 246 { |
249 Outline outline = outlines_B[0]; | 247 Outline outline = outlines_B[0]; |
250 Element element = outline.element; | 248 Element element = outline.element; |
251 expect(element.kind, ElementKind.CONSTRUCTOR); | 249 expect(element.kind, ElementKind.CONSTRUCTOR); |
252 expect(element.name, "B"); | 250 expect(element.name, "B"); |
253 { | 251 { |
254 Location location = element.location; | 252 Location location = element.location; |
255 expect(location.offset, testCode.indexOf("B(int p);")); | 253 expect(location.offset, testCode.indexOf("B(int p);")); |
256 expect(location.length, "B".length); | 254 expect(location.length, "B".length); |
257 } | 255 } |
258 expect(element.parameters, "(int p)"); | 256 expect(element.parameters, "(int p)"); |
259 expect(element.returnType, isNull); | 257 expect(element.returnType, isNull); |
260 } | 258 } |
261 } | 259 } |
262 }); | |
263 } | 260 } |
264 | 261 |
265 test_enum() { | 262 test_enum() async { |
266 addTestFile(''' | 263 addTestFile(''' |
267 enum MyEnum { | 264 enum MyEnum { |
268 A, B, C | 265 A, B, C |
269 } | 266 } |
270 '''); | 267 '''); |
271 return prepareOutline().then((_) { | 268 await prepareOutline(); |
272 Outline unitOutline = outline; | 269 Outline unitOutline = outline; |
273 List<Outline> topOutlines = unitOutline.children; | 270 List<Outline> topOutlines = unitOutline.children; |
274 expect(topOutlines, hasLength(1)); | 271 expect(topOutlines, hasLength(1)); |
275 // MyEnum | 272 // MyEnum |
276 { | 273 { |
277 Outline outline_MyEnum = topOutlines[0]; | 274 Outline outline_MyEnum = topOutlines[0]; |
278 Element element_MyEnum = outline_MyEnum.element; | 275 Element element_MyEnum = outline_MyEnum.element; |
279 expect(element_MyEnum.kind, ElementKind.ENUM); | 276 expect(element_MyEnum.kind, ElementKind.ENUM); |
280 expect(element_MyEnum.name, "MyEnum"); | 277 expect(element_MyEnum.name, "MyEnum"); |
281 { | 278 { |
282 Location location = element_MyEnum.location; | 279 Location location = element_MyEnum.location; |
283 expect(location.offset, testCode.indexOf("MyEnum {")); | 280 expect(location.offset, testCode.indexOf("MyEnum {")); |
284 expect(location.length, 'MyEnum'.length); | 281 expect(location.length, 'MyEnum'.length); |
285 } | 282 } |
286 expect(element_MyEnum.parameters, null); | 283 expect(element_MyEnum.parameters, null); |
287 expect(element_MyEnum.returnType, null); | 284 expect(element_MyEnum.returnType, null); |
288 // MyEnum children | 285 // MyEnum children |
289 List<Outline> outlines_MyEnum = outline_MyEnum.children; | 286 List<Outline> outlines_MyEnum = outline_MyEnum.children; |
290 expect(outlines_MyEnum, hasLength(3)); | 287 expect(outlines_MyEnum, hasLength(3)); |
291 _isEnumConstant(outlines_MyEnum[0], 'A'); | 288 _isEnumConstant(outlines_MyEnum[0], 'A'); |
292 _isEnumConstant(outlines_MyEnum[1], 'B'); | 289 _isEnumConstant(outlines_MyEnum[1], 'B'); |
293 _isEnumConstant(outlines_MyEnum[2], 'C'); | 290 _isEnumConstant(outlines_MyEnum[2], 'C'); |
294 } | 291 } |
295 }); | |
296 } | 292 } |
297 | 293 |
298 /** | 294 /** |
299 * Code like this caused NPE in the past. | 295 * Code like this caused NPE in the past. |
300 * | 296 * |
301 * https://code.google.com/p/dart/issues/detail?id=21373 | 297 * https://code.google.com/p/dart/issues/detail?id=21373 |
302 */ | 298 */ |
303 test_invalidGetterInConstructor() { | 299 test_invalidGetterInConstructor() async { |
304 addTestFile(''' | 300 addTestFile(''' |
305 class A { | 301 class A { |
306 A() { | 302 A() { |
307 get badGetter { | 303 get badGetter { |
308 const int CONST = 0; | 304 const int CONST = 0; |
309 } | 305 } |
310 } | 306 } |
311 } | 307 } |
312 '''); | 308 '''); |
313 return prepareOutline().then((_) { | 309 await prepareOutline(); |
314 expect(outline, isNotNull); | 310 expect(outline, isNotNull); |
315 }); | |
316 } | 311 } |
317 | 312 |
318 test_libraryName_hasLibraryDirective() async { | 313 test_libraryName_hasLibraryDirective() async { |
319 addTestFile(''' | 314 addTestFile(''' |
320 library my.lib; | 315 library my.lib; |
321 '''); | 316 '''); |
322 await prepareOutline(); | 317 await prepareOutline(); |
323 expect(fileKind, FileKind.LIBRARY); | 318 expect(fileKind, FileKind.LIBRARY); |
324 expect(libraryName, 'my.lib'); | 319 expect(libraryName, 'my.lib'); |
325 } | 320 } |
(...skipping 19 matching lines...) Expand all Loading... |
345 | 340 |
346 test_libraryName_noDirectives() async { | 341 test_libraryName_noDirectives() async { |
347 addTestFile(''' | 342 addTestFile(''' |
348 class A {} | 343 class A {} |
349 '''); | 344 '''); |
350 await prepareOutline(); | 345 await prepareOutline(); |
351 expect(fileKind, FileKind.LIBRARY); | 346 expect(fileKind, FileKind.LIBRARY); |
352 expect(libraryName, isNull); | 347 expect(libraryName, isNull); |
353 } | 348 } |
354 | 349 |
355 test_localFunctions() { | 350 test_localFunctions() async { |
356 addTestFile(''' | 351 addTestFile(''' |
357 class A { | 352 class A { |
358 A() { | 353 A() { |
359 int local_A() {} | 354 int local_A() {} |
360 } | 355 } |
361 m() { | 356 m() { |
362 local_m() {} | 357 local_m() {} |
363 } | 358 } |
364 } | 359 } |
365 f() { | 360 f() { |
366 local_f1(int i) {} | 361 local_f1(int i) {} |
367 local_f2(String s) { | 362 local_f2(String s) { |
368 local_f21(int p) {} | 363 local_f21(int p) {} |
369 } | 364 } |
370 } | 365 } |
371 '''); | 366 '''); |
372 return prepareOutline().then((_) { | 367 await prepareOutline(); |
373 Outline unitOutline = outline; | 368 Outline unitOutline = outline; |
374 List<Outline> topOutlines = unitOutline.children; | 369 List<Outline> topOutlines = unitOutline.children; |
375 expect(topOutlines, hasLength(2)); | 370 expect(topOutlines, hasLength(2)); |
376 // A | 371 // A |
377 { | 372 { |
378 Outline outline_A = topOutlines[0]; | 373 Outline outline_A = topOutlines[0]; |
379 Element element_A = outline_A.element; | 374 Element element_A = outline_A.element; |
380 expect(element_A.kind, ElementKind.CLASS); | 375 expect(element_A.kind, ElementKind.CLASS); |
381 expect(element_A.name, "A"); | 376 expect(element_A.name, "A"); |
382 { | 377 { |
383 Location location = element_A.location; | 378 Location location = element_A.location; |
384 expect(location.offset, testCode.indexOf("A {")); | 379 expect(location.offset, testCode.indexOf("A {")); |
| 380 expect(location.length, "A".length); |
| 381 } |
| 382 expect(element_A.parameters, null); |
| 383 expect(element_A.returnType, null); |
| 384 // A children |
| 385 List<Outline> outlines_A = outline_A.children; |
| 386 expect(outlines_A, hasLength(2)); |
| 387 { |
| 388 Outline constructorOutline = outlines_A[0]; |
| 389 Element constructorElement = constructorOutline.element; |
| 390 expect(constructorElement.kind, ElementKind.CONSTRUCTOR); |
| 391 expect(constructorElement.name, "A"); |
| 392 { |
| 393 Location location = constructorElement.location; |
| 394 expect(location.offset, testCode.indexOf("A() {")); |
385 expect(location.length, "A".length); | 395 expect(location.length, "A".length); |
386 } | 396 } |
387 expect(element_A.parameters, null); | 397 expect(constructorElement.parameters, "()"); |
388 expect(element_A.returnType, null); | 398 expect(constructorElement.returnType, isNull); |
389 // A children | 399 // local function |
390 List<Outline> outlines_A = outline_A.children; | 400 List<Outline> outlines_constructor = constructorOutline.children; |
391 expect(outlines_A, hasLength(2)); | 401 expect(outlines_constructor, hasLength(1)); |
392 { | 402 { |
393 Outline constructorOutline = outlines_A[0]; | 403 Outline outline = outlines_constructor[0]; |
394 Element constructorElement = constructorOutline.element; | 404 Element element = outline.element; |
395 expect(constructorElement.kind, ElementKind.CONSTRUCTOR); | 405 expect(element.kind, ElementKind.FUNCTION); |
396 expect(constructorElement.name, "A"); | 406 expect(element.name, "local_A"); |
397 { | 407 { |
398 Location location = constructorElement.location; | 408 Location location = element.location; |
399 expect(location.offset, testCode.indexOf("A() {")); | 409 expect(location.offset, testCode.indexOf("local_A() {}")); |
400 expect(location.length, "A".length); | 410 expect(location.length, "local_A".length); |
401 } | 411 } |
402 expect(constructorElement.parameters, "()"); | 412 expect(element.parameters, "()"); |
403 expect(constructorElement.returnType, isNull); | 413 expect(element.returnType, "int"); |
404 // local function | 414 } |
405 List<Outline> outlines_constructor = constructorOutline.children; | 415 } |
406 expect(outlines_constructor, hasLength(1)); | 416 { |
| 417 Outline outline_m = outlines_A[1]; |
| 418 Element element_m = outline_m.element; |
| 419 expect(element_m.kind, ElementKind.METHOD); |
| 420 expect(element_m.name, "m"); |
| 421 { |
| 422 Location location = element_m.location; |
| 423 expect(location.offset, testCode.indexOf("m() {")); |
| 424 expect(location.length, "m".length); |
| 425 } |
| 426 expect(element_m.parameters, "()"); |
| 427 expect(element_m.returnType, ""); |
| 428 // local function |
| 429 List<Outline> methodChildren = outline_m.children; |
| 430 expect(methodChildren, hasLength(1)); |
| 431 { |
| 432 Outline outline = methodChildren[0]; |
| 433 Element element = outline.element; |
| 434 expect(element.kind, ElementKind.FUNCTION); |
| 435 expect(element.name, "local_m"); |
407 { | 436 { |
408 Outline outline = outlines_constructor[0]; | 437 Location location = element.location; |
409 Element element = outline.element; | 438 expect(location.offset, testCode.indexOf("local_m() {}")); |
410 expect(element.kind, ElementKind.FUNCTION); | 439 expect(location.length, "local_m".length); |
411 expect(element.name, "local_A"); | |
412 { | |
413 Location location = element.location; | |
414 expect(location.offset, testCode.indexOf("local_A() {}")); | |
415 expect(location.length, "local_A".length); | |
416 } | |
417 expect(element.parameters, "()"); | |
418 expect(element.returnType, "int"); | |
419 } | 440 } |
420 } | 441 expect(element.parameters, "()"); |
421 { | 442 expect(element.returnType, ""); |
422 Outline outline_m = outlines_A[1]; | 443 } |
423 Element element_m = outline_m.element; | 444 } |
424 expect(element_m.kind, ElementKind.METHOD); | 445 } |
425 expect(element_m.name, "m"); | 446 // f() |
| 447 { |
| 448 Outline outline_f = topOutlines[1]; |
| 449 Element element_f = outline_f.element; |
| 450 expect(element_f.kind, ElementKind.FUNCTION); |
| 451 expect(element_f.name, "f"); |
| 452 { |
| 453 Location location = element_f.location; |
| 454 expect(location.offset, testCode.indexOf("f() {")); |
| 455 expect(location.length, "f".length); |
| 456 } |
| 457 expect(element_f.parameters, "()"); |
| 458 expect(element_f.returnType, ""); |
| 459 // f() children |
| 460 List<Outline> outlines_f = outline_f.children; |
| 461 expect(outlines_f, hasLength(2)); |
| 462 { |
| 463 Outline outline_f1 = outlines_f[0]; |
| 464 Element element_f1 = outline_f1.element; |
| 465 expect(element_f1.kind, ElementKind.FUNCTION); |
| 466 expect(element_f1.name, "local_f1"); |
| 467 { |
| 468 Location location = element_f1.location; |
| 469 expect(location.offset, testCode.indexOf("local_f1(int i) {}")); |
| 470 expect(location.length, "local_f1".length); |
| 471 } |
| 472 expect(element_f1.parameters, "(int i)"); |
| 473 expect(element_f1.returnType, ""); |
| 474 } |
| 475 { |
| 476 Outline outline_f2 = outlines_f[1]; |
| 477 Element element_f2 = outline_f2.element; |
| 478 expect(element_f2.kind, ElementKind.FUNCTION); |
| 479 expect(element_f2.name, "local_f2"); |
| 480 { |
| 481 Location location = element_f2.location; |
| 482 expect(location.offset, testCode.indexOf("local_f2(String s) {")); |
| 483 expect(location.length, "local_f2".length); |
| 484 } |
| 485 expect(element_f2.parameters, "(String s)"); |
| 486 expect(element_f2.returnType, ""); |
| 487 // local_f2() local function |
| 488 List<Outline> outlines_f2 = outline_f2.children; |
| 489 expect(outlines_f2, hasLength(1)); |
| 490 { |
| 491 Outline outline_f21 = outlines_f2[0]; |
| 492 Element element_f21 = outline_f21.element; |
| 493 expect(element_f21.kind, ElementKind.FUNCTION); |
| 494 expect(element_f21.name, "local_f21"); |
426 { | 495 { |
427 Location location = element_m.location; | 496 Location location = element_f21.location; |
428 expect(location.offset, testCode.indexOf("m() {")); | 497 expect(location.offset, testCode.indexOf("local_f21(int p) {")); |
429 expect(location.length, "m".length); | 498 expect(location.length, "local_f21".length); |
430 } | 499 } |
431 expect(element_m.parameters, "()"); | 500 expect(element_f21.parameters, "(int p)"); |
432 expect(element_m.returnType, ""); | 501 expect(element_f21.returnType, ""); |
433 // local function | 502 } |
434 List<Outline> methodChildren = outline_m.children; | 503 } |
435 expect(methodChildren, hasLength(1)); | 504 } |
436 { | |
437 Outline outline = methodChildren[0]; | |
438 Element element = outline.element; | |
439 expect(element.kind, ElementKind.FUNCTION); | |
440 expect(element.name, "local_m"); | |
441 { | |
442 Location location = element.location; | |
443 expect(location.offset, testCode.indexOf("local_m() {}")); | |
444 expect(location.length, "local_m".length); | |
445 } | |
446 expect(element.parameters, "()"); | |
447 expect(element.returnType, ""); | |
448 } | |
449 } | |
450 } | |
451 // f() | |
452 { | |
453 Outline outline_f = topOutlines[1]; | |
454 Element element_f = outline_f.element; | |
455 expect(element_f.kind, ElementKind.FUNCTION); | |
456 expect(element_f.name, "f"); | |
457 { | |
458 Location location = element_f.location; | |
459 expect(location.offset, testCode.indexOf("f() {")); | |
460 expect(location.length, "f".length); | |
461 } | |
462 expect(element_f.parameters, "()"); | |
463 expect(element_f.returnType, ""); | |
464 // f() children | |
465 List<Outline> outlines_f = outline_f.children; | |
466 expect(outlines_f, hasLength(2)); | |
467 { | |
468 Outline outline_f1 = outlines_f[0]; | |
469 Element element_f1 = outline_f1.element; | |
470 expect(element_f1.kind, ElementKind.FUNCTION); | |
471 expect(element_f1.name, "local_f1"); | |
472 { | |
473 Location location = element_f1.location; | |
474 expect(location.offset, testCode.indexOf("local_f1(int i) {}")); | |
475 expect(location.length, "local_f1".length); | |
476 } | |
477 expect(element_f1.parameters, "(int i)"); | |
478 expect(element_f1.returnType, ""); | |
479 } | |
480 { | |
481 Outline outline_f2 = outlines_f[1]; | |
482 Element element_f2 = outline_f2.element; | |
483 expect(element_f2.kind, ElementKind.FUNCTION); | |
484 expect(element_f2.name, "local_f2"); | |
485 { | |
486 Location location = element_f2.location; | |
487 expect(location.offset, testCode.indexOf("local_f2(String s) {")); | |
488 expect(location.length, "local_f2".length); | |
489 } | |
490 expect(element_f2.parameters, "(String s)"); | |
491 expect(element_f2.returnType, ""); | |
492 // local_f2() local function | |
493 List<Outline> outlines_f2 = outline_f2.children; | |
494 expect(outlines_f2, hasLength(1)); | |
495 { | |
496 Outline outline_f21 = outlines_f2[0]; | |
497 Element element_f21 = outline_f21.element; | |
498 expect(element_f21.kind, ElementKind.FUNCTION); | |
499 expect(element_f21.name, "local_f21"); | |
500 { | |
501 Location location = element_f21.location; | |
502 expect(location.offset, testCode.indexOf("local_f21(int p) {")); | |
503 expect(location.length, "local_f21".length); | |
504 } | |
505 expect(element_f21.parameters, "(int p)"); | |
506 expect(element_f21.returnType, ""); | |
507 } | |
508 } | |
509 } | |
510 }); | |
511 } | 505 } |
512 | 506 |
513 test_sourceRange_inClass() { | 507 test_sourceRange_inClass() async { |
514 addTestFile(''' | 508 addTestFile(''' |
515 class A { // leftA | 509 class A { // leftA |
516 int methodA() {} // endA | 510 int methodA() {} // endA |
517 int methodB() {} // endB | 511 int methodB() {} // endB |
518 } | 512 } |
519 '''); | 513 '''); |
520 return prepareOutline().then((_) { | 514 await prepareOutline(); |
521 Outline unitOutline = outline; | 515 Outline unitOutline = outline; |
522 List<Outline> outlines = unitOutline.children[0].children; | 516 List<Outline> outlines = unitOutline.children[0].children; |
523 expect(outlines, hasLength(2)); | 517 expect(outlines, hasLength(2)); |
524 // methodA | 518 // methodA |
525 { | 519 { |
526 Outline outline = outlines[0]; | 520 Outline outline = outlines[0]; |
527 Element element = outline.element; | 521 Element element = outline.element; |
528 expect(element.kind, ElementKind.METHOD); | 522 expect(element.kind, ElementKind.METHOD); |
529 expect(element.name, "methodA"); | 523 expect(element.name, "methodA"); |
530 { | 524 { |
531 int offset = testCode.indexOf(" // leftA"); | 525 int offset = testCode.indexOf(" // leftA"); |
532 int end = testCode.indexOf(" // endA"); | 526 int end = testCode.indexOf(" // endA"); |
533 expect(outline.offset, offset); | 527 expect(outline.offset, offset); |
534 expect(outline.length, end - offset); | 528 expect(outline.length, end - offset); |
535 } | 529 } |
536 } | 530 } |
537 // methodB | 531 // methodB |
538 { | 532 { |
539 Outline outline = outlines[1]; | 533 Outline outline = outlines[1]; |
540 Element element = outline.element; | 534 Element element = outline.element; |
541 expect(element.kind, ElementKind.METHOD); | 535 expect(element.kind, ElementKind.METHOD); |
542 expect(element.name, "methodB"); | 536 expect(element.name, "methodB"); |
543 { | 537 { |
544 int offset = testCode.indexOf(" // endA"); | 538 int offset = testCode.indexOf(" // endA"); |
545 int end = testCode.indexOf(" // endB"); | 539 int end = testCode.indexOf(" // endB"); |
546 expect(outline.offset, offset); | 540 expect(outline.offset, offset); |
547 expect(outline.length, end - offset); | 541 expect(outline.length, end - offset); |
548 } | 542 } |
549 } | 543 } |
550 }); | |
551 } | 544 } |
552 | 545 |
553 test_sourceRange_inClass_inVariableList() { | 546 test_sourceRange_inClass_inVariableList() async { |
554 addTestFile(''' | 547 addTestFile(''' |
555 class A { // leftA | 548 class A { // leftA |
556 int fieldA, fieldB, fieldC; // marker | 549 int fieldA, fieldB, fieldC; // marker |
557 int fieldD; // marker2 | 550 int fieldD; // marker2 |
558 } | 551 } |
559 '''); | 552 '''); |
560 return prepareOutline().then((_) { | 553 await prepareOutline(); |
561 Outline unitOutline = outline; | 554 Outline unitOutline = outline; |
562 List<Outline> outlines = unitOutline.children[0].children; | 555 List<Outline> outlines = unitOutline.children[0].children; |
563 expect(outlines, hasLength(4)); | 556 expect(outlines, hasLength(4)); |
564 // fieldA | 557 // fieldA |
565 { | 558 { |
566 Outline outline = outlines[0]; | 559 Outline outline = outlines[0]; |
567 Element element = outline.element; | 560 Element element = outline.element; |
568 expect(element.kind, ElementKind.FIELD); | 561 expect(element.kind, ElementKind.FIELD); |
569 expect(element.name, "fieldA"); | 562 expect(element.name, "fieldA"); |
570 { | 563 { |
571 int offset = testCode.indexOf(" // leftA"); | 564 int offset = testCode.indexOf(" // leftA"); |
572 int end = testCode.indexOf(", fieldB"); | 565 int end = testCode.indexOf(", fieldB"); |
573 expect(outline.offset, offset); | 566 expect(outline.offset, offset); |
574 expect(outline.length, end - offset); | 567 expect(outline.length, end - offset); |
575 } | 568 } |
576 } | 569 } |
577 // fieldB | 570 // fieldB |
578 { | 571 { |
579 Outline outline = outlines[1]; | 572 Outline outline = outlines[1]; |
580 Element element = outline.element; | 573 Element element = outline.element; |
581 expect(element.kind, ElementKind.FIELD); | 574 expect(element.kind, ElementKind.FIELD); |
582 expect(element.name, "fieldB"); | 575 expect(element.name, "fieldB"); |
583 { | 576 { |
584 int offset = testCode.indexOf(", fieldB"); | 577 int offset = testCode.indexOf(", fieldB"); |
585 int end = testCode.indexOf(", fieldC"); | 578 int end = testCode.indexOf(", fieldC"); |
586 expect(outline.offset, offset); | 579 expect(outline.offset, offset); |
587 expect(outline.length, end - offset); | 580 expect(outline.length, end - offset); |
588 } | 581 } |
589 } | 582 } |
590 // fieldC | 583 // fieldC |
591 { | 584 { |
592 Outline outline = outlines[2]; | 585 Outline outline = outlines[2]; |
593 Element element = outline.element; | 586 Element element = outline.element; |
594 expect(element.kind, ElementKind.FIELD); | 587 expect(element.kind, ElementKind.FIELD); |
595 expect(element.name, "fieldC"); | 588 expect(element.name, "fieldC"); |
596 { | 589 { |
597 int offset = testCode.indexOf(", fieldC"); | 590 int offset = testCode.indexOf(", fieldC"); |
598 int end = testCode.indexOf(" // marker"); | 591 int end = testCode.indexOf(" // marker"); |
599 expect(outline.offset, offset); | 592 expect(outline.offset, offset); |
600 expect(outline.length, end - offset); | 593 expect(outline.length, end - offset); |
601 } | 594 } |
602 } | 595 } |
603 // fieldD | 596 // fieldD |
604 { | 597 { |
605 Outline outline = outlines[3]; | 598 Outline outline = outlines[3]; |
606 Element element = outline.element; | 599 Element element = outline.element; |
607 expect(element.kind, ElementKind.FIELD); | 600 expect(element.kind, ElementKind.FIELD); |
608 expect(element.name, "fieldD"); | 601 expect(element.name, "fieldD"); |
609 { | 602 { |
610 int offset = testCode.indexOf(" // marker"); | 603 int offset = testCode.indexOf(" // marker"); |
611 int end = testCode.indexOf(" // marker2"); | 604 int end = testCode.indexOf(" // marker2"); |
612 expect(outline.offset, offset); | 605 expect(outline.offset, offset); |
613 expect(outline.length, end - offset); | 606 expect(outline.length, end - offset); |
614 } | 607 } |
615 } | 608 } |
616 }); | |
617 } | 609 } |
618 | 610 |
619 test_sourceRange_inUnit() { | 611 test_sourceRange_inUnit() async { |
620 addTestFile(''' | 612 addTestFile(''' |
621 library lib; | 613 library lib; |
622 /// My first class. | 614 /// My first class. |
623 class A { | 615 class A { |
624 } // endA | 616 } // endA |
625 class B { | 617 class B { |
626 } // endB | 618 } // endB |
627 '''); | 619 '''); |
628 return prepareOutline().then((_) { | 620 await prepareOutline(); |
629 Outline unitOutline = outline; | 621 Outline unitOutline = outline; |
630 List<Outline> topOutlines = unitOutline.children; | 622 List<Outline> topOutlines = unitOutline.children; |
631 expect(topOutlines, hasLength(2)); | 623 expect(topOutlines, hasLength(2)); |
632 // A | 624 // A |
| 625 { |
| 626 Outline outline = topOutlines[0]; |
| 627 Element element = outline.element; |
| 628 expect(element.kind, ElementKind.CLASS); |
| 629 expect(element.name, "A"); |
633 { | 630 { |
634 Outline outline = topOutlines[0]; | 631 int offset = testCode.indexOf("/// My first class."); |
635 Element element = outline.element; | 632 int end = testCode.indexOf(" // endA"); |
636 expect(element.kind, ElementKind.CLASS); | 633 expect(outline.offset, offset); |
637 expect(element.name, "A"); | 634 expect(outline.length, end - offset); |
638 { | |
639 int offset = testCode.indexOf("/// My first class."); | |
640 int end = testCode.indexOf(" // endA"); | |
641 expect(outline.offset, offset); | |
642 expect(outline.length, end - offset); | |
643 } | |
644 } | 635 } |
645 // B | 636 } |
| 637 // B |
| 638 { |
| 639 Outline outline = topOutlines[1]; |
| 640 Element element = outline.element; |
| 641 expect(element.kind, ElementKind.CLASS); |
| 642 expect(element.name, "B"); |
646 { | 643 { |
647 Outline outline = topOutlines[1]; | 644 int offset = testCode.indexOf(" // endA"); |
648 Element element = outline.element; | 645 int end = testCode.indexOf(" // endB"); |
649 expect(element.kind, ElementKind.CLASS); | 646 expect(outline.offset, offset); |
650 expect(element.name, "B"); | 647 expect(outline.length, end - offset); |
651 { | |
652 int offset = testCode.indexOf(" // endA"); | |
653 int end = testCode.indexOf(" // endB"); | |
654 expect(outline.offset, offset); | |
655 expect(outline.length, end - offset); | |
656 } | |
657 } | 648 } |
658 }); | 649 } |
659 } | 650 } |
660 | 651 |
661 test_sourceRange_inUnit_inVariableList() { | 652 test_sourceRange_inUnit_inVariableList() async { |
662 addTestFile(''' | 653 addTestFile(''' |
663 int fieldA, fieldB, fieldC; // marker | 654 int fieldA, fieldB, fieldC; // marker |
664 int fieldD; // marker2 | 655 int fieldD; // marker2 |
665 '''); | 656 '''); |
666 return prepareOutline().then((_) { | 657 await prepareOutline(); |
667 Outline unitOutline = outline; | 658 Outline unitOutline = outline; |
668 List<Outline> outlines = unitOutline.children; | 659 List<Outline> outlines = unitOutline.children; |
669 expect(outlines, hasLength(4)); | 660 expect(outlines, hasLength(4)); |
670 // fieldA | 661 // fieldA |
| 662 { |
| 663 Outline outline = outlines[0]; |
| 664 Element element = outline.element; |
| 665 expect(element.kind, ElementKind.TOP_LEVEL_VARIABLE); |
| 666 expect(element.name, "fieldA"); |
671 { | 667 { |
672 Outline outline = outlines[0]; | 668 int offset = 0; |
673 Element element = outline.element; | 669 int end = testCode.indexOf(", fieldB"); |
674 expect(element.kind, ElementKind.TOP_LEVEL_VARIABLE); | 670 expect(outline.offset, offset); |
675 expect(element.name, "fieldA"); | 671 expect(outline.length, end - offset); |
676 { | |
677 int offset = 0; | |
678 int end = testCode.indexOf(", fieldB"); | |
679 expect(outline.offset, offset); | |
680 expect(outline.length, end - offset); | |
681 } | |
682 } | 672 } |
683 // fieldB | 673 } |
| 674 // fieldB |
| 675 { |
| 676 Outline outline = outlines[1]; |
| 677 Element element = outline.element; |
| 678 expect(element.kind, ElementKind.TOP_LEVEL_VARIABLE); |
| 679 expect(element.name, "fieldB"); |
684 { | 680 { |
685 Outline outline = outlines[1]; | 681 int offset = testCode.indexOf(", fieldB"); |
686 Element element = outline.element; | 682 int end = testCode.indexOf(", fieldC"); |
687 expect(element.kind, ElementKind.TOP_LEVEL_VARIABLE); | 683 expect(outline.offset, offset); |
688 expect(element.name, "fieldB"); | 684 expect(outline.length, end - offset); |
689 { | |
690 int offset = testCode.indexOf(", fieldB"); | |
691 int end = testCode.indexOf(", fieldC"); | |
692 expect(outline.offset, offset); | |
693 expect(outline.length, end - offset); | |
694 } | |
695 } | 685 } |
696 // fieldC | 686 } |
| 687 // fieldC |
| 688 { |
| 689 Outline outline = outlines[2]; |
| 690 Element element = outline.element; |
| 691 expect(element.kind, ElementKind.TOP_LEVEL_VARIABLE); |
| 692 expect(element.name, "fieldC"); |
697 { | 693 { |
698 Outline outline = outlines[2]; | 694 int offset = testCode.indexOf(", fieldC"); |
699 Element element = outline.element; | 695 int end = testCode.indexOf(" // marker"); |
700 expect(element.kind, ElementKind.TOP_LEVEL_VARIABLE); | 696 expect(outline.offset, offset); |
701 expect(element.name, "fieldC"); | 697 expect(outline.length, end - offset); |
702 { | |
703 int offset = testCode.indexOf(", fieldC"); | |
704 int end = testCode.indexOf(" // marker"); | |
705 expect(outline.offset, offset); | |
706 expect(outline.length, end - offset); | |
707 } | |
708 } | 698 } |
709 // fieldD | 699 } |
| 700 // fieldD |
| 701 { |
| 702 Outline outline = outlines[3]; |
| 703 Element element = outline.element; |
| 704 expect(element.kind, ElementKind.TOP_LEVEL_VARIABLE); |
| 705 expect(element.name, "fieldD"); |
710 { | 706 { |
711 Outline outline = outlines[3]; | 707 int offset = testCode.indexOf(" // marker"); |
712 Element element = outline.element; | 708 int end = testCode.indexOf(" // marker2"); |
713 expect(element.kind, ElementKind.TOP_LEVEL_VARIABLE); | 709 expect(outline.offset, offset); |
714 expect(element.name, "fieldD"); | 710 expect(outline.length, end - offset); |
715 { | |
716 int offset = testCode.indexOf(" // marker"); | |
717 int end = testCode.indexOf(" // marker2"); | |
718 expect(outline.offset, offset); | |
719 expect(outline.length, end - offset); | |
720 } | |
721 } | 711 } |
722 }); | 712 } |
723 } | 713 } |
724 | 714 |
725 test_topLevel() { | 715 test_topLevel() async { |
726 addTestFile(''' | 716 addTestFile(''' |
727 typedef String FTA<K, V>(int i, String s); | 717 typedef String FTA<K, V>(int i, String s); |
728 typedef FTB(int p); | 718 typedef FTB(int p); |
729 class A<T> {} | 719 class A<T> {} |
730 class B {} | 720 class B {} |
731 class CTA<T> = A<T> with B; | 721 class CTA<T> = A<T> with B; |
732 class CTB = A with B; | 722 class CTB = A with B; |
733 String fA(int i, String s) => null; | 723 String fA(int i, String s) => null; |
734 fB(int p) => null; | 724 fB(int p) => null; |
735 String get propA => null; | 725 String get propA => null; |
736 set propB(int v) {} | 726 set propB(int v) {} |
737 '''); | 727 '''); |
738 return prepareOutline().then((_) { | 728 await prepareOutline(); |
739 Outline unitOutline = outline; | 729 Outline unitOutline = outline; |
740 List<Outline> topOutlines = unitOutline.children; | 730 List<Outline> topOutlines = unitOutline.children; |
741 expect(topOutlines, hasLength(10)); | 731 expect(topOutlines, hasLength(10)); |
742 // FTA | 732 // FTA |
| 733 { |
| 734 Outline outline = topOutlines[0]; |
| 735 Element element = outline.element; |
| 736 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); |
| 737 expect(element.name, "FTA"); |
| 738 expect(element.typeParameters, "<K, V>"); |
743 { | 739 { |
744 Outline outline = topOutlines[0]; | 740 Location location = element.location; |
745 Element element = outline.element; | 741 expect(location.offset, testCode.indexOf("FTA<K, V>(")); |
746 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); | 742 expect(location.length, "FTA".length); |
747 expect(element.name, "FTA"); | |
748 expect(element.typeParameters, "<K, V>"); | |
749 { | |
750 Location location = element.location; | |
751 expect(location.offset, testCode.indexOf("FTA<K, V>(")); | |
752 expect(location.length, "FTA".length); | |
753 } | |
754 expect(element.parameters, "(int i, String s)"); | |
755 expect(element.returnType, "String"); | |
756 } | 743 } |
757 // FTB | 744 expect(element.parameters, "(int i, String s)"); |
| 745 expect(element.returnType, "String"); |
| 746 } |
| 747 // FTB |
| 748 { |
| 749 Outline outline = topOutlines[1]; |
| 750 Element element = outline.element; |
| 751 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); |
| 752 expect(element.name, "FTB"); |
| 753 expect(element.typeParameters, isNull); |
758 { | 754 { |
759 Outline outline = topOutlines[1]; | 755 Location location = element.location; |
760 Element element = outline.element; | 756 expect(location.offset, testCode.indexOf("FTB(")); |
761 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); | 757 expect(location.length, "FTB".length); |
762 expect(element.name, "FTB"); | |
763 expect(element.typeParameters, isNull); | |
764 { | |
765 Location location = element.location; | |
766 expect(location.offset, testCode.indexOf("FTB(")); | |
767 expect(location.length, "FTB".length); | |
768 } | |
769 expect(element.parameters, "(int p)"); | |
770 expect(element.returnType, ""); | |
771 } | 758 } |
772 // CTA | 759 expect(element.parameters, "(int p)"); |
| 760 expect(element.returnType, ""); |
| 761 } |
| 762 // CTA |
| 763 { |
| 764 Outline outline = topOutlines[4]; |
| 765 Element element = outline.element; |
| 766 expect(element.kind, ElementKind.CLASS_TYPE_ALIAS); |
| 767 expect(element.name, "CTA"); |
| 768 expect(element.typeParameters, '<T>'); |
773 { | 769 { |
774 Outline outline = topOutlines[4]; | 770 Location location = element.location; |
775 Element element = outline.element; | 771 expect(location.offset, testCode.indexOf("CTA<T> =")); |
776 expect(element.kind, ElementKind.CLASS_TYPE_ALIAS); | 772 expect(location.length, "CTA".length); |
777 expect(element.name, "CTA"); | |
778 expect(element.typeParameters, '<T>'); | |
779 { | |
780 Location location = element.location; | |
781 expect(location.offset, testCode.indexOf("CTA<T> =")); | |
782 expect(location.length, "CTA".length); | |
783 } | |
784 expect(element.parameters, isNull); | |
785 expect(element.returnType, isNull); | |
786 } | 773 } |
787 // CTB | 774 expect(element.parameters, isNull); |
| 775 expect(element.returnType, isNull); |
| 776 } |
| 777 // CTB |
| 778 { |
| 779 Outline outline = topOutlines[5]; |
| 780 Element element = outline.element; |
| 781 expect(element.kind, ElementKind.CLASS_TYPE_ALIAS); |
| 782 expect(element.name, 'CTB'); |
| 783 expect(element.typeParameters, isNull); |
| 784 expect(element.returnType, isNull); |
| 785 } |
| 786 // fA |
| 787 { |
| 788 Outline outline = topOutlines[6]; |
| 789 Element element = outline.element; |
| 790 expect(element.kind, ElementKind.FUNCTION); |
| 791 expect(element.name, "fA"); |
788 { | 792 { |
789 Outline outline = topOutlines[5]; | 793 Location location = element.location; |
790 Element element = outline.element; | 794 expect(location.offset, testCode.indexOf("fA(")); |
791 expect(element.kind, ElementKind.CLASS_TYPE_ALIAS); | 795 expect(location.length, "fA".length); |
792 expect(element.name, 'CTB'); | |
793 expect(element.typeParameters, isNull); | |
794 expect(element.returnType, isNull); | |
795 } | 796 } |
796 // fA | 797 expect(element.parameters, "(int i, String s)"); |
| 798 expect(element.returnType, "String"); |
| 799 } |
| 800 // fB |
| 801 { |
| 802 Outline outline = topOutlines[7]; |
| 803 Element element = outline.element; |
| 804 expect(element.kind, ElementKind.FUNCTION); |
| 805 expect(element.name, "fB"); |
797 { | 806 { |
798 Outline outline = topOutlines[6]; | 807 Location location = element.location; |
799 Element element = outline.element; | 808 expect(location.offset, testCode.indexOf("fB(")); |
800 expect(element.kind, ElementKind.FUNCTION); | 809 expect(location.length, "fB".length); |
801 expect(element.name, "fA"); | |
802 { | |
803 Location location = element.location; | |
804 expect(location.offset, testCode.indexOf("fA(")); | |
805 expect(location.length, "fA".length); | |
806 } | |
807 expect(element.parameters, "(int i, String s)"); | |
808 expect(element.returnType, "String"); | |
809 } | 810 } |
810 // fB | 811 expect(element.parameters, "(int p)"); |
| 812 expect(element.returnType, ""); |
| 813 } |
| 814 // propA |
| 815 { |
| 816 Outline outline = topOutlines[8]; |
| 817 Element element = outline.element; |
| 818 expect(element.kind, ElementKind.GETTER); |
| 819 expect(element.name, "propA"); |
811 { | 820 { |
812 Outline outline = topOutlines[7]; | 821 Location location = element.location; |
813 Element element = outline.element; | 822 expect(location.offset, testCode.indexOf("propA => null;")); |
814 expect(element.kind, ElementKind.FUNCTION); | 823 expect(location.length, "propA".length); |
815 expect(element.name, "fB"); | |
816 { | |
817 Location location = element.location; | |
818 expect(location.offset, testCode.indexOf("fB(")); | |
819 expect(location.length, "fB".length); | |
820 } | |
821 expect(element.parameters, "(int p)"); | |
822 expect(element.returnType, ""); | |
823 } | 824 } |
824 // propA | 825 expect(element.parameters, ""); |
| 826 expect(element.returnType, "String"); |
| 827 } |
| 828 // propB |
| 829 { |
| 830 Outline outline = topOutlines[9]; |
| 831 Element element = outline.element; |
| 832 expect(element.kind, ElementKind.SETTER); |
| 833 expect(element.name, "propB"); |
825 { | 834 { |
826 Outline outline = topOutlines[8]; | 835 Location location = element.location; |
827 Element element = outline.element; | 836 expect(location.offset, testCode.indexOf("propB(int v) {}")); |
828 expect(element.kind, ElementKind.GETTER); | 837 expect(location.length, "propB".length); |
829 expect(element.name, "propA"); | |
830 { | |
831 Location location = element.location; | |
832 expect(location.offset, testCode.indexOf("propA => null;")); | |
833 expect(location.length, "propA".length); | |
834 } | |
835 expect(element.parameters, ""); | |
836 expect(element.returnType, "String"); | |
837 } | 838 } |
838 // propB | 839 expect(element.parameters, "(int v)"); |
839 { | 840 expect(element.returnType, ""); |
840 Outline outline = topOutlines[9]; | 841 } |
841 Element element = outline.element; | |
842 expect(element.kind, ElementKind.SETTER); | |
843 expect(element.name, "propB"); | |
844 { | |
845 Location location = element.location; | |
846 expect(location.offset, testCode.indexOf("propB(int v) {}")); | |
847 expect(location.length, "propB".length); | |
848 } | |
849 expect(element.parameters, "(int v)"); | |
850 expect(element.returnType, ""); | |
851 } | |
852 }); | |
853 } | 842 } |
854 | 843 |
855 void _isEnumConstant(Outline outline, String name) { | 844 void _isEnumConstant(Outline outline, String name) { |
856 Element element = outline.element; | 845 Element element = outline.element; |
857 expect(element.kind, ElementKind.ENUM_CONSTANT); | 846 expect(element.kind, ElementKind.ENUM_CONSTANT); |
858 expect(element.name, name); | 847 expect(element.name, name); |
859 expect(element.parameters, isNull); | 848 expect(element.parameters, isNull); |
860 expect(element.returnType, isNull); | 849 expect(element.returnType, isNull); |
861 } | 850 } |
862 } | 851 } |
OLD | NEW |