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

Side by Side Diff: pkg/analysis_server/test/services/completion/completion_test_util.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.util; 5 library test.services.completion.util;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol 9 import 'package:analysis_server/src/protocol.dart' as protocol
10 show Element, ElementKind; 10 show Element, ElementKind;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 protocol.Element element = cs.element; 194 protocol.Element element = cs.element;
195 expect(element, isNotNull); 195 expect(element, isNotNull);
196 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS)); 196 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS));
197 expect(element.name, equals(name)); 197 expect(element.name, equals(name));
198 expect(element.parameters, isNull); 198 expect(element.parameters, isNull);
199 expect(element.returnType, isNull); 199 expect(element.returnType, isNull);
200 assertHasNoParameterInfo(cs); 200 assertHasNoParameterInfo(cs);
201 return cs; 201 return cs;
202 } 202 }
203 203
204 CompletionSuggestion assertSuggestConstructor(String name) {
205 CompletionSuggestion cs = assertSuggest(name);
206 protocol.Element element = cs.element;
207 expect(element, isNotNull);
208 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR));
209 expect(element.name, name);
210 return cs;
211 }
212
204 CompletionSuggestion assertSuggestField(String name, String type, 213 CompletionSuggestion assertSuggestField(String name, String type,
205 {int relevance: DART_RELEVANCE_DEFAULT, 214 {int relevance: DART_RELEVANCE_DEFAULT,
206 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 215 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
207 bool isDeprecated: false}) { 216 bool isDeprecated: false}) {
208 CompletionSuggestion cs = assertSuggest(name, 217 CompletionSuggestion cs = assertSuggest(name,
209 csKind: kind, 218 csKind: kind,
210 relevance: relevance, 219 relevance: relevance,
211 elemKind: protocol.ElementKind.FIELD, 220 elemKind: protocol.ElementKind.FIELD,
212 isDeprecated: isDeprecated); 221 isDeprecated: isDeprecated);
213 // The returnType represents the type of a field 222 // The returnType represents the type of a field
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 CompletionSuggestion assertSuggestImportedClass(String name, 570 CompletionSuggestion assertSuggestImportedClass(String name,
562 [int relevance = DART_RELEVANCE_DEFAULT, 571 [int relevance = DART_RELEVANCE_DEFAULT,
563 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 572 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
564 if (computer is ImportedComputer) { 573 if (computer is ImportedComputer) {
565 return assertSuggestClass(name, relevance: relevance, kind: kind); 574 return assertSuggestClass(name, relevance: relevance, kind: kind);
566 } else { 575 } else {
567 return assertNotSuggested(name); 576 return assertNotSuggested(name);
568 } 577 }
569 } 578 }
570 579
580 CompletionSuggestion assertSuggestImportedConstructor(String name) {
581 return assertNotSuggested(name);
582 }
583
571 CompletionSuggestion assertSuggestImportedField(String name, String type, 584 CompletionSuggestion assertSuggestImportedField(String name, String type,
572 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) { 585 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) {
573 return assertNotSuggested(name); 586 return assertNotSuggested(name);
574 } 587 }
575 588
576 CompletionSuggestion assertSuggestImportedFunction( 589 CompletionSuggestion assertSuggestImportedFunction(
577 String name, String returnType, [bool isDeprecated = false, 590 String name, String returnType, [bool isDeprecated = false,
578 int relevance = DART_RELEVANCE_DEFAULT, 591 int relevance = DART_RELEVANCE_DEFAULT,
579 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 592 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
580 if (computer is ImportedComputer) { 593 if (computer is ImportedComputer) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 CompletionSuggestion assertSuggestLocalClass(String name, 695 CompletionSuggestion assertSuggestLocalClass(String name,
683 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { 696 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) {
684 return assertNotSuggested(name); 697 return assertNotSuggested(name);
685 } 698 }
686 699
687 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, 700 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name,
688 {int relevance: DART_RELEVANCE_DEFAULT}) { 701 {int relevance: DART_RELEVANCE_DEFAULT}) {
689 return assertNotSuggested(name); 702 return assertNotSuggested(name);
690 } 703 }
691 704
705 CompletionSuggestion assertSuggestLocalConstructor(String name) {
706 return assertNotSuggested(name);
707 }
708
692 CompletionSuggestion assertSuggestLocalField(String name, String type, 709 CompletionSuggestion assertSuggestLocalField(String name, String type,
693 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) { 710 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) {
694 return assertNotSuggested(name); 711 return assertNotSuggested(name);
695 } 712 }
696 713
697 CompletionSuggestion assertSuggestLocalFunction( 714 CompletionSuggestion assertSuggestLocalFunction(
698 String name, String returnType, 715 String name, String returnType,
699 {bool deprecated: false, int relevance: DART_RELEVANCE_LOCAL_FUNCTION}) { 716 {bool deprecated: false, int relevance: DART_RELEVANCE_LOCAL_FUNCTION}) {
700 return assertNotSuggested(name); 717 return assertNotSuggested(name);
701 } 718 }
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 // TODO (danrubel) getter is being suggested instead of top level var 2122 // TODO (danrubel) getter is being suggested instead of top level var
2106 //assertSuggestImportedTopLevelVar('T1', 'int'); 2123 //assertSuggestImportedTopLevelVar('T1', 'int');
2107 }); 2124 });
2108 } 2125 }
2109 2126
2110 test_InstanceCreationExpression_imported() { 2127 test_InstanceCreationExpression_imported() {
2111 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression 2128 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
2112 addSource('/testA.dart', ''' 2129 addSource('/testA.dart', '''
2113 int T1; 2130 int T1;
2114 F1() { } 2131 F1() { }
2115 class A {int x;}'''); 2132 class A {A(this.x) { } int x;}''');
2116 addTestSource(''' 2133 addTestSource('''
2117 import "/testA.dart"; 2134 import "/testA.dart";
2118 int T2; 2135 int T2;
2119 F2() { } 2136 F2() { }
2120 class B {int x;} 2137 class B {B(this.x, [String boo]) { } int x;}
2121 class C {foo(){var f; {var x;} new ^}}'''); 2138 class C {foo(){var f; {var x;} new ^}}''');
2122 computeFast(); 2139 computeFast();
2123 return computeFull((bool result) { 2140 return computeFull((bool result) {
2124 expect(request.replacementOffset, completionOffset); 2141 expect(request.replacementOffset, completionOffset);
2125 expect(request.replacementLength, 0); 2142 expect(request.replacementLength, 0);
2126 assertSuggestImportedClass('Object'); 2143 assertSuggestImportedConstructor('Object');
2127 assertSuggestImportedClass('A'); 2144 assertSuggestImportedConstructor('A');
2128 assertSuggestLocalClass('B'); 2145 assertSuggestLocalConstructor('B');
2129 assertSuggestLocalClass('C'); 2146 assertSuggestLocalConstructor('C');
2130 assertNotSuggested('f'); 2147 assertNotSuggested('f');
2131 assertNotSuggested('x'); 2148 assertNotSuggested('x');
2132 assertNotSuggested('foo'); 2149 assertNotSuggested('foo');
2133 assertNotSuggested('F1'); 2150 assertNotSuggested('F1');
2134 assertNotSuggested('F2'); 2151 assertNotSuggested('F2');
2135 assertNotSuggested('T1'); 2152 assertNotSuggested('T1');
2136 assertNotSuggested('T2'); 2153 assertNotSuggested('T2');
2137 }); 2154 });
2138 } 2155 }
2139 2156
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2477 F1() { } 2494 F1() { }
2478 class X {X.c(); X._d(); z() {}}'''); 2495 class X {X.c(); X._d(); z() {}}''');
2479 addSource('/testA.dart', ''' 2496 addSource('/testA.dart', '''
2480 library libA; 2497 library libA;
2481 import "/testB.dart"; 2498 import "/testB.dart";
2482 part "$testFile"; 2499 part "$testFile";
2483 class A { } 2500 class A { }
2484 var m;'''); 2501 var m;''');
2485 addTestSource(''' 2502 addTestSource('''
2486 part of libA; 2503 part of libA;
2487 class B { } 2504 class B { factory B.bar(int x) => null; }
2488 main() {new ^}'''); 2505 main() {new ^}''');
2489 computeFast(); 2506 computeFast();
2490 return computeFull((bool result) { 2507 return computeFull((bool result) {
2491 expect(request.replacementOffset, completionOffset); 2508 expect(request.replacementOffset, completionOffset);
2492 expect(request.replacementLength, 0); 2509 expect(request.replacementLength, 0);
2493 assertSuggestLocalClass('B'); 2510 assertSuggestLocalConstructor('B.bar');
2494 assertSuggestImportedClass('Object'); 2511 assertSuggestImportedConstructor('Object');
2495 assertSuggestImportedClass('X'); 2512 assertSuggestImportedConstructor('X.c');
2496 assertSuggestNonLocalClass('A'); 2513 assertNotSuggested('X._d');
2514 assertSuggestImportedConstructor('A');
2497 assertNotSuggested('F1'); 2515 assertNotSuggested('F1');
2498 assertNotSuggested('T1'); 2516 assertNotSuggested('T1');
2499 assertNotSuggested('_d'); 2517 assertNotSuggested('_d');
2500 assertNotSuggested('z'); 2518 assertNotSuggested('z');
2501 assertNotSuggested('m'); 2519 assertNotSuggested('m');
2502 }); 2520 });
2503 } 2521 }
2504 2522
2505 test_partFile_TypeName2() { 2523 test_partFile_TypeName2() {
2506 // SimpleIdentifier TypeName ConstructorName 2524 // SimpleIdentifier TypeName ConstructorName
2507 addSource('/testB.dart', ''' 2525 addSource('/testB.dart', '''
2508 lib B; 2526 lib B;
2509 int T1; 2527 int T1;
2510 F1() { } 2528 F1() { }
2511 class X {X.c(); X._d(); z() {}}'''); 2529 class X {X.c(); X._d(); z() {}}''');
2512 addSource('/testA.dart', ''' 2530 addSource('/testA.dart', '''
2513 part of libA; 2531 part of libA;
2514 class B { }'''); 2532 class B { }''');
2515 addTestSource(''' 2533 addTestSource('''
2516 library libA; 2534 library libA;
2517 import "/testB.dart"; 2535 import "/testB.dart";
2518 part "/testA.dart"; 2536 part "/testA.dart";
2519 class A { } 2537 class A { A({String boo: 'hoo'}) { } }
2520 main() {new ^} 2538 main() {new ^}
2521 var m;'''); 2539 var m;''');
2522 computeFast(); 2540 computeFast();
2523 return computeFull((bool result) { 2541 return computeFull((bool result) {
2524 expect(request.replacementOffset, completionOffset); 2542 expect(request.replacementOffset, completionOffset);
2525 expect(request.replacementLength, 0); 2543 expect(request.replacementLength, 0);
2526 assertSuggestLocalClass('A'); 2544 assertSuggestLocalConstructor('A');
2527 assertSuggestImportedClass('Object'); 2545 assertSuggestImportedConstructor('Object');
2528 assertSuggestImportedClass('X'); 2546 assertSuggestImportedConstructor('X.c');
2529 assertSuggestNonLocalClass('B'); 2547 assertNotSuggested('X._d');
2548 assertSuggestImportedConstructor('B');
2530 assertNotSuggested('F1'); 2549 assertNotSuggested('F1');
2531 assertNotSuggested('T1'); 2550 assertNotSuggested('T1');
2532 assertNotSuggested('_d'); 2551 assertNotSuggested('_d');
2533 assertNotSuggested('z'); 2552 assertNotSuggested('z');
2534 assertNotSuggested('m'); 2553 assertNotSuggested('m');
2535 }); 2554 });
2536 } 2555 }
2537 2556
2538 test_PrefixedIdentifier_class_const() { 2557 test_PrefixedIdentifier_class_const() {
2539 // SimpleIdentifier PrefixedIdentifier ExpressionStatement Block 2558 // SimpleIdentifier PrefixedIdentifier ExpressionStatement Block
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
3048 assertNotSuggested('bar2'); 3067 assertNotSuggested('bar2');
3049 assertNotSuggested('_B'); 3068 assertNotSuggested('_B');
3050 assertSuggestLocalClass('Y'); 3069 assertSuggestLocalClass('Y');
3051 assertSuggestLocalClass('C'); 3070 assertSuggestLocalClass('C');
3052 assertSuggestLocalVariable('f', null); 3071 assertSuggestLocalVariable('f', null);
3053 assertNotSuggested('x'); 3072 assertNotSuggested('x');
3054 assertNotSuggested('e'); 3073 assertNotSuggested('e');
3055 }); 3074 });
3056 } 3075 }
3057 } 3076 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698