| 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 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 | 2075 |
| 2076 test_IfStatement_invocation() { | 2076 test_IfStatement_invocation() { |
| 2077 // SimpleIdentifier PrefixIdentifier IfStatement | 2077 // SimpleIdentifier PrefixIdentifier IfStatement |
| 2078 addTestSource(''' | 2078 addTestSource(''' |
| 2079 main() {var a; if (a.^) something}'''); | 2079 main() {var a; if (a.^) something}'''); |
| 2080 computeFast(); | 2080 computeFast(); |
| 2081 return computeFull((bool result) { | 2081 return computeFull((bool result) { |
| 2082 expect(request.replacementOffset, completionOffset); | 2082 expect(request.replacementOffset, completionOffset); |
| 2083 expect(request.replacementLength, 0); | 2083 expect(request.replacementLength, 0); |
| 2084 assertSuggestInvocationMethod('toString', 'Object', 'String'); | 2084 assertSuggestInvocationMethod('toString', 'Object', 'String'); |
| 2085 //TODO (danrubel) type for '_c' should be 'X' not null | |
| 2086 assertNotSuggested('Object'); | 2085 assertNotSuggested('Object'); |
| 2087 assertNotSuggested('A'); | 2086 assertNotSuggested('A'); |
| 2088 assertNotSuggested('=='); | 2087 assertNotSuggested('=='); |
| 2089 }); | 2088 }); |
| 2090 } | 2089 } |
| 2091 | 2090 |
| 2092 test_ImportDirective_dart() { | 2091 test_ImportDirective_dart() { |
| 2093 // SimpleStringLiteral ImportDirective | 2092 // SimpleStringLiteral ImportDirective |
| 2094 addTestSource(''' | 2093 addTestSource(''' |
| 2095 import "dart^"; | 2094 import "dart^"; |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2790 addTestSource('class A {String x; int get foo {x.^ int y = 0;}'); | 2789 addTestSource('class A {String x; int get foo {x.^ int y = 0;}'); |
| 2791 computeFast(); | 2790 computeFast(); |
| 2792 return computeFull((bool result) { | 2791 return computeFull((bool result) { |
| 2793 expect(request.replacementOffset, completionOffset); | 2792 expect(request.replacementOffset, completionOffset); |
| 2794 expect(request.replacementLength, 0); | 2793 expect(request.replacementLength, 0); |
| 2795 assertSuggestInvocationGetter('isEmpty', 'bool'); | 2794 assertSuggestInvocationGetter('isEmpty', 'bool'); |
| 2796 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); | 2795 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); |
| 2797 }); | 2796 }); |
| 2798 } | 2797 } |
| 2799 | 2798 |
| 2799 test_PrefixedIdentifier_trailingStmt_const() { |
| 2800 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2801 addTestSource('const String g = "hello"; f() {g.^ int y = 0;}'); |
| 2802 computeFast(); |
| 2803 return computeFull((bool result) { |
| 2804 assertSuggestInvocationGetter('length', 'int'); |
| 2805 }); |
| 2806 } |
| 2807 |
| 2808 test_PrefixedIdentifier_trailingStmt_field() { |
| 2809 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2810 addTestSource('class A {String g; f() {g.^ int y = 0;}}'); |
| 2811 computeFast(); |
| 2812 return computeFull((bool result) { |
| 2813 assertSuggestInvocationGetter('length', 'int'); |
| 2814 }); |
| 2815 } |
| 2816 |
| 2817 test_PrefixedIdentifier_trailingStmt_function() { |
| 2818 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2819 addTestSource('String g() => "one"; f() {g.^ int y = 0;}'); |
| 2820 computeFast(); |
| 2821 return computeFull((bool result) { |
| 2822 assertSuggestInvocationGetter('length', 'int'); |
| 2823 }); |
| 2824 } |
| 2825 |
| 2826 test_PrefixedIdentifier_trailingStmt_functionTypeAlias() { |
| 2827 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2828 addTestSource('typedef String g(); f() {g.^ int y = 0;}'); |
| 2829 computeFast(); |
| 2830 return computeFull((bool result) { |
| 2831 assertSuggestInvocationGetter('length', 'int'); |
| 2832 }); |
| 2833 } |
| 2834 |
| 2835 test_PrefixedIdentifier_trailingStmt_getter() { |
| 2836 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2837 addTestSource('String get g => "one"; f() {g.^ int y = 0;}'); |
| 2838 computeFast(); |
| 2839 return computeFull((bool result) { |
| 2840 assertSuggestInvocationGetter('length', 'int'); |
| 2841 }); |
| 2842 } |
| 2843 |
| 2844 test_PrefixedIdentifier_trailingStmt_local_typed() { |
| 2845 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2846 addTestSource('f() {String g; g.^ int y = 0;}'); |
| 2847 computeFast(); |
| 2848 return computeFull((bool result) { |
| 2849 assertSuggestInvocationGetter('length', 'int'); |
| 2850 }); |
| 2851 } |
| 2852 |
| 2853 test_PrefixedIdentifier_trailingStmt_local_untyped() { |
| 2854 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2855 addTestSource('f() {var g = "hello"; g.^ int y = 0;}'); |
| 2856 computeFast(); |
| 2857 return computeFull((bool result) { |
| 2858 assertSuggestInvocationGetter('length', 'int'); |
| 2859 }); |
| 2860 } |
| 2861 |
| 2862 test_PrefixedIdentifier_trailingStmt_method() { |
| 2863 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2864 addTestSource('class A {String g() {}; f() {g.^ int y = 0;}}'); |
| 2865 computeFast(); |
| 2866 return computeFull((bool result) { |
| 2867 assertSuggestInvocationGetter('length', 'int'); |
| 2868 }); |
| 2869 } |
| 2870 |
| 2871 test_PrefixedIdentifier_trailingStmt_param() { |
| 2872 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2873 addTestSource('class A {f(String g) {g.^ int y = 0;}}'); |
| 2874 computeFast(); |
| 2875 return computeFull((bool result) { |
| 2876 assertSuggestInvocationGetter('length', 'int'); |
| 2877 }); |
| 2878 } |
| 2879 |
| 2880 test_PrefixedIdentifier_trailingStmt_param2() { |
| 2881 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2882 addTestSource('f(String g) {g.^ int y = 0;}'); |
| 2883 computeFast(); |
| 2884 return computeFull((bool result) { |
| 2885 assertSuggestInvocationGetter('length', 'int'); |
| 2886 }); |
| 2887 } |
| 2888 |
| 2889 test_PrefixedIdentifier_trailingStmt_topLevelVar() { |
| 2890 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2891 addTestSource('String g; f() {g.^ int y = 0;}'); |
| 2892 computeFast(); |
| 2893 return computeFull((bool result) { |
| 2894 assertSuggestInvocationGetter('length', 'int'); |
| 2895 }); |
| 2896 } |
| 2897 |
| 2800 test_PropertyAccess_expression() { | 2898 test_PropertyAccess_expression() { |
| 2801 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement | 2899 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement |
| 2802 addTestSource('class A {a() {"hello".to^String().length}}'); | 2900 addTestSource('class A {a() {"hello".to^String().length}}'); |
| 2803 computeFast(); | 2901 computeFast(); |
| 2804 return computeFull((bool result) { | 2902 return computeFull((bool result) { |
| 2805 expect(request.replacementOffset, completionOffset - 2); | 2903 expect(request.replacementOffset, completionOffset - 2); |
| 2806 expect(request.replacementLength, 8); | 2904 expect(request.replacementLength, 8); |
| 2807 assertSuggestInvocationGetter('length', 'int'); | 2905 assertSuggestInvocationGetter('length', 'int'); |
| 2808 assertNotSuggested('A'); | 2906 assertNotSuggested('A'); |
| 2809 assertNotSuggested('a'); | 2907 assertNotSuggested('a'); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2991 assertNotSuggested('bar2'); | 3089 assertNotSuggested('bar2'); |
| 2992 assertNotSuggested('_B'); | 3090 assertNotSuggested('_B'); |
| 2993 assertSuggestLocalClass('Y'); | 3091 assertSuggestLocalClass('Y'); |
| 2994 assertSuggestLocalClass('C'); | 3092 assertSuggestLocalClass('C'); |
| 2995 assertSuggestLocalVariable('f', null); | 3093 assertSuggestLocalVariable('f', null); |
| 2996 assertNotSuggested('x'); | 3094 assertNotSuggested('x'); |
| 2997 assertNotSuggested('e'); | 3095 assertNotSuggested('e'); |
| 2998 }); | 3096 }); |
| 2999 } | 3097 } |
| 3000 } | 3098 } |
| OLD | NEW |