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.completion; | 5 library test.domain.completion; |
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/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 return getSuggestions().then((_) { | 463 return getSuggestions().then((_) { |
464 expect(replacementOffset, equals(completionOffset)); | 464 expect(replacementOffset, equals(completionOffset)); |
465 expect(replacementLength, equals(0)); | 465 expect(replacementLength, equals(0)); |
466 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); | 466 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); |
467 assertHasResult(CompletionSuggestionKind.INVOCATION, 'foo'); | 467 assertHasResult(CompletionSuggestionKind.INVOCATION, 'foo'); |
468 assertNoResult('HtmlElement'); | 468 assertNoResult('HtmlElement'); |
469 assertNoResult('test'); | 469 assertNoResult('test'); |
470 }); | 470 }); |
471 } | 471 } |
472 | 472 |
| 473 test_imports_prefixed2() { |
| 474 addTestFile(''' |
| 475 import 'dart:html' as foo; |
| 476 main() {foo.^} |
| 477 '''); |
| 478 return getSuggestions().then((_) { |
| 479 expect(replacementOffset, equals(completionOffset)); |
| 480 expect(replacementLength, equals(0)); |
| 481 assertHasResult(CompletionSuggestionKind.INVOCATION, 'HtmlElement'); |
| 482 assertNoResult('test'); |
| 483 }); |
| 484 } |
| 485 |
473 test_invocation() { | 486 test_invocation() { |
474 addTestFile('class A {b() {}} main() {A a; a.^}'); | 487 addTestFile('class A {b() {}} main() {A a; a.^}'); |
475 return getSuggestions().then((_) { | 488 return getSuggestions().then((_) { |
476 expect(replacementOffset, equals(completionOffset)); | 489 expect(replacementOffset, equals(completionOffset)); |
477 expect(replacementLength, equals(0)); | 490 expect(replacementLength, equals(0)); |
478 assertHasResult(CompletionSuggestionKind.INVOCATION, 'b'); | 491 assertHasResult(CompletionSuggestionKind.INVOCATION, 'b'); |
479 }); | 492 }); |
480 } | 493 } |
481 | 494 |
482 test_invocation_sdk_relevancy_off() { | 495 test_invocation_sdk_relevancy_off() { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 '''); | 638 '''); |
626 return getSuggestions().then((_) { | 639 return getSuggestions().then((_) { |
627 expect(replacementOffset, equals(completionOffset)); | 640 expect(replacementOffset, equals(completionOffset)); |
628 expect(replacementLength, equals(0)); | 641 expect(replacementLength, equals(0)); |
629 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); | 642 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); |
630 assertNoResult('HtmlElement'); | 643 assertNoResult('HtmlElement'); |
631 assertNoResult('test'); | 644 assertNoResult('test'); |
632 }); | 645 }); |
633 } | 646 } |
634 | 647 |
| 648 test_static() { |
| 649 addTestFile('class A {static b() {} c() {}} main() {A.^}'); |
| 650 return getSuggestions().then((_) { |
| 651 expect(replacementOffset, equals(completionOffset)); |
| 652 expect(replacementLength, equals(0)); |
| 653 assertHasResult(CompletionSuggestionKind.INVOCATION, 'b'); |
| 654 assertNoResult('c'); |
| 655 }); |
| 656 } |
| 657 |
635 test_topLevel() { | 658 test_topLevel() { |
636 addTestFile(''' | 659 addTestFile(''' |
637 typedef foo(); | 660 typedef foo(); |
638 var test = ''; | 661 var test = ''; |
639 main() {tes^t} | 662 main() {tes^t} |
640 '''); | 663 '''); |
641 return getSuggestions().then((_) { | 664 return getSuggestions().then((_) { |
642 expect(replacementOffset, equals(completionOffset - 3)); | 665 expect(replacementOffset, equals(completionOffset - 3)); |
643 expect(replacementLength, equals(4)); | 666 expect(replacementLength, equals(4)); |
644 // Suggestions based upon imported elements are partially filtered | 667 // Suggestions based upon imported elements are partially filtered |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 } | 869 } |
847 '''); | 870 '''); |
848 await waitForTasksFinished(); | 871 await waitForTasksFinished(); |
849 Request request = | 872 Request request = |
850 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); | 873 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); |
851 Response response = handler.handleRequest(request); | 874 Response response = handler.handleRequest(request); |
852 expect(response.error, isNotNull); | 875 expect(response.error, isNotNull); |
853 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | 876 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
854 } | 877 } |
855 } | 878 } |
OLD | NEW |