| 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'; | 8 import 'package:analysis_server/src/protocol.dart'; |
| 9 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; | 9 import 'package:analysis_server/src/services/completion/invocation_computer.dart
'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 import '../../reflective_tests.dart'; | 12 import '../../reflective_tests.dart'; |
| 13 import 'completion_test_util.dart'; | 13 import 'completion_test_util.dart'; |
| 14 | 14 |
| 15 main() { | 15 main() { |
| 16 groupSep = ' | '; | 16 groupSep = ' | '; |
| 17 runReflectiveTests(InvocationComputerTest); | 17 runReflectiveTests(InvocationComputerTest); |
| 18 } | 18 } |
| 19 | 19 |
| 20 @ReflectiveTestCase() | 20 @ReflectiveTestCase() |
| 21 class InvocationComputerTest extends AbstractCompletionTest { | 21 class InvocationComputerTest extends AbstractSelectorSuggestionTest { |
| 22 | 22 |
| 23 @override | 23 @override |
| 24 void setUp() { | 24 void setUp() { |
| 25 super.setUp(); | 25 super.setUp(); |
| 26 computer = new InvocationComputer(); | 26 computer = new InvocationComputer(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 test_CascadeExpression_selector1() { | |
| 30 // PropertyAccess CascadeExpression ExpressionStatement | |
| 31 addTestSource(''' | |
| 32 class A {var b; X _c;} | |
| 33 class X{} | |
| 34 // looks like a cascade to the parser | |
| 35 // but the user is trying to get completions for a non-cascade | |
| 36 main() {A a; a.^.b}'''); | |
| 37 return computeFull(true).then((_) { | |
| 38 assertSuggestGetter('b', null); | |
| 39 assertSuggestGetter('_c', 'X'); | |
| 40 }); | |
| 41 } | |
| 42 | |
| 43 test_CascadeExpression_selector2() { | |
| 44 // PropertyAccess CascadeExpression ExpressionStatement | |
| 45 addTestSource(''' | |
| 46 class A {var b; X _c;} | |
| 47 class X{} | |
| 48 main() {A a; a..^b}'''); | |
| 49 return computeFull().then((_) { | |
| 50 assertSuggestGetter('b', null); | |
| 51 assertSuggestGetter('_c', 'X'); | |
| 52 }); | |
| 53 } | |
| 54 | |
| 55 test_CascadeExpression_target() { | 29 test_CascadeExpression_target() { |
| 56 // PropertyAccess CascadeExpression ExpressionStatement | 30 // PropertyAccess CascadeExpression ExpressionStatement |
| 57 addTestSource(''' | 31 addTestSource(''' |
| 58 class A {var b; X _c;} | 32 class A {var b; X _c;} |
| 59 class X{} | 33 class X{} |
| 60 main() {A a; a^..b}'''); | 34 main() {A a; a^..b}'''); |
| 61 return computeFull().then((_) { | 35 return computeFull().then((_) { |
| 62 assertNotSuggested('b'); | 36 assertNotSuggested('b'); |
| 63 assertNotSuggested('_c'); | 37 assertNotSuggested('_c'); |
| 64 }); | 38 }); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 class X {X.c(); X._d(); z() {}} | 64 class X {X.c(); X._d(); z() {}} |
| 91 main() {new X.^}'''); | 65 main() {new X.^}'''); |
| 92 return computeFull().then((_) { | 66 return computeFull().then((_) { |
| 93 assertSuggest(CompletionSuggestionKind.CONSTRUCTOR, 'c'); | 67 assertSuggest(CompletionSuggestionKind.CONSTRUCTOR, 'c'); |
| 94 assertSuggest(CompletionSuggestionKind.CONSTRUCTOR, '_d'); | 68 assertSuggest(CompletionSuggestionKind.CONSTRUCTOR, '_d'); |
| 95 assertNotSuggested('z'); | 69 assertNotSuggested('z'); |
| 96 assertNotSuggested('m'); | 70 assertNotSuggested('m'); |
| 97 }); | 71 }); |
| 98 } | 72 } |
| 99 | 73 |
| 74 test_IsExpression() { |
| 75 // SimpleIdentifier TypeName IsExpression IfStatement |
| 76 addSource('/testB.dart', ''' |
| 77 lib B; |
| 78 class X {X.c(); X._d(); z() {}}'''); |
| 79 addTestSource(''' |
| 80 import "/testB.dart"; |
| 81 main() {var x; if (x is ^) { }}'''); |
| 82 return computeFull().then((_) { |
| 83 assertNoSuggestions(); |
| 84 }); |
| 85 } |
| 86 |
| 100 test_PrefixedIdentifier_field() { | 87 test_PrefixedIdentifier_field() { |
| 101 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 88 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 102 addTestSource(''' | 89 addTestSource(''' |
| 103 class A {var b; X _c;} | 90 class A {var b; X _c;} |
| 104 class X{} | 91 class X{} |
| 105 main() {A a; a.^}'''); | 92 main() {A a; a.^}'''); |
| 106 return computeFull().then((_) { | 93 return computeFull().then((_) { |
| 107 assertSuggestGetter('b', null); | 94 assertSuggestGetter('b', null); |
| 108 assertSuggestGetter('_c', 'X'); | 95 assertSuggestGetter('_c', 'X'); |
| 109 }); | 96 }); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 lib B; | 255 lib B; |
| 269 class X {set y(X x) {} set _z(X x) {}}'''); | 256 class X {set y(X x) {} set _z(X x) {}}'''); |
| 270 addTestSource(''' | 257 addTestSource(''' |
| 271 import "/testB.dart"; | 258 import "/testB.dart"; |
| 272 main() {X x; x.^}'''); | 259 main() {X x; x.^}'''); |
| 273 return computeFull().then((_) { | 260 return computeFull().then((_) { |
| 274 assertSuggestSetter('y'); | 261 assertSuggestSetter('y'); |
| 275 assertNotSuggested('_z'); | 262 assertNotSuggested('_z'); |
| 276 }); | 263 }); |
| 277 } | 264 } |
| 278 | |
| 279 //TODO (danrubel) implement | |
| 280 xtest_IsExpression() { | |
| 281 // SimpleIdentifier TypeName IsExpression IfStatement | |
| 282 addSource('/testB.dart', ''' | |
| 283 lib B; | |
| 284 class X {X.c(); X._d(); z() {}}'''); | |
| 285 addTestSource(''' | |
| 286 import "/testB.dart"; | |
| 287 main() {var x; if (x is ^) { }}'''); | |
| 288 return computeFull().then((_) { | |
| 289 assertNoSuggestions(); | |
| 290 }); | |
| 291 } | |
| 292 } | 265 } |
| OLD | NEW |