| 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.dart.local; | 5 library test.services.completion.dart.local; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol_server.dart'; | 7 import 'package:analysis_server/src/protocol_server.dart'; |
| 8 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 8 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 9 import 'package:analysis_server/src/services/completion/local_computer.dart'; | 9 import 'package:analysis_server/src/services/completion/local_computer.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 void main() { | 187 void main() { |
| 188 while (true) { | 188 while (true) { |
| 189 break ^ | 189 break ^ |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 '''); | 192 '''); |
| 193 expect(computeFast(), isTrue); | 193 expect(computeFast(), isTrue); |
| 194 assertNotSuggested('x'); | 194 assertNotSuggested('x'); |
| 195 } | 195 } |
| 196 | 196 |
| 197 test_overrides() { | |
| 198 addTestSource(''' | |
| 199 class A {m() {}} | |
| 200 class B extends A {m() {^}} | |
| 201 '''); | |
| 202 expect(computeFast(), isTrue); | |
| 203 assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD); | |
| 204 } | |
| 205 | |
| 206 test_break_ignores_unrelated_statements() { | 197 test_break_ignores_unrelated_statements() { |
| 207 addTestSource(''' | 198 addTestSource(''' |
| 208 void main() { | 199 void main() { |
| 209 foo: while (true) {} | 200 foo: while (true) {} |
| 210 while (true) { break ^ } | 201 while (true) { break ^ } |
| 211 bar: while (true) {} | 202 bar: while (true) {} |
| 212 } | 203 } |
| 213 '''); | 204 '''); |
| 214 expect(computeFast(), isTrue); | 205 expect(computeFast(), isTrue); |
| 215 // The scope of the label defined by a labeled statement is just the | 206 // The scope of the label defined by a labeled statement is just the |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 CompletionSuggestion suggestion = assertSuggestLocalFunction('m', 'void'); | 560 CompletionSuggestion suggestion = assertSuggestLocalFunction('m', 'void'); |
| 570 expect(suggestion.parameterNames, hasLength(2)); | 561 expect(suggestion.parameterNames, hasLength(2)); |
| 571 expect(suggestion.parameterNames[0], 'x'); | 562 expect(suggestion.parameterNames[0], 'x'); |
| 572 expect(suggestion.parameterTypes[0], 'dynamic'); | 563 expect(suggestion.parameterTypes[0], 'dynamic'); |
| 573 expect(suggestion.parameterNames[1], 'y'); | 564 expect(suggestion.parameterNames[1], 'y'); |
| 574 expect(suggestion.parameterTypes[1], 'int'); | 565 expect(suggestion.parameterTypes[1], 'int'); |
| 575 expect(suggestion.requiredParameterCount, 2); | 566 expect(suggestion.requiredParameterCount, 2); |
| 576 expect(suggestion.hasNamedParameters, false); | 567 expect(suggestion.hasNamedParameters, false); |
| 577 } | 568 } |
| 578 | 569 |
| 570 test_ignore_symbol_being_completed() { |
| 571 addTestSource('class MyClass { } main(MC^) { }'); |
| 572 expect(computeFast(), isTrue); |
| 573 assertSuggestLocalClass('MyClass'); |
| 574 assertNotSuggested('MC'); |
| 575 } |
| 576 |
| 579 test_InstanceCreationExpression() { | 577 test_InstanceCreationExpression() { |
| 580 addTestSource(''' | 578 addTestSource(''' |
| 581 class A {foo(){var f; {var x;}}} | 579 class A {foo(){var f; {var x;}}} |
| 582 class B {B(this.x, [String boo]) { } int x;} | 580 class B {B(this.x, [String boo]) { } int x;} |
| 583 class C {C.bar({boo: 'hoo', int z: 0}) { } } | 581 class C {C.bar({boo: 'hoo', int z: 0}) { } } |
| 584 main() {new ^ String x = "hello";}'''); | 582 main() {new ^ String x = "hello";}'''); |
| 585 computeFast(); | 583 computeFast(); |
| 586 return computeFull((bool result) { | 584 return computeFull((bool result) { |
| 587 CompletionSuggestion suggestion; | 585 CompletionSuggestion suggestion; |
| 588 | 586 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 assertSuggestLocalMethod('m', 'A', 'void'); | 734 assertSuggestLocalMethod('m', 'A', 'void'); |
| 737 expect(suggestion.parameterNames, hasLength(2)); | 735 expect(suggestion.parameterNames, hasLength(2)); |
| 738 expect(suggestion.parameterNames[0], 'x'); | 736 expect(suggestion.parameterNames[0], 'x'); |
| 739 expect(suggestion.parameterTypes[0], 'dynamic'); | 737 expect(suggestion.parameterTypes[0], 'dynamic'); |
| 740 expect(suggestion.parameterNames[1], 'y'); | 738 expect(suggestion.parameterNames[1], 'y'); |
| 741 expect(suggestion.parameterTypes[1], 'int'); | 739 expect(suggestion.parameterTypes[1], 'int'); |
| 742 expect(suggestion.requiredParameterCount, 2); | 740 expect(suggestion.requiredParameterCount, 2); |
| 743 expect(suggestion.hasNamedParameters, false); | 741 expect(suggestion.hasNamedParameters, false); |
| 744 } | 742 } |
| 745 | 743 |
| 744 test_overrides() { |
| 745 addTestSource(''' |
| 746 class A {m() {}} |
| 747 class B extends A {m() {^}} |
| 748 '''); |
| 749 expect(computeFast(), isTrue); |
| 750 assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD); |
| 751 } |
| 752 |
| 746 test_shadowed_name() { | 753 test_shadowed_name() { |
| 747 addTestSource('var a; class A { var a; m() { ^ } }'); | 754 addTestSource('var a; class A { var a; m() { ^ } }'); |
| 748 expect(computeFast(), isTrue); | 755 expect(computeFast(), isTrue); |
| 749 assertSuggestLocalField('a', null); | 756 assertSuggestLocalField('a', null); |
| 750 } | 757 } |
| 751 } | 758 } |
| OLD | NEW |