Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(927)

Side by Side Diff: pkg/analysis_server/test/services/completion/local_computer_test.dart

Issue 972933002: add arguments to constructor completions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 15 matching lines...) Expand all
26 relevance: relevance, isDeprecated: isDeprecated); 26 relevance: relevance, isDeprecated: isDeprecated);
27 } 27 }
28 28
29 @override 29 @override
30 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, 30 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name,
31 {int relevance: DART_RELEVANCE_DEFAULT}) { 31 {int relevance: DART_RELEVANCE_DEFAULT}) {
32 return assertSuggestClassTypeAlias(name, relevance); 32 return assertSuggestClassTypeAlias(name, relevance);
33 } 33 }
34 34
35 @override 35 @override
36 CompletionSuggestion assertSuggestLocalConstructor(String name) {
37 return assertSuggestConstructor(name);
38 }
39
40 @override
36 CompletionSuggestion assertSuggestLocalField(String name, String type, 41 CompletionSuggestion assertSuggestLocalField(String name, String type,
37 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) { 42 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) {
38 return assertSuggestField(name, type, 43 return assertSuggestField(name, type,
39 relevance: relevance, isDeprecated: deprecated); 44 relevance: relevance, isDeprecated: deprecated);
40 } 45 }
41 46
42 @override 47 @override
43 CompletionSuggestion assertSuggestLocalFunction( 48 CompletionSuggestion assertSuggestLocalFunction(
44 String name, String returnType, 49 String name, String returnType,
45 {bool deprecated: false, int relevance: DART_RELEVANCE_LOCAL_FUNCTION}) { 50 {bool deprecated: false, int relevance: DART_RELEVANCE_LOCAL_FUNCTION}) {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 CompletionSuggestion suggestion = assertSuggestLocalFunction('m', 'void'); 522 CompletionSuggestion suggestion = assertSuggestLocalFunction('m', 'void');
518 expect(suggestion.parameterNames, hasLength(2)); 523 expect(suggestion.parameterNames, hasLength(2));
519 expect(suggestion.parameterNames[0], 'x'); 524 expect(suggestion.parameterNames[0], 'x');
520 expect(suggestion.parameterTypes[0], 'dynamic'); 525 expect(suggestion.parameterTypes[0], 'dynamic');
521 expect(suggestion.parameterNames[1], 'y'); 526 expect(suggestion.parameterNames[1], 'y');
522 expect(suggestion.parameterTypes[1], 'int'); 527 expect(suggestion.parameterTypes[1], 'int');
523 expect(suggestion.requiredParameterCount, 2); 528 expect(suggestion.requiredParameterCount, 2);
524 expect(suggestion.hasNamedParameters, false); 529 expect(suggestion.hasNamedParameters, false);
525 } 530 }
526 531
532 test_InstanceCreationExpression() {
533 addTestSource('''
534 class A {foo(){var f; {var x;}}}
535 class B {B(this.x, [String boo]) { } int x;}
536 class C {C.bar({boo: 'hoo', int z: 0}) { } }
537 main() {new ^ String x = "hello";}''');
538 computeFast();
539 return computeFull((bool result) {
540 CompletionSuggestion suggestion;
541
542 suggestion = assertSuggestLocalConstructor('A');
543 expect(suggestion.element.parameters, '()');
544 expect(suggestion.element.returnType, 'A');
545 expect(suggestion.declaringType, 'A');
546 expect(suggestion.parameterNames, hasLength(0));
547 expect(suggestion.requiredParameterCount, 0);
548 expect(suggestion.hasNamedParameters, false);
549
550 suggestion = assertSuggestLocalConstructor('B');
551 expect(suggestion.element.parameters, '(int x, [String boo])');
552 expect(suggestion.element.returnType, 'B');
553 expect(suggestion.declaringType, 'B');
554 expect(suggestion.parameterNames, hasLength(2));
555 expect(suggestion.parameterNames[0], 'x');
556 expect(suggestion.parameterTypes[0], 'int');
557 expect(suggestion.parameterNames[1], 'boo');
558 expect(suggestion.parameterTypes[1], 'String');
559 expect(suggestion.requiredParameterCount, 1);
560 expect(suggestion.hasNamedParameters, false);
561
562 suggestion = assertSuggestLocalConstructor('C.bar');
563 expect(suggestion.element.parameters, '({dynamic boo, int z})');
564 expect(suggestion.element.returnType, 'C');
565 expect(suggestion.declaringType, 'C');
566 expect(suggestion.parameterNames, hasLength(2));
567 expect(suggestion.parameterNames[0], 'boo');
568 expect(suggestion.parameterTypes[0], 'dynamic');
569 expect(suggestion.parameterNames[1], 'z');
570 expect(suggestion.parameterTypes[1], 'int');
571 expect(suggestion.requiredParameterCount, 0);
572 expect(suggestion.hasNamedParameters, true);
573 });
574 }
575
527 test_method_parameters_mixed_required_and_named() { 576 test_method_parameters_mixed_required_and_named() {
528 addTestSource(''' 577 addTestSource('''
529 class A { 578 class A {
530 void m(x, {int y}) {} 579 void m(x, {int y}) {}
531 } 580 }
532 class B extends A { 581 class B extends A {
533 main() {^} 582 main() {^}
534 } 583 }
535 '''); 584 ''');
536 expect(computeFast(), isTrue); 585 expect(computeFast(), isTrue);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 assertSuggestLocalMethod('m', 'A', 'void'); 689 assertSuggestLocalMethod('m', 'A', 'void');
641 expect(suggestion.parameterNames, hasLength(2)); 690 expect(suggestion.parameterNames, hasLength(2));
642 expect(suggestion.parameterNames[0], 'x'); 691 expect(suggestion.parameterNames[0], 'x');
643 expect(suggestion.parameterTypes[0], 'dynamic'); 692 expect(suggestion.parameterTypes[0], 'dynamic');
644 expect(suggestion.parameterNames[1], 'y'); 693 expect(suggestion.parameterNames[1], 'y');
645 expect(suggestion.parameterTypes[1], 'int'); 694 expect(suggestion.parameterTypes[1], 'int');
646 expect(suggestion.requiredParameterCount, 2); 695 expect(suggestion.requiredParameterCount, 2);
647 expect(suggestion.hasNamedParameters, false); 696 expect(suggestion.hasNamedParameters, false);
648 } 697 }
649 } 698 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698