| 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.invocation; | 5 library test.services.completion.invocation; |
| 6 | 6 |
| 7 | 7 |
| 8 import 'package:analysis_server/src/protocol.dart'; | |
| 9 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; | 8 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; |
| 10 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 11 | 10 |
| 12 import '../../reflective_tests.dart'; | 11 import '../../reflective_tests.dart'; |
| 13 import 'completion_test_util.dart'; | 12 import 'completion_test_util.dart'; |
| 14 | 13 |
| 15 main() { | 14 main() { |
| 16 groupSep = ' | '; | 15 groupSep = ' | '; |
| 17 runReflectiveTests(InvocationComputerTest); | 16 runReflectiveTests(InvocationComputerTest); |
| 18 } | 17 } |
| 19 | 18 |
| 20 @ReflectiveTestCase() | 19 @ReflectiveTestCase() |
| 21 class InvocationComputerTest extends AbstractSelectorSuggestionTest { | 20 class InvocationComputerTest extends AbstractSelectorSuggestionTest { |
| 22 | 21 |
| 23 @override | 22 @override |
| 24 void setUp() { | 23 void setUp() { |
| 25 super.setUp(); | 24 super.setUp(); |
| 26 computer = new InvocationComputer(); | 25 computer = new InvocationComputer(); |
| 27 } | 26 } |
| 28 | 27 |
| 29 test_ConstructorName_importedClass() { | |
| 30 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 31 // InstanceCreationExpression | |
| 32 addSource('/testB.dart', ''' | |
| 33 lib B; | |
| 34 class X {X.c(); X._d(); z() {}}'''); | |
| 35 addTestSource(''' | |
| 36 import "/testB.dart"; | |
| 37 var m; | |
| 38 main() {new X.^}'''); | |
| 39 return computeFull().then((_) { | |
| 40 assertSuggest(CompletionSuggestionKind.CONSTRUCTOR, 'c'); | |
| 41 assertNotSuggested('_d'); | |
| 42 assertNotSuggested('z'); | |
| 43 assertNotSuggested('m'); | |
| 44 }); | |
| 45 } | |
| 46 | |
| 47 test_ConstructorName_localClass() { | |
| 48 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 49 // InstanceCreationExpression | |
| 50 addTestSource(''' | |
| 51 var m; | |
| 52 class X {X.c(); X._d(); z() {}} | |
| 53 main() {new X.^}'''); | |
| 54 return computeFull().then((_) { | |
| 55 assertSuggest(CompletionSuggestionKind.CONSTRUCTOR, 'c'); | |
| 56 assertSuggest(CompletionSuggestionKind.CONSTRUCTOR, '_d'); | |
| 57 assertNotSuggested('z'); | |
| 58 assertNotSuggested('m'); | |
| 59 }); | |
| 60 } | |
| 61 | |
| 62 test_PrefixedIdentifier_field() { | 28 test_PrefixedIdentifier_field() { |
| 63 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 29 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 64 addTestSource(''' | 30 addTestSource(''' |
| 65 class A {var b; X _c;} | 31 class A {var b; X _c;} |
| 66 class X{} | 32 class X{} |
| 67 main() {A a; a.^}'''); | 33 main() {A a; a.^}'''); |
| 68 return computeFull().then((_) { | 34 return computeFull().then((_) { |
| 69 assertSuggestGetter('b', null); | 35 assertSuggestGetter('b', null); |
| 70 assertSuggestGetter('_c', 'X'); | 36 assertSuggestGetter('_c', 'X'); |
| 71 }); | 37 }); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 class X {set y(X x) {} set _z(X x) {}}'''); | 197 class X {set y(X x) {} set _z(X x) {}}'''); |
| 232 addTestSource(''' | 198 addTestSource(''' |
| 233 import "/testB.dart"; | 199 import "/testB.dart"; |
| 234 main() {X x; x.^}'''); | 200 main() {X x; x.^}'''); |
| 235 return computeFull().then((_) { | 201 return computeFull().then((_) { |
| 236 assertSuggestSetter('y'); | 202 assertSuggestSetter('y'); |
| 237 assertNotSuggested('_z'); | 203 assertNotSuggested('_z'); |
| 238 }); | 204 }); |
| 239 } | 205 } |
| 240 } | 206 } |
| OLD | NEW |