| 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.services.completion.util; | 5 library test.services.completion.util; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 371 |
| 372 CompletionSuggestion assertSuggestImportedClass(String name, | 372 CompletionSuggestion assertSuggestImportedClass(String name, |
| 373 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { | 373 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { |
| 374 if (computer is ImportedComputer) { | 374 if (computer is ImportedComputer) { |
| 375 return assertSuggestClass(name, relevance); | 375 return assertSuggestClass(name, relevance); |
| 376 } else { | 376 } else { |
| 377 return assertNotSuggested(name); | 377 return assertNotSuggested(name); |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 | 380 |
| 381 CompletionSuggestion assertSuggestInvocationGetter(String name, String returnT
ype, | 381 CompletionSuggestion assertSuggestInvocationGetter(String name, |
| 382 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { | 382 String returnType, [CompletionRelevance relevance = |
| 383 CompletionRelevance.DEFAULT]) { |
| 383 if (computer is InvocationComputer) { | 384 if (computer is InvocationComputer) { |
| 384 return assertSuggestGetter(name, returnType, relevance); | 385 return assertSuggestGetter(name, returnType, relevance); |
| 385 } else { | 386 } else { |
| 386 return null; | 387 return null; |
| 387 } | 388 } |
| 388 } | 389 } |
| 389 | 390 |
| 390 CompletionSuggestion assertSuggestLocalClass(String name, | 391 CompletionSuggestion assertSuggestLocalClass(String name, |
| 391 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { | 392 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { |
| 392 if (computer is LocalComputer) { | 393 if (computer is LocalComputer) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 computeFast(); | 499 computeFast(); |
| 499 return computeFull(true).then((_) { | 500 return computeFull(true).then((_) { |
| 500 assertNotSuggested('b'); | 501 assertNotSuggested('b'); |
| 501 assertNotSuggested('_c'); | 502 assertNotSuggested('_c'); |
| 502 assertSuggestLocalVariable('a', 'A'); | 503 assertSuggestLocalVariable('a', 'A'); |
| 503 assertSuggestLocalClass('A'); | 504 assertSuggestLocalClass('A'); |
| 504 assertSuggestLocalClass('X'); | 505 assertSuggestLocalClass('X'); |
| 505 assertSuggestImportedClass('Object'); | 506 assertSuggestImportedClass('Object'); |
| 506 }); | 507 }); |
| 507 } | 508 } |
| 509 |
| 510 test_IsExpression_type() { |
| 511 // SimpleIdentifier TypeName IsExpression IfStatement |
| 512 addSource('/testB.dart', ''' |
| 513 lib B; |
| 514 foo() { } |
| 515 class X {X.c(); X._d(); z() {}}'''); |
| 516 addTestSource(''' |
| 517 import "/testB.dart"; |
| 518 class Y {Y.c(); Y._d(); z() {}} |
| 519 main() {var x; if (x is ^) { }}'''); |
| 520 computeFast(); |
| 521 return computeFull(true).then((_) { |
| 522 assertSuggestImportedClass('X'); |
| 523 assertSuggestLocalClass('Y'); |
| 524 assertNotSuggested('x'); |
| 525 assertNotSuggested('main'); |
| 526 assertNotSuggested('foo'); |
| 527 }); |
| 528 } |
| 508 } | 529 } |
| OLD | NEW |