| 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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2799 addTestSource('class A {String x; int get foo {x.^ int y = 0;}'); | 2798 addTestSource('class A {String x; int get foo {x.^ int y = 0;}'); |
| 2800 computeFast(); | 2799 computeFast(); |
| 2801 return computeFull((bool result) { | 2800 return computeFull((bool result) { |
| 2802 expect(request.replacementOffset, completionOffset); | 2801 expect(request.replacementOffset, completionOffset); |
| 2803 expect(request.replacementLength, 0); | 2802 expect(request.replacementLength, 0); |
| 2804 assertSuggestInvocationGetter('isEmpty', 'bool'); | 2803 assertSuggestInvocationGetter('isEmpty', 'bool'); |
| 2805 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); | 2804 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); |
| 2806 }); | 2805 }); |
| 2807 } | 2806 } |
| 2808 | 2807 |
| 2808 test_PrefixedIdentifier_trailingStmt_const() { |
| 2809 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2810 addTestSource('const String g = "hello"; f() {g.^ int y = 0;}'); |
| 2811 computeFast(); |
| 2812 return computeFull((bool result) { |
| 2813 assertSuggestInvocationGetter('length', 'int'); |
| 2814 }); |
| 2815 } |
| 2816 |
| 2817 test_PrefixedIdentifier_trailingStmt_field() { |
| 2818 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2819 addTestSource('class A {String g; f() {g.^ int y = 0;}}'); |
| 2820 computeFast(); |
| 2821 return computeFull((bool result) { |
| 2822 assertSuggestInvocationGetter('length', 'int'); |
| 2823 }); |
| 2824 } |
| 2825 |
| 2826 test_PrefixedIdentifier_trailingStmt_function() { |
| 2827 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2828 addTestSource('String g() => "one"; f() {g.^ int y = 0;}'); |
| 2829 computeFast(); |
| 2830 return computeFull((bool result) { |
| 2831 assertSuggestInvocationGetter('length', 'int'); |
| 2832 }); |
| 2833 } |
| 2834 |
| 2835 test_PrefixedIdentifier_trailingStmt_functionTypeAlias() { |
| 2836 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2837 addTestSource('typedef String g(); f() {g.^ int y = 0;}'); |
| 2838 computeFast(); |
| 2839 return computeFull((bool result) { |
| 2840 assertSuggestInvocationGetter('length', 'int'); |
| 2841 }); |
| 2842 } |
| 2843 |
| 2844 test_PrefixedIdentifier_trailingStmt_getter() { |
| 2845 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2846 addTestSource('String get g => "one"; f() {g.^ int y = 0;}'); |
| 2847 computeFast(); |
| 2848 return computeFull((bool result) { |
| 2849 assertSuggestInvocationGetter('length', 'int'); |
| 2850 }); |
| 2851 } |
| 2852 |
| 2853 test_PrefixedIdentifier_trailingStmt_local_typed() { |
| 2854 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2855 addTestSource('f() {String g; g.^ int y = 0;}'); |
| 2856 computeFast(); |
| 2857 return computeFull((bool result) { |
| 2858 assertSuggestInvocationGetter('length', 'int'); |
| 2859 }); |
| 2860 } |
| 2861 |
| 2862 test_PrefixedIdentifier_trailingStmt_local_untyped() { |
| 2863 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2864 addTestSource('f() {var g = "hello"; g.^ int y = 0;}'); |
| 2865 computeFast(); |
| 2866 return computeFull((bool result) { |
| 2867 assertSuggestInvocationGetter('length', 'int'); |
| 2868 }); |
| 2869 } |
| 2870 |
| 2871 test_PrefixedIdentifier_trailingStmt_method() { |
| 2872 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2873 addTestSource('class A {String g() {}; f() {g.^ int y = 0;}}'); |
| 2874 computeFast(); |
| 2875 return computeFull((bool result) { |
| 2876 assertSuggestInvocationGetter('length', 'int'); |
| 2877 }); |
| 2878 } |
| 2879 |
| 2880 test_PrefixedIdentifier_trailingStmt_param() { |
| 2881 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2882 addTestSource('class A {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_param2() { |
| 2890 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2891 addTestSource('f(String g) {g.^ int y = 0;}'); |
| 2892 computeFast(); |
| 2893 return computeFull((bool result) { |
| 2894 assertSuggestInvocationGetter('length', 'int'); |
| 2895 }); |
| 2896 } |
| 2897 |
| 2898 test_PrefixedIdentifier_trailingStmt_topLevelVar() { |
| 2899 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 2900 addTestSource('String g; f() {g.^ int y = 0;}'); |
| 2901 computeFast(); |
| 2902 return computeFull((bool result) { |
| 2903 assertSuggestInvocationGetter('length', 'int'); |
| 2904 }); |
| 2905 } |
| 2906 |
| 2809 test_PropertyAccess_expression() { | 2907 test_PropertyAccess_expression() { |
| 2810 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement | 2908 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement |
| 2811 addTestSource('class A {a() {"hello".to^String().length}}'); | 2909 addTestSource('class A {a() {"hello".to^String().length}}'); |
| 2812 computeFast(); | 2910 computeFast(); |
| 2813 return computeFull((bool result) { | 2911 return computeFull((bool result) { |
| 2814 expect(request.replacementOffset, completionOffset - 2); | 2912 expect(request.replacementOffset, completionOffset - 2); |
| 2815 expect(request.replacementLength, 8); | 2913 expect(request.replacementLength, 8); |
| 2816 assertSuggestInvocationGetter('length', 'int'); | 2914 assertSuggestInvocationGetter('length', 'int'); |
| 2817 assertNotSuggested('A'); | 2915 assertNotSuggested('A'); |
| 2818 assertNotSuggested('a'); | 2916 assertNotSuggested('a'); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3000 assertNotSuggested('bar2'); | 3098 assertNotSuggested('bar2'); |
| 3001 assertNotSuggested('_B'); | 3099 assertNotSuggested('_B'); |
| 3002 assertSuggestLocalClass('Y'); | 3100 assertSuggestLocalClass('Y'); |
| 3003 assertSuggestLocalClass('C'); | 3101 assertSuggestLocalClass('C'); |
| 3004 assertSuggestLocalVariable('f', null); | 3102 assertSuggestLocalVariable('f', null); |
| 3005 assertNotSuggested('x'); | 3103 assertNotSuggested('x'); |
| 3006 assertNotSuggested('e'); | 3104 assertNotSuggested('e'); |
| 3007 }); | 3105 }); |
| 3008 } | 3106 } |
| 3009 } | 3107 } |
| OLD | NEW |