| 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.toplevel; | 5 library test.services.completion.toplevel; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:analysis_server/src/services/completion/imported_computer.dart'; | 8 import 'package:analysis_server/src/services/completion/imported_computer.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // VariableDeclarationStatement Block | 289 // VariableDeclarationStatement Block |
| 290 addSource('/testA.dart', 'var T1;'); | 290 addSource('/testA.dart', 'var T1;'); |
| 291 addTestSource(''' | 291 addTestSource(''' |
| 292 import "/testA.dart"; | 292 import "/testA.dart"; |
| 293 class C {a() {var ^}}'''); | 293 class C {a() {var ^}}'''); |
| 294 return computeFull().then((_) { | 294 return computeFull().then((_) { |
| 295 assertNotSuggested('T1'); | 295 assertNotSuggested('T1'); |
| 296 }); | 296 }); |
| 297 } | 297 } |
| 298 | 298 |
| 299 xtest_ConstructorName_importedClass() { |
| 300 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName |
| 301 // InstanceCreationExpression |
| 302 addSource('/testB.dart', ''' |
| 303 lib B; |
| 304 class X {X.c(); X._d(); z() {}}'''); |
| 305 addTestSource(''' |
| 306 import "/testB.dart"; |
| 307 var m; |
| 308 main() {new X.^}'''); |
| 309 return computeFull().then((_) { |
| 310 assertNoSuggestions(); |
| 311 }); |
| 312 } |
| 313 |
| 314 xtest_ConstructorName_localClass() { |
| 315 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName |
| 316 // InstanceCreationExpression |
| 317 addTestSource(''' |
| 318 var m; |
| 319 class X {X.c(); X._d(); z() {}} |
| 320 main() {new X.^}'''); |
| 321 return computeFull().then((_) { |
| 322 assertNoSuggestions(); |
| 323 }); |
| 324 } |
| 325 |
| 299 // TODO (danrubel) implement | 326 // TODO (danrubel) implement |
| 300 xtest_InstanceCreationExpression() { | 327 xtest_InstanceCreationExpression() { |
| 301 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression | 328 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression |
| 302 addSource('/testA.dart', ''' | 329 addSource('/testA.dart', ''' |
| 303 class A {int x;} | 330 class A {int x;} |
| 304 B() { }'''); | 331 B() { }'''); |
| 305 addTestSource(''' | 332 addTestSource(''' |
| 306 import "/testA.dart"; | 333 import "/testA.dart"; |
| 307 class C {foo(){new ^}}'''); | 334 class C {foo(){new ^}}'''); |
| 308 return computeFull().then((_) { | 335 return computeFull().then((_) { |
| 309 assertSuggestClass('A'); | 336 assertSuggestClass('A'); |
| 310 assertNotSuggested('x'); | 337 assertNotSuggested('x'); |
| 311 assertNotSuggested('B'); | 338 assertNotSuggested('B'); |
| 312 // Should not suggest compilation unit elements | 339 // Should not suggest compilation unit elements |
| 313 // which are returned by the LocalComputer | 340 // which are returned by the LocalComputer |
| 314 assertNotSuggested('C'); | 341 assertNotSuggested('C'); |
| 315 }); | 342 }); |
| 316 } | 343 } |
| 317 | 344 |
| 318 // TODO (danrubel) implement | 345 // TODO (danrubel) implement |
| 346 xtest_IsExpression_imported() { |
| 347 // SimpleIdentifier TypeName IsExpression IfStatement |
| 348 addSource('/testB.dart', ''' |
| 349 lib B; |
| 350 class X {X.c(); X._d(); z() {}}'''); |
| 351 addTestSource(''' |
| 352 import "/testB.dart"; |
| 353 main() {var x; if (x is ^) { }}'''); |
| 354 return computeFull().then((_) { |
| 355 assertSuggestConstructor('c'); |
| 356 assertNotSuggested('main'); |
| 357 assertNotSuggested('X'); |
| 358 assertNotSuggested('B'); |
| 359 assertNotSuggested('x'); |
| 360 }); |
| 361 } |
| 362 |
| 363 // TODO (danrubel) implement |
| 364 xtest_IsExpression_local() { |
| 365 // SimpleIdentifier TypeName IsExpression IfStatement |
| 366 addTestSource(''' |
| 367 class X {X.c(); X._d(); z() {}} |
| 368 main() {var x; if (x is ^) { }}'''); |
| 369 return computeFull().then((_) { |
| 370 assertNoSuggestions(); |
| 371 }); |
| 372 } |
| 373 |
| 374 // TODO (danrubel) implement |
| 319 xtest_VariableDeclarationStatement_RHS() { | 375 xtest_VariableDeclarationStatement_RHS() { |
| 320 // SimpleIdentifier VariableDeclaration VariableDeclarationList | 376 // SimpleIdentifier VariableDeclaration VariableDeclarationList |
| 321 // VariableDeclarationStatement | 377 // VariableDeclarationStatement |
| 322 addSource('/testA.dart', 'class A {int x;} class _B { }'); | 378 addSource('/testA.dart', 'class A {int x;} class _B { }'); |
| 323 addTestSource(''' | 379 addTestSource(''' |
| 324 import "/testA.dart"; | 380 import "/testA.dart"; |
| 325 class C {foo(){var e = ^}}'''); | 381 class C {foo(){var e = ^}}'''); |
| 326 return computeFull().then((_) { | 382 return computeFull().then((_) { |
| 327 assertSuggestClass('A'); | 383 assertSuggestClass('A'); |
| 328 assertNotSuggested('x'); | 384 assertNotSuggested('x'); |
| 329 assertNotSuggested('_B'); | 385 assertNotSuggested('_B'); |
| 330 // Should not suggest compilation unit elements | 386 // Should not suggest compilation unit elements |
| 331 // which are returned by the LocalComputer | 387 // which are returned by the LocalComputer |
| 332 assertNotSuggested('C'); | 388 assertNotSuggested('C'); |
| 333 }); | 389 }); |
| 334 } | 390 } |
| 335 } | 391 } |
| OLD | NEW |