| 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 'dart:async'; | 8 import 'dart:async'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 }); | 146 }); |
| 147 } | 147 } |
| 148 | 148 |
| 149 test_local_propogatedType() { | 149 test_local_propogatedType() { |
| 150 addTestSource('foo() {var x = "bar"; x.^}'); | 150 addTestSource('foo() {var x = "bar"; x.^}'); |
| 151 return computeFull((bool result) { | 151 return computeFull((bool result) { |
| 152 assertSuggestGetter('length', 'int'); | 152 assertSuggestGetter('length', 'int'); |
| 153 }); | 153 }); |
| 154 } | 154 } |
| 155 | 155 |
| 156 test_param() { | |
| 157 addTestSource('foo(String x) {x.^}'); | |
| 158 return computeFull((bool result) { | |
| 159 assertSuggestGetter('length', 'int'); | |
| 160 }); | |
| 161 } | |
| 162 | |
| 163 test_param_is() { | |
| 164 addTestSource('foo(x) {if (x is String) x.^}'); | |
| 165 return computeFull((bool result) { | |
| 166 assertSuggestGetter('length', 'int'); | |
| 167 }); | |
| 168 } | |
| 169 | |
| 170 test_method_parameters_mixed_required_and_named() { | 156 test_method_parameters_mixed_required_and_named() { |
| 171 addTestSource(''' | 157 addTestSource(''' |
| 172 class C { | 158 class C { |
| 173 void m(x, {int y}) {} | 159 void m(x, {int y}) {} |
| 174 } | 160 } |
| 175 void main() {new C().^}'''); | 161 void main() {new C().^}'''); |
| 176 return computeFull((bool result) { | 162 return computeFull((bool result) { |
| 177 CompletionSuggestion suggestion = assertSuggestMethod('m', 'C', 'void'); | 163 CompletionSuggestion suggestion = assertSuggestMethod('m', 'C', 'void'); |
| 178 expect(suggestion.parameterNames, hasLength(2)); | 164 expect(suggestion.parameterNames, hasLength(2)); |
| 179 expect(suggestion.parameterNames[0], 'x'); | 165 expect(suggestion.parameterNames[0], 'x'); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 class C { | 288 class C { |
| 303 set x(int value) {}; | 289 set x(int value) {}; |
| 304 } | 290 } |
| 305 void main() {int y = new C().^}'''); | 291 void main() {int y = new C().^}'''); |
| 306 return computeFull((bool result) { | 292 return computeFull((bool result) { |
| 307 CompletionSuggestion suggestion = assertSuggestSetter('x'); | 293 CompletionSuggestion suggestion = assertSuggestSetter('x'); |
| 308 assertHasNoParameterInfo(suggestion); | 294 assertHasNoParameterInfo(suggestion); |
| 309 }); | 295 }); |
| 310 } | 296 } |
| 311 | 297 |
| 298 test_only_instance() { |
| 299 // SimpleIdentifier PropertyAccess ExpressionStatement |
| 300 addTestSource(''' |
| 301 class C { |
| 302 int f1; |
| 303 static int f2; |
| 304 m1() {} |
| 305 static m2() {} |
| 306 } |
| 307 void main() {new C().^}'''); |
| 308 return computeFull((bool result) { |
| 309 assertSuggestInvocationField('f1', 'int'); |
| 310 assertNotSuggested('f2'); |
| 311 assertSuggestMethod('m1', 'C', null); |
| 312 assertNotSuggested('m2'); |
| 313 }); |
| 314 } |
| 315 |
| 316 test_only_instance2() { |
| 317 // SimpleIdentifier MethodInvocation ExpressionStatement |
| 318 addTestSource(''' |
| 319 class C { |
| 320 int f1; |
| 321 static int f2; |
| 322 m1() {} |
| 323 static m2() {} |
| 324 } |
| 325 void main() {new C().^ print("something");}'''); |
| 326 return computeFull((bool result) { |
| 327 assertSuggestInvocationField('f1', 'int'); |
| 328 assertNotSuggested('f2'); |
| 329 assertSuggestMethod('m1', 'C', null); |
| 330 assertNotSuggested('m2'); |
| 331 }); |
| 332 } |
| 333 |
| 334 test_only_static() { |
| 335 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 336 addTestSource(''' |
| 337 class C { |
| 338 int f1; |
| 339 static int f2; |
| 340 m1() {} |
| 341 static m2() {} |
| 342 } |
| 343 void main() {C.^}'''); |
| 344 return computeFull((bool result) { |
| 345 assertNotSuggested('f1'); |
| 346 assertSuggestInvocationField('f2', 'int'); |
| 347 assertNotSuggested('m1'); |
| 348 assertSuggestMethod('m2', 'C', null); |
| 349 }); |
| 350 } |
| 351 |
| 352 test_only_static2() { |
| 353 // SimpleIdentifier MethodInvocation ExpressionStatement |
| 354 addTestSource(''' |
| 355 class C { |
| 356 int f1; |
| 357 static int f2; |
| 358 m1() {} |
| 359 static m2() {} |
| 360 } |
| 361 void main() {C.^ print("something");}'''); |
| 362 return computeFull((bool result) { |
| 363 assertNotSuggested('f1'); |
| 364 assertSuggestInvocationField('f2', 'int'); |
| 365 assertNotSuggested('m1'); |
| 366 assertSuggestMethod('m2', 'C', null); |
| 367 }); |
| 368 } |
| 369 |
| 370 test_param() { |
| 371 addTestSource('foo(String x) {x.^}'); |
| 372 return computeFull((bool result) { |
| 373 assertSuggestGetter('length', 'int'); |
| 374 }); |
| 375 } |
| 376 |
| 377 test_param_is() { |
| 378 addTestSource('foo(x) {if (x is String) x.^}'); |
| 379 return computeFull((bool result) { |
| 380 assertSuggestGetter('length', 'int'); |
| 381 }); |
| 382 } |
| 383 |
| 312 test_shadowing_field_over_field() => | 384 test_shadowing_field_over_field() => |
| 313 check_shadowing('int x;', 'int x;', true); | 385 check_shadowing('int x;', 'int x;', true); |
| 314 | 386 |
| 315 test_shadowing_field_over_getter() => | 387 test_shadowing_field_over_getter() => |
| 316 check_shadowing('int x;', 'int get x => null;', true); | 388 check_shadowing('int x;', 'int get x => null;', true); |
| 317 | 389 |
| 318 test_shadowing_field_over_method() => | 390 test_shadowing_field_over_method() => |
| 319 check_shadowing('int x;', 'void x() {}', true); | 391 check_shadowing('int x;', 'void x() {}', true); |
| 320 | 392 |
| 321 test_shadowing_field_over_setter() => | 393 test_shadowing_field_over_setter() => |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 486 } |
| 415 void test(Derived d) { | 487 void test(Derived d) { |
| 416 d.^ | 488 d.^ |
| 417 } | 489 } |
| 418 '''); | 490 '''); |
| 419 return computeFull((bool result) { | 491 return computeFull((bool result) { |
| 420 assertSuggestMethod('f', 'Base', 'void'); | 492 assertSuggestMethod('f', 'Base', 'void'); |
| 421 }); | 493 }); |
| 422 } | 494 } |
| 423 } | 495 } |
| OLD | NEW |