| 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 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 int T3; | 1000 int T3; |
| 1001 var _T4;'''); // not imported | 1001 var _T4;'''); // not imported |
| 1002 addTestSource(''' | 1002 addTestSource(''' |
| 1003 import "/testAB.dart"; | 1003 import "/testAB.dart"; |
| 1004 import "/testCD.dart" hide D; | 1004 import "/testCD.dart" hide D; |
| 1005 import "/testEEF.dart" show EE; | 1005 import "/testEEF.dart" show EE; |
| 1006 import "/testG.dart" as g; | 1006 import "/testG.dart" as g; |
| 1007 int T5; | 1007 int T5; |
| 1008 var _T6; | 1008 var _T6; |
| 1009 Z D2() {int x;} | 1009 Z D2() {int x;} |
| 1010 class X {a() {var f; {var x;} ^ var r;} void b() { }} | 1010 class X { |
| 1011 a() { |
| 1012 var f; |
| 1013 localF(int arg1) { } |
| 1014 {var x;} |
| 1015 ^ var r; |
| 1016 } |
| 1017 void b() { }} |
| 1011 class Z { }'''); | 1018 class Z { }'''); |
| 1012 computeFast(); | 1019 computeFast(); |
| 1013 return computeFull((bool result) { | 1020 return computeFull((bool result) { |
| 1014 | 1021 |
| 1015 assertSuggestLocalClass('X'); | 1022 assertSuggestLocalClass('X'); |
| 1016 assertSuggestLocalClass('Z'); | 1023 assertSuggestLocalClass('Z'); |
| 1017 assertLocalSuggestMethod('a', 'X', null); | 1024 assertLocalSuggestMethod('a', 'X', null); |
| 1018 assertLocalSuggestMethod('b', 'X', 'void'); | 1025 assertLocalSuggestMethod('b', 'X', 'void'); |
| 1026 assertSuggestLocalFunction('localF', null); |
| 1019 assertSuggestLocalVariable('f', null); | 1027 assertSuggestLocalVariable('f', null); |
| 1020 // Don't suggest locals out of scope | 1028 // Don't suggest locals out of scope |
| 1021 assertNotSuggested('r'); | 1029 assertNotSuggested('r'); |
| 1022 assertNotSuggested('x'); | 1030 assertNotSuggested('x'); |
| 1023 | 1031 |
| 1024 assertSuggestImportedClass('A'); | 1032 assertSuggestImportedClass('A'); |
| 1025 assertNotSuggested('_B'); | 1033 assertNotSuggested('_B'); |
| 1026 assertSuggestImportedClass('C'); | 1034 assertSuggestImportedClass('C'); |
| 1027 // hidden element suggested as low relevance | 1035 // hidden element suggested as low relevance |
| 1028 // but imported results are partially filtered | 1036 // but imported results are partially filtered |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2108 computeFast(); | 2116 computeFast(); |
| 2109 return computeFull((bool result) { | 2117 return computeFull((bool result) { |
| 2110 assertSuggestInvocationGetter('isEven', 'bool'); | 2118 assertSuggestInvocationGetter('isEven', 'bool'); |
| 2111 assertNotSuggested('A'); | 2119 assertNotSuggested('A'); |
| 2112 assertNotSuggested('a'); | 2120 assertNotSuggested('a'); |
| 2113 assertNotSuggested('Object'); | 2121 assertNotSuggested('Object'); |
| 2114 assertNotSuggested('=='); | 2122 assertNotSuggested('=='); |
| 2115 }); | 2123 }); |
| 2116 } | 2124 } |
| 2117 | 2125 |
| 2126 test_ThisExpression_block() { |
| 2127 // MethodInvocation ExpressionStatement Block |
| 2128 addTestSource(''' |
| 2129 main() { } |
| 2130 class I {X get f => new A();get _g => new A();} |
| 2131 class A implements I { |
| 2132 A() {} |
| 2133 A.z() {} |
| 2134 var b; X _c; |
| 2135 X get d => new A();get _e => new A(); |
| 2136 // no semicolon between completion point and next statement |
| 2137 set s1(I x) {} set _s2(I x) {this.^ m(null);} |
| 2138 m(X x) {} I _n(X x) {}} |
| 2139 class X{}'''); |
| 2140 computeFast(); |
| 2141 return computeFull((bool result) { |
| 2142 assertSuggestInvocationGetter('b', null); |
| 2143 assertSuggestInvocationGetter('_c', 'X'); |
| 2144 assertSuggestInvocationGetter('d', 'X'); |
| 2145 assertSuggestInvocationGetter('_e', null); |
| 2146 assertSuggestInvocationGetter('f', 'X'); |
| 2147 assertSuggestInvocationGetter('_g', null); |
| 2148 assertSuggestInvocationMethod('m', 'A', null); |
| 2149 assertSuggestInvocationMethod('_n', 'A', 'I'); |
| 2150 assertSuggestInvocationSetter('s1'); |
| 2151 assertSuggestInvocationSetter('_s2'); |
| 2152 assertNotSuggested('z'); |
| 2153 assertNotSuggested('I'); |
| 2154 assertNotSuggested('A'); |
| 2155 assertNotSuggested('X'); |
| 2156 assertNotSuggested('Object'); |
| 2157 assertNotSuggested('=='); |
| 2158 }); |
| 2159 } |
| 2160 |
| 2161 test_ThisExpression_constructor() { |
| 2162 // MethodInvocation ExpressionStatement Block |
| 2163 addTestSource(''' |
| 2164 main() { } |
| 2165 class I {X get f => new A();get _g => new A();} |
| 2166 class A implements I { |
| 2167 A() {this.^} |
| 2168 A.z() {} |
| 2169 var b; X _c; |
| 2170 X get d => new A();get _e => new A(); |
| 2171 // no semicolon between completion point and next statement |
| 2172 set s1(I x) {} set _s2(I x) {m(null);} |
| 2173 m(X x) {} I _n(X x) {}} |
| 2174 class X{}'''); |
| 2175 computeFast(); |
| 2176 return computeFull((bool result) { |
| 2177 assertSuggestInvocationGetter('b', null); |
| 2178 assertSuggestInvocationGetter('_c', 'X'); |
| 2179 assertSuggestInvocationGetter('d', 'X'); |
| 2180 assertSuggestInvocationGetter('_e', null); |
| 2181 assertSuggestInvocationGetter('f', 'X'); |
| 2182 assertSuggestInvocationGetter('_g', null); |
| 2183 assertSuggestInvocationMethod('m', 'A', null); |
| 2184 assertSuggestInvocationMethod('_n', 'A', 'I'); |
| 2185 assertSuggestInvocationSetter('s1'); |
| 2186 assertSuggestInvocationSetter('_s2'); |
| 2187 assertNotSuggested('z'); |
| 2188 assertNotSuggested('I'); |
| 2189 assertNotSuggested('A'); |
| 2190 assertNotSuggested('X'); |
| 2191 assertNotSuggested('Object'); |
| 2192 assertNotSuggested('=='); |
| 2193 }); |
| 2194 } |
| 2195 |
| 2118 test_TopLevelVariableDeclaration_typed_name() { | 2196 test_TopLevelVariableDeclaration_typed_name() { |
| 2119 // SimpleIdentifier VariableDeclaration VariableDeclarationList | 2197 // SimpleIdentifier VariableDeclaration VariableDeclarationList |
| 2120 // TopLevelVariableDeclaration | 2198 // TopLevelVariableDeclaration |
| 2121 addTestSource('class A {} B ^'); | 2199 addTestSource('class A {} B ^'); |
| 2122 computeFast(); | 2200 computeFast(); |
| 2123 return computeFull((bool result) { | 2201 return computeFull((bool result) { |
| 2124 assertNoSuggestions(); | 2202 assertNoSuggestions(); |
| 2125 }); | 2203 }); |
| 2126 } | 2204 } |
| 2127 | 2205 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2201 assertNotSuggested('bar2'); | 2279 assertNotSuggested('bar2'); |
| 2202 assertNotSuggested('_B'); | 2280 assertNotSuggested('_B'); |
| 2203 assertSuggestLocalClass('Y'); | 2281 assertSuggestLocalClass('Y'); |
| 2204 assertSuggestLocalClass('C'); | 2282 assertSuggestLocalClass('C'); |
| 2205 assertSuggestLocalVariable('f', null); | 2283 assertSuggestLocalVariable('f', null); |
| 2206 assertNotSuggested('x'); | 2284 assertNotSuggested('x'); |
| 2207 assertNotSuggested('e'); | 2285 assertNotSuggested('e'); |
| 2208 }); | 2286 }); |
| 2209 } | 2287 } |
| 2210 } | 2288 } |
| OLD | NEW |