| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 assertSuggestTopLevelVarGetterSetter('T1', 'String'); | 63 assertSuggestTopLevelVarGetterSetter('T1', 'String'); |
| 64 assertNotSuggested('_T2'); | 64 assertNotSuggested('_T2'); |
| 65 assertSuggestTopLevelVar('T3', 'int', CompletionRelevance.LOW); | 65 assertSuggestTopLevelVar('T3', 'int', CompletionRelevance.LOW); |
| 66 assertNotSuggested('_T4'); | 66 assertNotSuggested('_T4'); |
| 67 // LocalComputer provides local suggestions | 67 // LocalComputer provides local suggestions |
| 68 assertNotSuggested('C'); | 68 assertNotSuggested('C'); |
| 69 assertNotSuggested('foo'); | 69 assertNotSuggested('foo'); |
| 70 }); | 70 }); |
| 71 } | 71 } |
| 72 | 72 |
| 73 test_ConstructorName_importedClass() { | |
| 74 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 75 // InstanceCreationExpression | |
| 76 addSource('/testB.dart', ''' | |
| 77 lib B; | |
| 78 class X {X.c(); X._d(); z() {}}'''); | |
| 79 addTestSource(''' | |
| 80 import "/testB.dart"; | |
| 81 var m; | |
| 82 main() {new X.^}'''); | |
| 83 return computeFull().then((_) { | |
| 84 assertNoSuggestions(); | |
| 85 }); | |
| 86 } | |
| 87 | |
| 88 test_ConstructorName_localClass() { | |
| 89 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 90 // InstanceCreationExpression | |
| 91 addTestSource(''' | |
| 92 var m; | |
| 93 class X {X.c(); X._d(); z() {}} | |
| 94 main() {new X.^}'''); | |
| 95 return computeFull().then((_) { | |
| 96 assertNoSuggestions(); | |
| 97 }); | |
| 98 } | |
| 99 | |
| 100 test_ExpressionStatement_class() { | 73 test_ExpressionStatement_class() { |
| 101 // SimpleIdentifier ExpressionStatement Block | 74 // SimpleIdentifier ExpressionStatement Block |
| 102 addSource('/testA.dart', ''' | 75 addSource('/testA.dart', ''' |
| 103 class A {int x;} | 76 class A {int x;} |
| 104 class _B { }'''); | 77 class _B { }'''); |
| 105 addTestSource(''' | 78 addTestSource(''' |
| 106 import "/testA.dart"; | 79 import "/testA.dart"; |
| 107 class C {foo(){O^}}'''); | 80 class C {foo(){O^}}'''); |
| 108 return computeFull().then((_) { | 81 return computeFull().then((_) { |
| 109 assertSuggestClass('A'); | 82 assertSuggestClass('A'); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 // SimpleIdentifier VariableDeclaration VariableDeclarationList | 234 // SimpleIdentifier VariableDeclaration VariableDeclarationList |
| 262 // TopLevelVariableDeclaration | 235 // TopLevelVariableDeclaration |
| 263 addSource('/testA.dart', 'class B { };'); | 236 addSource('/testA.dart', 'class B { };'); |
| 264 addTestSource(''' | 237 addTestSource(''' |
| 265 import "/testA.dart"; | 238 import "/testA.dart"; |
| 266 class C {} var ^'''); | 239 class C {} var ^'''); |
| 267 return computeFull().then((_) { | 240 return computeFull().then((_) { |
| 268 assertNotSuggested('B'); | 241 assertNotSuggested('B'); |
| 269 }); | 242 }); |
| 270 } | 243 } |
| 271 | |
| 272 test_VariableDeclaration_name() { | |
| 273 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 274 // VariableDeclarationStatement Block | |
| 275 addSource('/testA.dart', 'var T1;'); | |
| 276 addTestSource(''' | |
| 277 import "/testA.dart"; | |
| 278 class C {a() {var ^}}'''); | |
| 279 return computeFull().then((_) { | |
| 280 assertNotSuggested('T1'); | |
| 281 }); | |
| 282 } | |
| 283 | |
| 284 xtest_InstanceCreationExpression() { | |
| 285 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression | |
| 286 addSource('/testA.dart', ''' | |
| 287 class A {int x;} | |
| 288 B() { }'''); | |
| 289 addTestSource(''' | |
| 290 import "/testA.dart"; | |
| 291 class C {foo(){new ^}}'''); | |
| 292 return computeFull().then((_) { | |
| 293 assertSuggestClass('A'); | |
| 294 assertNotSuggested('x'); | |
| 295 assertNotSuggested('B'); | |
| 296 // Should not suggest compilation unit elements | |
| 297 // which are returned by the LocalComputer | |
| 298 assertNotSuggested('C'); | |
| 299 }); | |
| 300 } | |
| 301 | |
| 302 xtest_VariableDeclarationStatement_RHS() { | |
| 303 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 304 // VariableDeclarationStatement | |
| 305 addSource('/testA.dart', 'class A {int x;} class _B { }'); | |
| 306 addTestSource(''' | |
| 307 import "/testA.dart"; | |
| 308 class C {foo(){var e = ^}}'''); | |
| 309 return computeFull().then((_) { | |
| 310 assertSuggestClass('A'); | |
| 311 assertNotSuggested('x'); | |
| 312 assertNotSuggested('_B'); | |
| 313 // Should not suggest compilation unit elements | |
| 314 // which are returned by the LocalComputer | |
| 315 assertNotSuggested('C'); | |
| 316 }); | |
| 317 } | |
| 318 } | 244 } |
| OLD | NEW |