| 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.navigation; | 5 library test.analysis.notification.navigation; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 311 |
| 312 test_instanceCreation_implicit() { | 312 test_instanceCreation_implicit() { |
| 313 addTestFile(''' | 313 addTestFile(''' |
| 314 class A { | 314 class A { |
| 315 } | 315 } |
| 316 main() { | 316 main() { |
| 317 new A(); | 317 new A(); |
| 318 } | 318 } |
| 319 '''); | 319 '''); |
| 320 return prepareNavigation().then((_) { | 320 return prepareNavigation().then((_) { |
| 321 findRegion(findOffset('new A'), 'new A'.length, true); | 321 { |
| 322 assertHasTarget('A {'); | 322 findRegion(findOffset('new A'), 'new'.length, true); |
| 323 assertHasTarget('A {'); |
| 324 } |
| 325 { |
| 326 findRegion(findOffset('A()'), 'A'.length, true); |
| 327 assertHasTarget('A {'); |
| 328 } |
| 323 }); | 329 }); |
| 324 } | 330 } |
| 325 | 331 |
| 332 test_instanceCreation_implicit_withTypeArgument() { |
| 333 addTestFile(''' |
| 334 class A {} |
| 335 class B<T> { |
| 336 } |
| 337 main() { |
| 338 new B<A>(); |
| 339 } |
| 340 '''); |
| 341 return prepareNavigation().then((_) { |
| 342 { |
| 343 findRegion(findOffset('new B'), 'new'.length, true); |
| 344 assertHasTarget('B<T> {'); |
| 345 } |
| 346 { |
| 347 findRegion(findOffset('A>();'), 'A'.length, true); |
| 348 assertHasTarget('A {'); |
| 349 } |
| 350 }); |
| 351 } |
| 352 |
| 326 test_instanceCreation_named() { | 353 test_instanceCreation_named() { |
| 327 addTestFile(''' | 354 addTestFile(''' |
| 328 class A { | 355 class A { |
| 329 A.named() {} | 356 A.named() {} |
| 330 } | 357 } |
| 331 main() { | 358 main() { |
| 332 new A.named(); | 359 new A.named(); |
| 333 } | 360 } |
| 334 '''); | 361 '''); |
| 335 return prepareNavigation().then((_) { | 362 return prepareNavigation().then((_) { |
| 336 { | 363 { |
| 337 findRegion(findOffset('new '), 'new'.length, true); | 364 findRegion(findOffset('new '), 'new'.length, true); |
| 338 assertHasTarget('named() {}'); | 365 assertHasTarget('named() {}'); |
| 339 } | 366 } |
| 340 { | 367 { |
| 341 findRegion(findOffset('A.named();'), 'A'.length, true); | 368 findRegion(findOffset('A.named();'), 'A'.length, true); |
| 342 assertHasTarget('A {'); | 369 assertHasTarget('A {'); |
| 343 } | 370 } |
| 344 { | 371 { |
| 345 findRegion(findOffset('.named();'), '.named'.length, true); | 372 findRegion(findOffset('.named();'), '.named'.length, true); |
| 346 assertHasTarget('named() {}'); | 373 assertHasTarget('named() {}'); |
| 347 } | 374 } |
| 348 }); | 375 }); |
| 349 } | 376 } |
| 350 | 377 |
| 378 test_instanceCreation_named_withTypeArgument() { |
| 379 addTestFile(''' |
| 380 class A {} |
| 381 class B<T> { |
| 382 A.named() {} |
| 383 } |
| 384 main() { |
| 385 new B<A>.named(); |
| 386 } |
| 387 '''); |
| 388 return prepareNavigation().then((_) { |
| 389 { |
| 390 findRegion(findOffset('new '), 'new'.length, true); |
| 391 assertHasTarget('named() {}'); |
| 392 } |
| 393 { |
| 394 findRegion(findOffset('B<A>.named();'), 'B'.length, true); |
| 395 assertHasTarget('B<T> {'); |
| 396 } |
| 397 { |
| 398 findRegion(findOffset('.named();'), '.named'.length, true); |
| 399 assertHasTarget('named() {}'); |
| 400 } |
| 401 { |
| 402 findRegion(findOffset('A>.named();'), 'A'.length, true); |
| 403 assertHasTarget('A {'); |
| 404 } |
| 405 }); |
| 406 } |
| 407 |
| 351 test_instanceCreation_unnamed() { | 408 test_instanceCreation_unnamed() { |
| 352 addTestFile(''' | 409 addTestFile(''' |
| 353 class A { | 410 class A { |
| 354 A() {} | 411 A() {} |
| 355 } | 412 } |
| 356 main() { | 413 main() { |
| 357 new A(); | 414 new A(); |
| 358 } | 415 } |
| 359 '''); | 416 '''); |
| 360 return prepareNavigation().then((_) { | 417 return prepareNavigation().then((_) { |
| 361 { | 418 { |
| 362 findRegion(findOffset('new '), 'new'.length, true); | 419 findRegion(findOffset('new '), 'new'.length, true); |
| 363 assertHasTarget('A() {}', 0); | 420 assertHasTarget('A() {}', 0); |
| 364 } | 421 } |
| 365 { | 422 { |
| 366 findRegion(findOffset('A();'), 'A'.length, true); | 423 findRegion(findOffset('A();'), 'A'.length, true); |
| 367 assertHasTarget('A {'); | 424 assertHasTarget('A {'); |
| 368 } | 425 } |
| 369 }); | 426 }); |
| 370 } | 427 } |
| 371 | 428 |
| 429 test_instanceCreation_unnamed_withTypeArgument() { |
| 430 addTestFile(''' |
| 431 class A {} |
| 432 class B<T> { |
| 433 B() {} |
| 434 } |
| 435 main() { |
| 436 new B<A>(); |
| 437 } |
| 438 '''); |
| 439 return prepareNavigation().then((_) { |
| 440 { |
| 441 findRegion(findOffset('new '), 'new'.length, true); |
| 442 assertHasTarget('B() {}', 0); |
| 443 } |
| 444 { |
| 445 findRegion(findOffset('B<A>();'), 'B'.length, true); |
| 446 assertHasTarget('B<T> {'); |
| 447 } |
| 448 { |
| 449 findRegion(findOffset('A>();'), 'A'.length, true); |
| 450 assertHasTarget('A {'); |
| 451 } |
| 452 }); |
| 453 } |
| 454 |
| 372 test_multiplyDefinedElement() { | 455 test_multiplyDefinedElement() { |
| 373 addFile('$projectPath/bin/libA.dart', 'library A; int TEST = 1;'); | 456 addFile('$projectPath/bin/libA.dart', 'library A; int TEST = 1;'); |
| 374 addFile('$projectPath/bin/libB.dart', 'library B; int TEST = 2;'); | 457 addFile('$projectPath/bin/libB.dart', 'library B; int TEST = 2;'); |
| 375 addTestFile(''' | 458 addTestFile(''' |
| 376 import 'libA.dart'; | 459 import 'libA.dart'; |
| 377 import 'libB.dart'; | 460 import 'libB.dart'; |
| 378 main() { | 461 main() { |
| 379 TEST; | 462 TEST; |
| 380 } | 463 } |
| 381 '''); | 464 '''); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 test_type_void() { | 635 test_type_void() { |
| 553 addTestFile(''' | 636 addTestFile(''' |
| 554 void main() { | 637 void main() { |
| 555 } | 638 } |
| 556 '''); | 639 '''); |
| 557 return prepareNavigation().then((_) { | 640 return prepareNavigation().then((_) { |
| 558 assertNoRegionAt('void'); | 641 assertNoRegionAt('void'); |
| 559 }); | 642 }); |
| 560 } | 643 } |
| 561 } | 644 } |
| OLD | NEW |