| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 test_ImportDirective_dart() { | 155 test_ImportDirective_dart() { |
| 156 // SimpleStringLiteral ImportDirective | 156 // SimpleStringLiteral ImportDirective |
| 157 addTestSource(''' | 157 addTestSource(''' |
| 158 import "dart^"; | 158 import "dart^"; |
| 159 main() {}'''); | 159 main() {}'''); |
| 160 return computeFull().then((_) { | 160 return computeFull().then((_) { |
| 161 assertNotSuggested('Object'); | 161 assertNotSuggested('Object'); |
| 162 }); | 162 }); |
| 163 } | 163 } |
| 164 | 164 |
| 165 test_PrefixedIdentifier() { | |
| 166 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 167 addSource('/testA.dart', ''' | |
| 168 class A() {int x;} | |
| 169 _B() {}'''); | |
| 170 addTestSource(''' | |
| 171 import "/testA.dart"; | |
| 172 class X {foo(){A a; a.^}}'''); | |
| 173 return computeFull().then((_) { | |
| 174 // InvocationComputer provides suggestions for prefixed expressions | |
| 175 assertNotSuggested('A'); | |
| 176 assertNotSuggested('x'); | |
| 177 assertNotSuggested('X'); | |
| 178 assertNotSuggested('Object'); | |
| 179 }); | |
| 180 } | |
| 181 | |
| 182 test_PrefixedIdentifier_prefix() { | |
| 183 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 184 addSource('/testA.dart', ''' | |
| 185 class A {static int bar = 10;} | |
| 186 _B() {}'''); | |
| 187 addTestSource(''' | |
| 188 import "/testA.dart"; | |
| 189 class X {foo(){A^.bar}}'''); | |
| 190 return computeFull().then((_) { | |
| 191 // InvocationComputer provides suggestions for prefixed expressions | |
| 192 assertSuggestClass('A'); | |
| 193 assertNotSuggested('bar'); | |
| 194 assertNotSuggested('_B'); | |
| 195 assertNotSuggested('X'); | |
| 196 assertNotSuggested('foo'); | |
| 197 }); | |
| 198 } | |
| 199 | |
| 200 test_ShowCombinator_class() { | 165 test_ShowCombinator_class() { |
| 201 // SimpleIdentifier ShowCombinator ImportDirective | 166 // SimpleIdentifier ShowCombinator ImportDirective |
| 202 addSource('/testAB.dart', ''' | 167 addSource('/testAB.dart', ''' |
| 203 class A { } | 168 class A { } |
| 204 class B { }'''); | 169 class B { }'''); |
| 205 addSource('/testCD.dart', ''' | 170 addSource('/testCD.dart', ''' |
| 206 class C { } | 171 class C { } |
| 207 class D { }'''); | 172 class D { }'''); |
| 208 addTestSource(''' | 173 addTestSource(''' |
| 209 import "/testAB.dart" show ^; | 174 import "/testAB.dart" show ^; |
| 210 import "/testCD.dart"; | 175 import "/testCD.dart"; |
| 211 class X {}'''); | 176 class X {}'''); |
| 212 return computeFull().then((_) { | 177 return computeFull().then((_) { |
| 213 assertSuggestClass('A'); | 178 assertSuggestClass('A'); |
| 214 assertSuggestClass('B'); | 179 assertSuggestClass('B'); |
| 215 assertNotSuggested('C'); | 180 assertNotSuggested('C'); |
| 216 assertNotSuggested('D'); | 181 assertNotSuggested('D'); |
| 217 assertNotSuggested('Object'); | 182 assertNotSuggested('Object'); |
| 218 }); | 183 }); |
| 219 } | 184 } |
| 220 | |
| 221 test_TopLevelVariableDeclaration_name() { | |
| 222 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 223 // TopLevelVariableDeclaration | |
| 224 addSource('/testA.dart', 'class B { };'); | |
| 225 addTestSource(''' | |
| 226 import "/testA.dart"; | |
| 227 class C {} B ^'''); | |
| 228 return computeFull().then((_) { | |
| 229 assertNotSuggested('B'); | |
| 230 }); | |
| 231 } | |
| 232 | |
| 233 test_TopLevelVariableDeclaration_name_untyped() { | |
| 234 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 235 // TopLevelVariableDeclaration | |
| 236 addSource('/testA.dart', 'class B { };'); | |
| 237 addTestSource(''' | |
| 238 import "/testA.dart"; | |
| 239 class C {} var ^'''); | |
| 240 return computeFull().then((_) { | |
| 241 assertNotSuggested('B'); | |
| 242 }); | |
| 243 } | |
| 244 } | 185 } |
| OLD | NEW |