| 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 | 9 import 'package:analysis_server/src/protocol.dart' as protocol |
| 10 show Element, ElementKind; | 10 show Element, ElementKind; |
| (...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2619 expect(request.replacementLength, 0); | 2619 expect(request.replacementLength, 0); |
| 2620 assertSuggestLocalFunction('foo', null); | 2620 assertSuggestLocalFunction('foo', null); |
| 2621 assertSuggestLocalFunction('bar', 'void'); | 2621 assertSuggestLocalFunction('bar', 'void'); |
| 2622 assertSuggestLocalMethod('a', 'A', 'Z'); | 2622 assertSuggestLocalMethod('a', 'A', 'Z'); |
| 2623 assertSuggestParameter('x', 'X'); | 2623 assertSuggestParameter('x', 'X'); |
| 2624 assertSuggestParameter('y', 'int'); | 2624 assertSuggestParameter('y', 'int'); |
| 2625 assertSuggestImportedClass('String'); | 2625 assertSuggestImportedClass('String'); |
| 2626 }); | 2626 }); |
| 2627 } | 2627 } |
| 2628 | 2628 |
| 2629 test_MethodDeclaration_returnType() { |
| 2630 // ClassDeclaration CompilationUnit |
| 2631 addSource('/testA.dart', ''' |
| 2632 int T1; |
| 2633 F1() { } |
| 2634 typedef D1(); |
| 2635 class C1 {C1(this.x) { } int x;}'''); |
| 2636 addTestSource(''' |
| 2637 import "/testA.dart"; |
| 2638 int T2; |
| 2639 F2() { } |
| 2640 typedef D2(); |
| 2641 class C2 {^ zoo(z) { } String name; }'''); |
| 2642 computeFast(); |
| 2643 return computeFull((bool result) { |
| 2644 expect(request.replacementOffset, completionOffset); |
| 2645 expect(request.replacementLength, 0); |
| 2646 assertSuggestImportedClass('Object'); |
| 2647 assertNotSuggested('T1'); |
| 2648 assertNotSuggested('F1'); |
| 2649 assertSuggestImportedFunctionTypeAlias('D1', null); |
| 2650 assertSuggestImportedClass('C1'); |
| 2651 assertNotSuggested('T2'); |
| 2652 assertNotSuggested('F2'); |
| 2653 assertSuggestLocalFunctionTypeAlias('D2', null); |
| 2654 assertSuggestLocalClass('C2'); |
| 2655 assertNotSuggested('name'); |
| 2656 }); |
| 2657 } |
| 2658 |
| 2659 test_MethodDeclaration_returnType_afterComment() { |
| 2660 // ClassDeclaration CompilationUnit |
| 2661 addSource('/testA.dart', ''' |
| 2662 int T1; |
| 2663 F1() { } |
| 2664 typedef D1(); |
| 2665 class C1 {C1(this.x) { } int x;}'''); |
| 2666 addTestSource(''' |
| 2667 import "/testA.dart"; |
| 2668 int T2; |
| 2669 F2() { } |
| 2670 typedef D2(); |
| 2671 class C2 {/* */ ^ zoo(z) { } String name; }'''); |
| 2672 computeFast(); |
| 2673 return computeFull((bool result) { |
| 2674 expect(request.replacementOffset, completionOffset); |
| 2675 expect(request.replacementLength, 0); |
| 2676 assertSuggestImportedClass('Object'); |
| 2677 assertNotSuggested('T1'); |
| 2678 assertNotSuggested('F1'); |
| 2679 assertSuggestImportedFunctionTypeAlias('D1', null); |
| 2680 assertSuggestImportedClass('C1'); |
| 2681 assertNotSuggested('T2'); |
| 2682 assertNotSuggested('F2'); |
| 2683 assertSuggestLocalFunctionTypeAlias('D2', null); |
| 2684 assertSuggestLocalClass('C2'); |
| 2685 assertNotSuggested('name'); |
| 2686 }); |
| 2687 } |
| 2688 |
| 2689 test_MethodDeclaration_returnType_afterComment2() { |
| 2690 // MethodDeclaration ClassDeclaration CompilationUnit |
| 2691 addSource('/testA.dart', ''' |
| 2692 int T1; |
| 2693 F1() { } |
| 2694 typedef D1(); |
| 2695 class C1 {C1(this.x) { } int x;}'''); |
| 2696 addTestSource(''' |
| 2697 import "/testA.dart"; |
| 2698 int T2; |
| 2699 F2() { } |
| 2700 typedef D2(); |
| 2701 class C2 {/** */ ^ zoo(z) { } String name; }'''); |
| 2702 computeFast(); |
| 2703 return computeFull((bool result) { |
| 2704 expect(request.replacementOffset, completionOffset); |
| 2705 expect(request.replacementLength, 0); |
| 2706 assertSuggestImportedClass('Object'); |
| 2707 assertNotSuggested('T1'); |
| 2708 assertNotSuggested('F1'); |
| 2709 assertSuggestImportedFunctionTypeAlias('D1', null); |
| 2710 assertSuggestImportedClass('C1'); |
| 2711 assertNotSuggested('T2'); |
| 2712 assertNotSuggested('F2'); |
| 2713 assertSuggestLocalFunctionTypeAlias('D2', null); |
| 2714 assertSuggestLocalClass('C2'); |
| 2715 assertNotSuggested('name'); |
| 2716 }); |
| 2717 } |
| 2718 |
| 2719 test_MethodDeclaration_returnType_afterComment3() { |
| 2720 // MethodDeclaration ClassDeclaration CompilationUnit |
| 2721 addSource('/testA.dart', ''' |
| 2722 int T1; |
| 2723 F1() { } |
| 2724 typedef D1(); |
| 2725 class C1 {C1(this.x) { } int x;}'''); |
| 2726 addTestSource(''' |
| 2727 import "/testA.dart"; |
| 2728 int T2; |
| 2729 F2() { } |
| 2730 typedef D2(); |
| 2731 class C2 { |
| 2732 /// some dartdoc |
| 2733 ^ zoo(z) { } String name; }'''); |
| 2734 computeFast(); |
| 2735 return computeFull((bool result) { |
| 2736 expect(request.replacementOffset, completionOffset); |
| 2737 expect(request.replacementLength, 0); |
| 2738 assertSuggestImportedClass('Object'); |
| 2739 assertNotSuggested('T1'); |
| 2740 assertNotSuggested('F1'); |
| 2741 assertSuggestImportedFunctionTypeAlias('D1', null); |
| 2742 assertSuggestImportedClass('C1'); |
| 2743 assertNotSuggested('T2'); |
| 2744 assertNotSuggested('F2'); |
| 2745 assertSuggestLocalFunctionTypeAlias('D2', null); |
| 2746 assertSuggestLocalClass('C2'); |
| 2747 assertNotSuggested('name'); |
| 2748 }); |
| 2749 } |
| 2750 |
| 2629 test_MethodInvocation_no_semicolon() { | 2751 test_MethodInvocation_no_semicolon() { |
| 2630 // MethodInvocation ExpressionStatement Block | 2752 // MethodInvocation ExpressionStatement Block |
| 2631 addTestSource(''' | 2753 addTestSource(''' |
| 2632 main() { } | 2754 main() { } |
| 2633 class I {X get f => new A();get _g => new A();} | 2755 class I {X get f => new A();get _g => new A();} |
| 2634 class A implements I { | 2756 class A implements I { |
| 2635 var b; X _c; | 2757 var b; X _c; |
| 2636 X get d => new A();get _e => new A(); | 2758 X get d => new A();get _e => new A(); |
| 2637 // no semicolon between completion point and next statement | 2759 // no semicolon between completion point and next statement |
| 2638 set s1(I x) {} set _s2(I x) {x.^ m(null);} | 2760 set s1(I x) {} set _s2(I x) {x.^ m(null);} |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3265 assertNotSuggested('bar2'); | 3387 assertNotSuggested('bar2'); |
| 3266 assertNotSuggested('_B'); | 3388 assertNotSuggested('_B'); |
| 3267 assertSuggestLocalClass('Y'); | 3389 assertSuggestLocalClass('Y'); |
| 3268 assertSuggestLocalClass('C'); | 3390 assertSuggestLocalClass('C'); |
| 3269 assertSuggestLocalVariable('f', null); | 3391 assertSuggestLocalVariable('f', null); |
| 3270 assertNotSuggested('x'); | 3392 assertNotSuggested('x'); |
| 3271 assertNotSuggested('e'); | 3393 assertNotSuggested('e'); |
| 3272 }); | 3394 }); |
| 3273 } | 3395 } |
| 3274 } | 3396 } |
| OLD | NEW |