| 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.domain.analysis.notification.outline; | 5 library test.domain.analysis.notification.outline; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/computer/computer_outline.dart'; | 10 import 'package:analysis_server/src/computer/computer_outline.dart'; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 return prepareOutline(() { | 88 return prepareOutline(() { |
| 89 Outline unitOutline = outline; | 89 Outline unitOutline = outline; |
| 90 List<Outline> topOutlines = unitOutline.children; | 90 List<Outline> topOutlines = unitOutline.children; |
| 91 expect(topOutlines, hasLength(2)); | 91 expect(topOutlines, hasLength(2)); |
| 92 // A | 92 // A |
| 93 { | 93 { |
| 94 Outline outline_A = topOutlines[0]; | 94 Outline outline_A = topOutlines[0]; |
| 95 Element element_A = outline_A.element; | 95 Element element_A = outline_A.element; |
| 96 expect(element_A.kind, ElementKind.CLASS); | 96 expect(element_A.kind, ElementKind.CLASS); |
| 97 expect(element_A.name, "A"); | 97 expect(element_A.name, "A"); |
| 98 expect(element_A.offset, testCode.indexOf("A {")); | 98 { |
| 99 expect(element_A.length, 1); | 99 Location location = element_A.location; |
| 100 expect(location.offset, testCode.indexOf("A {")); |
| 101 expect(location.length, 1); |
| 102 } |
| 100 expect(element_A.parameters, null); | 103 expect(element_A.parameters, null); |
| 101 expect(element_A.returnType, null); | 104 expect(element_A.returnType, null); |
| 102 // A children | 105 // A children |
| 103 List<Outline> outlines_A = outline_A.children; | 106 List<Outline> outlines_A = outline_A.children; |
| 104 expect(outlines_A, hasLength(10)); | 107 expect(outlines_A, hasLength(10)); |
| 105 { | 108 { |
| 106 Outline outline = outlines_A[0]; | 109 Outline outline = outlines_A[0]; |
| 107 Element element = outline.element; | 110 Element element = outline.element; |
| 108 expect(element.kind, ElementKind.FIELD); | 111 expect(element.kind, ElementKind.FIELD); |
| 109 expect(element.name, "fa"); | 112 expect(element.name, "fa"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 124 expect(element.kind, ElementKind.FIELD); | 127 expect(element.kind, ElementKind.FIELD); |
| 125 expect(element.name, "fc"); | 128 expect(element.name, "fc"); |
| 126 expect(element.parameters, isNull); | 129 expect(element.parameters, isNull); |
| 127 expect(element.returnType, "String"); | 130 expect(element.returnType, "String"); |
| 128 } | 131 } |
| 129 { | 132 { |
| 130 Outline outline = outlines_A[3]; | 133 Outline outline = outlines_A[3]; |
| 131 Element element = outline.element; | 134 Element element = outline.element; |
| 132 expect(element.kind, ElementKind.CONSTRUCTOR); | 135 expect(element.kind, ElementKind.CONSTRUCTOR); |
| 133 expect(element.name, "A"); | 136 expect(element.name, "A"); |
| 134 expect(element.offset, testCode.indexOf("A(int i, String s);")); | 137 { |
| 135 expect(element.length, "A".length); | 138 Location location = element.location; |
| 139 expect(location.offset, testCode.indexOf("A(int i, String s);")); |
| 140 expect(location.length, "A".length); |
| 141 } |
| 136 expect(element.parameters, "(int i, String s)"); | 142 expect(element.parameters, "(int i, String s)"); |
| 137 expect(element.returnType, isNull); | 143 expect(element.returnType, isNull); |
| 138 expect(element.isAbstract, isFalse); | 144 expect(element.isAbstract, isFalse); |
| 139 expect(element.isStatic, isFalse); | 145 expect(element.isStatic, isFalse); |
| 140 } | 146 } |
| 141 { | 147 { |
| 142 Outline outline = outlines_A[4]; | 148 Outline outline = outlines_A[4]; |
| 143 Element element = outline.element; | 149 Element element = outline.element; |
| 144 expect(element.kind, ElementKind.CONSTRUCTOR); | 150 expect(element.kind, ElementKind.CONSTRUCTOR); |
| 145 expect(element.name, "A.name"); | 151 expect(element.name, "A.name"); |
| 146 expect(element.offset, testCode.indexOf("name(num p);")); | 152 { |
| 147 expect(element.length, "name".length); | 153 Location location = element.location; |
| 154 expect(location.offset, testCode.indexOf("name(num p);")); |
| 155 expect(location.length, "name".length); |
| 156 } |
| 148 expect(element.parameters, "(num p)"); | 157 expect(element.parameters, "(num p)"); |
| 149 expect(element.returnType, isNull); | 158 expect(element.returnType, isNull); |
| 150 expect(element.isAbstract, isFalse); | 159 expect(element.isAbstract, isFalse); |
| 151 expect(element.isStatic, isFalse); | 160 expect(element.isStatic, isFalse); |
| 152 } | 161 } |
| 153 { | 162 { |
| 154 Outline outline = outlines_A[5]; | 163 Outline outline = outlines_A[5]; |
| 155 Element element = outline.element; | 164 Element element = outline.element; |
| 156 expect(element.kind, ElementKind.CONSTRUCTOR); | 165 expect(element.kind, ElementKind.CONSTRUCTOR); |
| 157 expect(element.name, "A._privateName"); | 166 expect(element.name, "A._privateName"); |
| 158 expect(element.offset, testCode.indexOf("_privateName(num p);")); | 167 { |
| 159 expect(element.length, "_privateName".length); | 168 Location location = element.location; |
| 169 expect(location.offset, testCode.indexOf("_privateName(num p);")); |
| 170 expect(location.length, "_privateName".length); |
| 171 } |
| 160 expect(element.parameters, "(num p)"); | 172 expect(element.parameters, "(num p)"); |
| 161 expect(element.returnType, isNull); | 173 expect(element.returnType, isNull); |
| 162 expect(element.isAbstract, isFalse); | 174 expect(element.isAbstract, isFalse); |
| 163 expect(element.isStatic, isFalse); | 175 expect(element.isStatic, isFalse); |
| 164 } | 176 } |
| 165 { | 177 { |
| 166 Outline outline = outlines_A[6]; | 178 Outline outline = outlines_A[6]; |
| 167 Element element = outline.element; | 179 Element element = outline.element; |
| 168 expect(element.kind, ElementKind.METHOD); | 180 expect(element.kind, ElementKind.METHOD); |
| 169 expect(element.name, "ma"); | 181 expect(element.name, "ma"); |
| 170 expect(element.offset, testCode.indexOf("ma(int pa) => null;")); | 182 { |
| 171 expect(element.length, "ma".length); | 183 Location location = element.location; |
| 184 expect(location.offset, testCode.indexOf("ma(int pa) => null;")); |
| 185 expect(location.length, "ma".length); |
| 186 } |
| 172 expect(element.parameters, "(int pa)"); | 187 expect(element.parameters, "(int pa)"); |
| 173 expect(element.returnType, "String"); | 188 expect(element.returnType, "String"); |
| 174 expect(element.isAbstract, isFalse); | 189 expect(element.isAbstract, isFalse); |
| 175 expect(element.isStatic, isTrue); | 190 expect(element.isStatic, isTrue); |
| 176 } | 191 } |
| 177 { | 192 { |
| 178 Outline outline = outlines_A[7]; | 193 Outline outline = outlines_A[7]; |
| 179 Element element = outline.element; | 194 Element element = outline.element; |
| 180 expect(element.kind, ElementKind.METHOD); | 195 expect(element.kind, ElementKind.METHOD); |
| 181 expect(element.name, "_mb"); | 196 expect(element.name, "_mb"); |
| 182 expect(element.offset, testCode.indexOf("_mb(int pb);")); | 197 { |
| 183 expect(element.length, "_mb".length); | 198 Location location = element.location; |
| 199 expect(location.offset, testCode.indexOf("_mb(int pb);")); |
| 200 expect(location.length, "_mb".length); |
| 201 } |
| 184 expect(element.parameters, "(int pb)"); | 202 expect(element.parameters, "(int pb)"); |
| 185 expect(element.returnType, ""); | 203 expect(element.returnType, ""); |
| 186 expect(element.isAbstract, isTrue); | 204 expect(element.isAbstract, isTrue); |
| 187 expect(element.isStatic, isFalse); | 205 expect(element.isStatic, isFalse); |
| 188 } | 206 } |
| 189 { | 207 { |
| 190 Outline outline = outlines_A[8]; | 208 Outline outline = outlines_A[8]; |
| 191 Element element = outline.element; | 209 Element element = outline.element; |
| 192 expect(element.kind, ElementKind.GETTER); | 210 expect(element.kind, ElementKind.GETTER); |
| 193 expect(element.name, "propA"); | 211 expect(element.name, "propA"); |
| 194 expect(element.offset, testCode.indexOf("propA => null;")); | 212 { |
| 195 expect(element.length, "propA".length); | 213 Location location = element.location; |
| 214 expect(location.offset, testCode.indexOf("propA => null;")); |
| 215 expect(location.length, "propA".length); |
| 216 } |
| 196 expect(element.parameters, ""); | 217 expect(element.parameters, ""); |
| 197 expect(element.returnType, "String"); | 218 expect(element.returnType, "String"); |
| 198 } | 219 } |
| 199 { | 220 { |
| 200 Outline outline = outlines_A[9]; | 221 Outline outline = outlines_A[9]; |
| 201 Element element = outline.element; | 222 Element element = outline.element; |
| 202 expect(element.kind, ElementKind.SETTER); | 223 expect(element.kind, ElementKind.SETTER); |
| 203 expect(element.name, "propB"); | 224 expect(element.name, "propB"); |
| 204 expect(element.offset, testCode.indexOf("propB(int v) {}")); | 225 { |
| 205 expect(element.length, "propB".length); | 226 Location location = element.location; |
| 227 expect(location.offset, testCode.indexOf("propB(int v) {}")); |
| 228 expect(location.length, "propB".length); |
| 229 } |
| 206 expect(element.parameters, "(int v)"); | 230 expect(element.parameters, "(int v)"); |
| 207 expect(element.returnType, ""); | 231 expect(element.returnType, ""); |
| 208 } | 232 } |
| 209 } | 233 } |
| 210 // B | 234 // B |
| 211 { | 235 { |
| 212 Outline outline_B = topOutlines[1]; | 236 Outline outline_B = topOutlines[1]; |
| 213 Element element_B = outline_B.element; | 237 Element element_B = outline_B.element; |
| 214 expect(element_B.kind, ElementKind.CLASS); | 238 expect(element_B.kind, ElementKind.CLASS); |
| 215 expect(element_B.name, "B"); | 239 expect(element_B.name, "B"); |
| 216 expect(element_B.offset, testCode.indexOf("B {")); | 240 { |
| 217 expect(element_B.length, 1); | 241 Location location = element_B.location; |
| 242 expect(location.offset, testCode.indexOf("B {")); |
| 243 expect(location.length, 1); |
| 244 } |
| 218 expect(element_B.parameters, null); | 245 expect(element_B.parameters, null); |
| 219 expect(element_B.returnType, null); | 246 expect(element_B.returnType, null); |
| 220 // B children | 247 // B children |
| 221 List<Outline> outlines_B = outline_B.children; | 248 List<Outline> outlines_B = outline_B.children; |
| 222 expect(outlines_B, hasLength(1)); | 249 expect(outlines_B, hasLength(1)); |
| 223 { | 250 { |
| 224 Outline outline = outlines_B[0]; | 251 Outline outline = outlines_B[0]; |
| 225 Element element = outline.element; | 252 Element element = outline.element; |
| 226 expect(element.kind, ElementKind.CONSTRUCTOR); | 253 expect(element.kind, ElementKind.CONSTRUCTOR); |
| 227 expect(element.name, "B"); | 254 expect(element.name, "B"); |
| 228 expect(element.offset, testCode.indexOf("B(int p);")); | 255 { |
| 229 expect(element.length, "B".length); | 256 Location location = element.location; |
| 257 expect(location.offset, testCode.indexOf("B(int p);")); |
| 258 expect(location.length, "B".length); |
| 259 } |
| 230 expect(element.parameters, "(int p)"); | 260 expect(element.parameters, "(int p)"); |
| 231 expect(element.returnType, isNull); | 261 expect(element.returnType, isNull); |
| 232 } | 262 } |
| 233 } | 263 } |
| 234 }); | 264 }); |
| 235 } | 265 } |
| 236 | 266 |
| 237 test_localFunctions() { | 267 test_localFunctions() { |
| 238 addTestFile(''' | 268 addTestFile(''' |
| 239 class A { | 269 class A { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 254 return prepareOutline(() { | 284 return prepareOutline(() { |
| 255 Outline unitOutline = outline; | 285 Outline unitOutline = outline; |
| 256 List<Outline> topOutlines = unitOutline.children; | 286 List<Outline> topOutlines = unitOutline.children; |
| 257 expect(topOutlines, hasLength(2)); | 287 expect(topOutlines, hasLength(2)); |
| 258 // A | 288 // A |
| 259 { | 289 { |
| 260 Outline outline_A = topOutlines[0]; | 290 Outline outline_A = topOutlines[0]; |
| 261 Element element_A = outline_A.element; | 291 Element element_A = outline_A.element; |
| 262 expect(element_A.kind, ElementKind.CLASS); | 292 expect(element_A.kind, ElementKind.CLASS); |
| 263 expect(element_A.name, "A"); | 293 expect(element_A.name, "A"); |
| 264 expect(element_A.offset, testCode.indexOf("A {")); | 294 { |
| 265 expect(element_A.length, "A".length); | 295 Location location = element_A.location; |
| 296 expect(location.offset, testCode.indexOf("A {")); |
| 297 expect(location.length, "A".length); |
| 298 } |
| 266 expect(element_A.parameters, null); | 299 expect(element_A.parameters, null); |
| 267 expect(element_A.returnType, null); | 300 expect(element_A.returnType, null); |
| 268 // A children | 301 // A children |
| 269 List<Outline> outlines_A = outline_A.children; | 302 List<Outline> outlines_A = outline_A.children; |
| 270 expect(outlines_A, hasLength(2)); | 303 expect(outlines_A, hasLength(2)); |
| 271 { | 304 { |
| 272 Outline constructorOutline = outlines_A[0]; | 305 Outline constructorOutline = outlines_A[0]; |
| 273 Element constructorElement = constructorOutline.element; | 306 Element constructorElement = constructorOutline.element; |
| 274 expect(constructorElement.kind, ElementKind.CONSTRUCTOR); | 307 expect(constructorElement.kind, ElementKind.CONSTRUCTOR); |
| 275 expect(constructorElement.name, "A"); | 308 expect(constructorElement.name, "A"); |
| 276 expect(constructorElement.offset, testCode.indexOf("A() {")); | 309 { |
| 277 expect(constructorElement.length, "A".length); | 310 Location location = constructorElement.location; |
| 311 expect(location.offset, testCode.indexOf("A() {")); |
| 312 expect(location.length, "A".length); |
| 313 } |
| 278 expect(constructorElement.parameters, "()"); | 314 expect(constructorElement.parameters, "()"); |
| 279 expect(constructorElement.returnType, isNull); | 315 expect(constructorElement.returnType, isNull); |
| 280 // local function | 316 // local function |
| 281 List<Outline> outlines_constructor = constructorOutline.children; | 317 List<Outline> outlines_constructor = constructorOutline.children; |
| 282 expect(outlines_constructor, hasLength(1)); | 318 expect(outlines_constructor, hasLength(1)); |
| 283 { | 319 { |
| 284 Outline outline = outlines_constructor[0]; | 320 Outline outline = outlines_constructor[0]; |
| 285 Element element = outline.element; | 321 Element element = outline.element; |
| 286 expect(element.kind, ElementKind.FUNCTION); | 322 expect(element.kind, ElementKind.FUNCTION); |
| 287 expect(element.name, "local_A"); | 323 expect(element.name, "local_A"); |
| 288 expect(element.offset, testCode.indexOf("local_A() {}")); | 324 { |
| 289 expect(element.length, "local_A".length); | 325 Location location = element.location; |
| 326 expect(location.offset, testCode.indexOf("local_A() {}")); |
| 327 expect(location.length, "local_A".length); |
| 328 } |
| 290 expect(element.parameters, "()"); | 329 expect(element.parameters, "()"); |
| 291 expect(element.returnType, "int"); | 330 expect(element.returnType, "int"); |
| 292 } | 331 } |
| 293 } | 332 } |
| 294 { | 333 { |
| 295 Outline outline_m = outlines_A[1]; | 334 Outline outline_m = outlines_A[1]; |
| 296 Element element_m = outline_m.element; | 335 Element element_m = outline_m.element; |
| 297 expect(element_m.kind, ElementKind.METHOD); | 336 expect(element_m.kind, ElementKind.METHOD); |
| 298 expect(element_m.name, "m"); | 337 expect(element_m.name, "m"); |
| 299 expect(element_m.offset, testCode.indexOf("m() {")); | 338 { |
| 300 expect(element_m.length, "m".length); | 339 Location location = element_m.location; |
| 340 expect(location.offset, testCode.indexOf("m() {")); |
| 341 expect(location.length, "m".length); |
| 342 } |
| 301 expect(element_m.parameters, "()"); | 343 expect(element_m.parameters, "()"); |
| 302 expect(element_m.returnType, ""); | 344 expect(element_m.returnType, ""); |
| 303 // local function | 345 // local function |
| 304 List<Outline> methodChildren = outline_m.children; | 346 List<Outline> methodChildren = outline_m.children; |
| 305 expect(methodChildren, hasLength(1)); | 347 expect(methodChildren, hasLength(1)); |
| 306 { | 348 { |
| 307 Outline outline = methodChildren[0]; | 349 Outline outline = methodChildren[0]; |
| 308 Element element = outline.element; | 350 Element element = outline.element; |
| 309 expect(element.kind, ElementKind.FUNCTION); | 351 expect(element.kind, ElementKind.FUNCTION); |
| 310 expect(element.name, "local_m"); | 352 expect(element.name, "local_m"); |
| 311 expect(element.offset, testCode.indexOf("local_m() {}")); | 353 { |
| 312 expect(element.length, "local_m".length); | 354 Location location = element.location; |
| 355 expect(location.offset, testCode.indexOf("local_m() {}")); |
| 356 expect(location.length, "local_m".length); |
| 357 } |
| 313 expect(element.parameters, "()"); | 358 expect(element.parameters, "()"); |
| 314 expect(element.returnType, ""); | 359 expect(element.returnType, ""); |
| 315 } | 360 } |
| 316 } | 361 } |
| 317 } | 362 } |
| 318 // f() | 363 // f() |
| 319 { | 364 { |
| 320 Outline outline_f = topOutlines[1]; | 365 Outline outline_f = topOutlines[1]; |
| 321 Element element_f = outline_f.element; | 366 Element element_f = outline_f.element; |
| 322 expect(element_f.kind, ElementKind.FUNCTION); | 367 expect(element_f.kind, ElementKind.FUNCTION); |
| 323 expect(element_f.name, "f"); | 368 expect(element_f.name, "f"); |
| 324 expect(element_f.offset, testCode.indexOf("f() {")); | 369 { |
| 325 expect(element_f.length, "f".length); | 370 Location location = element_f.location; |
| 371 expect(location.offset, testCode.indexOf("f() {")); |
| 372 expect(location.length, "f".length); |
| 373 } |
| 326 expect(element_f.parameters, "()"); | 374 expect(element_f.parameters, "()"); |
| 327 expect(element_f.returnType, ""); | 375 expect(element_f.returnType, ""); |
| 328 // f() children | 376 // f() children |
| 329 List<Outline> outlines_f = outline_f.children; | 377 List<Outline> outlines_f = outline_f.children; |
| 330 expect(outlines_f, hasLength(2)); | 378 expect(outlines_f, hasLength(2)); |
| 331 { | 379 { |
| 332 Outline outline_f1 = outlines_f[0]; | 380 Outline outline_f1 = outlines_f[0]; |
| 333 Element element_f1 = outline_f1.element; | 381 Element element_f1 = outline_f1.element; |
| 334 expect(element_f1.kind, ElementKind.FUNCTION); | 382 expect(element_f1.kind, ElementKind.FUNCTION); |
| 335 expect(element_f1.name, "local_f1"); | 383 expect(element_f1.name, "local_f1"); |
| 336 expect(element_f1.offset, testCode.indexOf("local_f1(int i) {}")); | 384 { |
| 337 expect(element_f1.length, "local_f1".length); | 385 Location location = element_f1.location; |
| 386 expect(location.offset, testCode.indexOf("local_f1(int i) {}")); |
| 387 expect(location.length, "local_f1".length); |
| 388 } |
| 338 expect(element_f1.parameters, "(int i)"); | 389 expect(element_f1.parameters, "(int i)"); |
| 339 expect(element_f1.returnType, ""); | 390 expect(element_f1.returnType, ""); |
| 340 } | 391 } |
| 341 { | 392 { |
| 342 Outline outline_f2 = outlines_f[1]; | 393 Outline outline_f2 = outlines_f[1]; |
| 343 Element element_f2 = outline_f2.element; | 394 Element element_f2 = outline_f2.element; |
| 344 expect(element_f2.kind, ElementKind.FUNCTION); | 395 expect(element_f2.kind, ElementKind.FUNCTION); |
| 345 expect(element_f2.name, "local_f2"); | 396 expect(element_f2.name, "local_f2"); |
| 346 expect(element_f2.offset, testCode.indexOf("local_f2(String s) {")); | 397 { |
| 347 expect(element_f2.length, "local_f2".length); | 398 Location location = element_f2.location; |
| 399 expect(location.offset, testCode.indexOf("local_f2(String s) {")); |
| 400 expect(location.length, "local_f2".length); |
| 401 } |
| 348 expect(element_f2.parameters, "(String s)"); | 402 expect(element_f2.parameters, "(String s)"); |
| 349 expect(element_f2.returnType, ""); | 403 expect(element_f2.returnType, ""); |
| 350 // local_f2() local function | 404 // local_f2() local function |
| 351 List<Outline> outlines_f2 = outline_f2.children; | 405 List<Outline> outlines_f2 = outline_f2.children; |
| 352 expect(outlines_f2, hasLength(1)); | 406 expect(outlines_f2, hasLength(1)); |
| 353 { | 407 { |
| 354 Outline outline_f21 = outlines_f2[0]; | 408 Outline outline_f21 = outlines_f2[0]; |
| 355 Element element_f21 = outline_f21.element; | 409 Element element_f21 = outline_f21.element; |
| 356 expect(element_f21.kind, ElementKind.FUNCTION); | 410 expect(element_f21.kind, ElementKind.FUNCTION); |
| 357 expect(element_f21.name, "local_f21"); | 411 expect(element_f21.name, "local_f21"); |
| 358 expect(element_f21.offset, testCode.indexOf("local_f21(int p) {")); | 412 { |
| 359 expect(element_f21.length, "local_f21".length); | 413 Location location = element_f21.location; |
| 414 expect(location.offset, testCode.indexOf("local_f21(int p) {")); |
| 415 expect(location.length, "local_f21".length); |
| 416 } |
| 360 expect(element_f21.parameters, "(int p)"); | 417 expect(element_f21.parameters, "(int p)"); |
| 361 expect(element_f21.returnType, ""); | 418 expect(element_f21.returnType, ""); |
| 362 } | 419 } |
| 363 } | 420 } |
| 364 } | 421 } |
| 365 }); | 422 }); |
| 366 } | 423 } |
| 367 | 424 |
| 368 test_sourceRange_inClass() { | 425 test_sourceRange_inClass() { |
| 369 addTestFile(''' | 426 addTestFile(''' |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 return prepareOutline(() { | 647 return prepareOutline(() { |
| 591 Outline unitOutline = outline; | 648 Outline unitOutline = outline; |
| 592 List<Outline> topOutlines = unitOutline.children; | 649 List<Outline> topOutlines = unitOutline.children; |
| 593 expect(topOutlines, hasLength(9)); | 650 expect(topOutlines, hasLength(9)); |
| 594 // FTA | 651 // FTA |
| 595 { | 652 { |
| 596 Outline outline = topOutlines[0]; | 653 Outline outline = topOutlines[0]; |
| 597 Element element = outline.element; | 654 Element element = outline.element; |
| 598 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); | 655 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); |
| 599 expect(element.name, "FTA"); | 656 expect(element.name, "FTA"); |
| 600 expect(element.offset, testCode.indexOf("FTA(")); | 657 { |
| 601 expect(element.length, "FTA".length); | 658 Location location = element.location; |
| 659 expect(location.offset, testCode.indexOf("FTA(")); |
| 660 expect(location.length, "FTA".length); |
| 661 } |
| 602 expect(element.parameters, "(int i, String s)"); | 662 expect(element.parameters, "(int i, String s)"); |
| 603 expect(element.returnType, "String"); | 663 expect(element.returnType, "String"); |
| 604 } | 664 } |
| 605 // FTB | 665 // FTB |
| 606 { | 666 { |
| 607 Outline outline = topOutlines[1]; | 667 Outline outline = topOutlines[1]; |
| 608 Element element = outline.element; | 668 Element element = outline.element; |
| 609 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); | 669 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); |
| 610 expect(element.name, "FTB"); | 670 expect(element.name, "FTB"); |
| 611 expect(element.offset, testCode.indexOf("FTB(")); | 671 { |
| 612 expect(element.length, "FTB".length); | 672 Location location = element.location; |
| 673 expect(location.offset, testCode.indexOf("FTB(")); |
| 674 expect(location.length, "FTB".length); |
| 675 } |
| 613 expect(element.parameters, "(int p)"); | 676 expect(element.parameters, "(int p)"); |
| 614 expect(element.returnType, ""); | 677 expect(element.returnType, ""); |
| 615 } | 678 } |
| 616 // CTA | 679 // CTA |
| 617 { | 680 { |
| 618 Outline outline = topOutlines[4]; | 681 Outline outline = topOutlines[4]; |
| 619 Element element = outline.element; | 682 Element element = outline.element; |
| 620 expect(element.kind, ElementKind.CLASS_TYPE_ALIAS); | 683 expect(element.kind, ElementKind.CLASS_TYPE_ALIAS); |
| 621 expect(element.name, "CTA"); | 684 expect(element.name, "CTA"); |
| 622 expect(element.offset, testCode.indexOf("CTA =")); | 685 { |
| 623 expect(element.length, "CTA".length); | 686 Location location = element.location; |
| 687 expect(location.offset, testCode.indexOf("CTA =")); |
| 688 expect(location.length, "CTA".length); |
| 689 } |
| 624 expect(element.parameters, isNull); | 690 expect(element.parameters, isNull); |
| 625 expect(element.returnType, isNull); | 691 expect(element.returnType, isNull); |
| 626 } | 692 } |
| 627 // fA | 693 // fA |
| 628 { | 694 { |
| 629 Outline outline = topOutlines[5]; | 695 Outline outline = topOutlines[5]; |
| 630 Element element = outline.element; | 696 Element element = outline.element; |
| 631 expect(element.kind, ElementKind.FUNCTION); | 697 expect(element.kind, ElementKind.FUNCTION); |
| 632 expect(element.name, "fA"); | 698 expect(element.name, "fA"); |
| 633 expect(element.offset, testCode.indexOf("fA(")); | 699 { |
| 634 expect(element.length, "fA".length); | 700 Location location = element.location; |
| 701 expect(location.offset, testCode.indexOf("fA(")); |
| 702 expect(location.length, "fA".length); |
| 703 } |
| 635 expect(element.parameters, "(int i, String s)"); | 704 expect(element.parameters, "(int i, String s)"); |
| 636 expect(element.returnType, "String"); | 705 expect(element.returnType, "String"); |
| 637 } | 706 } |
| 638 // fB | 707 // fB |
| 639 { | 708 { |
| 640 Outline outline = topOutlines[6]; | 709 Outline outline = topOutlines[6]; |
| 641 Element element = outline.element; | 710 Element element = outline.element; |
| 642 expect(element.kind, ElementKind.FUNCTION); | 711 expect(element.kind, ElementKind.FUNCTION); |
| 643 expect(element.name, "fB"); | 712 expect(element.name, "fB"); |
| 644 expect(element.offset, testCode.indexOf("fB(")); | 713 { |
| 645 expect(element.length, "fB".length); | 714 Location location = element.location; |
| 715 expect(location.offset, testCode.indexOf("fB(")); |
| 716 expect(location.length, "fB".length); |
| 717 } |
| 646 expect(element.parameters, "(int p)"); | 718 expect(element.parameters, "(int p)"); |
| 647 expect(element.returnType, ""); | 719 expect(element.returnType, ""); |
| 648 } | 720 } |
| 649 // propA | 721 // propA |
| 650 { | 722 { |
| 651 Outline outline = topOutlines[7]; | 723 Outline outline = topOutlines[7]; |
| 652 Element element = outline.element; | 724 Element element = outline.element; |
| 653 expect(element.kind, ElementKind.GETTER); | 725 expect(element.kind, ElementKind.GETTER); |
| 654 expect(element.name, "propA"); | 726 expect(element.name, "propA"); |
| 655 expect(element.offset, testCode.indexOf("propA => null;")); | 727 { |
| 656 expect(element.length, "propA".length); | 728 Location location = element.location; |
| 729 expect(element.location.offset, testCode.indexOf("propA => null;")); |
| 730 expect(element.location.length, "propA".length); |
| 731 } |
| 657 expect(element.parameters, ""); | 732 expect(element.parameters, ""); |
| 658 expect(element.returnType, "String"); | 733 expect(element.returnType, "String"); |
| 659 } | 734 } |
| 660 // propB | 735 // propB |
| 661 { | 736 { |
| 662 Outline outline = topOutlines[8]; | 737 Outline outline = topOutlines[8]; |
| 663 Element element = outline.element; | 738 Element element = outline.element; |
| 664 expect(element.kind, ElementKind.SETTER); | 739 expect(element.kind, ElementKind.SETTER); |
| 665 expect(element.name, "propB"); | 740 expect(element.name, "propB"); |
| 666 expect(element.offset, testCode.indexOf("propB(int v) {}")); | 741 { |
| 667 expect(element.length, "propB".length); | 742 Location location = element.location; |
| 743 expect(location.offset, testCode.indexOf("propB(int v) {}")); |
| 744 expect(location.length, "propB".length); |
| 745 } |
| 668 expect(element.parameters, "(int v)"); | 746 expect(element.parameters, "(int v)"); |
| 669 expect(element.returnType, ""); | 747 expect(element.returnType, ""); |
| 670 } | 748 } |
| 671 }); | 749 }); |
| 672 } | 750 } |
| 673 } | 751 } |
| OLD | NEW |