| 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.dart.local; | 5 library test.services.completion.dart.local; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/services/completion/local_computer.dart'; | 7 import 'package:analysis_server/src/services/completion/local_computer.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 import '../../reflective_tests.dart'; | 10 import '../../reflective_tests.dart'; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 test_FunctionExpression_body_function() { | 148 test_FunctionExpression_body_function() { |
| 149 // Block BlockFunctionBody FunctionExpression | 149 // Block BlockFunctionBody FunctionExpression |
| 150 addTestSource('String foo(List args) {x.then((R b) {^});}'); | 150 addTestSource('String foo(List args) {x.then((R b) {^});}'); |
| 151 expect(computeFast(), isTrue); | 151 expect(computeFast(), isTrue); |
| 152 var f = assertSuggestFunction('foo', 'String', false); | 152 var f = assertSuggestFunction('foo', 'String', false); |
| 153 expect(f.element.isPrivate, isFalse); | 153 expect(f.element.isPrivate, isFalse); |
| 154 assertSuggestParameter('args', 'List'); | 154 assertSuggestParameter('args', 'List'); |
| 155 assertSuggestParameter('b', 'R'); | 155 assertSuggestParameter('b', 'R'); |
| 156 } | 156 } |
| 157 | 157 |
| 158 test_InstanceCreationExpression() { | |
| 159 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression | |
| 160 addTestSource('class A {a() {var f; {var x;} new ^}} class B { }'); | |
| 161 expect(computeFast(), isTrue); | |
| 162 assertSuggestClass('A'); | |
| 163 assertSuggestClass('B'); | |
| 164 // TODO (danrubel) should only suggest types | |
| 165 //assertNotSuggested('a'); | |
| 166 assertSuggestMethod('a', 'A', null); | |
| 167 //assertNotSuggested('f'); | |
| 168 assertSuggestLocalVariable('f', null); | |
| 169 assertNotSuggested('x'); | |
| 170 } | |
| 171 | |
| 172 test_InterpolationExpression() { | 158 test_InterpolationExpression() { |
| 173 // SimpleIdentifier InterpolationExpression StringInterpolation | 159 // SimpleIdentifier InterpolationExpression StringInterpolation |
| 174 addTestSource('main() {String name; print("hello \$^");}'); | 160 addTestSource('main() {String name; print("hello \$^");}'); |
| 175 expect(computeFast(), isTrue); | 161 expect(computeFast(), isTrue); |
| 176 assertSuggestLocalVariable('name', 'String'); | 162 assertSuggestLocalVariable('name', 'String'); |
| 177 } | 163 } |
| 178 | 164 |
| 179 test_InterpolationExpression_block() { | 165 test_InterpolationExpression_block() { |
| 180 // SimpleIdentifier InterpolationExpression StringInterpolation | 166 // SimpleIdentifier InterpolationExpression StringInterpolation |
| 181 addTestSource('main() {String name; print("hello \${n^}");}'); | 167 addTestSource('main() {String name; print("hello \${n^}");}'); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 test_VariableDeclaration_RHS() { | 277 test_VariableDeclaration_RHS() { |
| 292 // VariableDeclaration VariableDeclarationList | 278 // VariableDeclaration VariableDeclarationList |
| 293 // VariableDeclarationStatement | 279 // VariableDeclarationStatement |
| 294 addTestSource('class A {a() {var f; {var x;} var e = ^ var g;}}'); | 280 addTestSource('class A {a() {var f; {var x;} var e = ^ var g;}}'); |
| 295 expect(computeFast(), isTrue); | 281 expect(computeFast(), isTrue); |
| 296 assertSuggestClass('A'); | 282 assertSuggestClass('A'); |
| 297 assertSuggestLocalVariable('f', null); | 283 assertSuggestLocalVariable('f', null); |
| 298 assertNotSuggested('g'); | 284 assertNotSuggested('g'); |
| 299 assertNotSuggested('x'); | 285 assertNotSuggested('x'); |
| 300 } | 286 } |
| 287 |
| 288 //TODO (danrubel) implement |
| 289 xtest_ConstructorName_importedClass() { |
| 290 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName |
| 291 // InstanceCreationExpression |
| 292 addSource('/testB.dart', ''' |
| 293 lib B; |
| 294 class X {X.c(); X._d(); z() {}}'''); |
| 295 addTestSource(''' |
| 296 import "/testB.dart"; |
| 297 var m; |
| 298 main() {new X.^}'''); |
| 299 return computeFull().then((_) { |
| 300 assertNoSuggestions(); |
| 301 }); |
| 302 } |
| 303 |
| 304 //TODO (danrubel) implement |
| 305 xtest_ConstructorName_localClass() { |
| 306 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName |
| 307 // InstanceCreationExpression |
| 308 addTestSource(''' |
| 309 var m; |
| 310 class X {X.c(); X._d(); z() {}} |
| 311 main() {new X.^}'''); |
| 312 return computeFull().then((_) { |
| 313 assertNoSuggestions(); |
| 314 }); |
| 315 } |
| 316 |
| 317 //TODO (danrubel) implement |
| 318 xtest_InstanceCreationExpression() { |
| 319 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression |
| 320 addTestSource('class A {a() {var f; {var x;} new ^}} class B { }'); |
| 321 expect(computeFast(), isTrue); |
| 322 assertSuggestClass('A'); |
| 323 assertSuggestClass('B'); |
| 324 assertNotSuggested('a'); |
| 325 assertNotSuggested('f'); |
| 326 assertNotSuggested('x'); |
| 327 } |
| 328 |
| 329 //TODO (danrubel) implement |
| 330 xtest_IsExpression_imported() { |
| 331 // SimpleIdentifier TypeName IsExpression IfStatement |
| 332 addSource('/testB.dart', ''' |
| 333 lib B; |
| 334 class X {X.c(); X._d(); z() {}}'''); |
| 335 addTestSource(''' |
| 336 import "/testB.dart"; |
| 337 main() {var x; if (x is ^) { }}'''); |
| 338 return computeFull().then((_) { |
| 339 assertNoSuggestions(); |
| 340 }); |
| 341 } |
| 342 |
| 343 //TODO (danrubel) implement |
| 344 xtest_IsExpression_local() { |
| 345 // SimpleIdentifier TypeName IsExpression IfStatement |
| 346 addTestSource(''' |
| 347 class X {X.c(); X._d(); z() {}} |
| 348 main() {var x; if (x is ^) { }}'''); |
| 349 return computeFull().then((_) { |
| 350 assertSuggestConstructor('c'); |
| 351 assertNotSuggested('main'); |
| 352 assertNotSuggested('X'); |
| 353 assertNotSuggested('B'); |
| 354 assertNotSuggested('x'); |
| 355 }); |
| 356 } |
| 301 } | 357 } |
| OLD | NEW |