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

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

Issue 831273002: fix local setter suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 11 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/local_computer.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 show Element, 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element,
10 ElementKind; 10 ElementKind;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 name, 376 name,
377 csKind: kind, 377 csKind: kind,
378 relevance: relevance, 378 relevance: relevance,
379 elemKind: protocol.ElementKind.SETTER); 379 elemKind: protocol.ElementKind.SETTER);
380 protocol.Element element = cs.element; 380 protocol.Element element = cs.element;
381 expect(element, isNotNull); 381 expect(element, isNotNull);
382 expect(element.kind, equals(protocol.ElementKind.SETTER)); 382 expect(element.kind, equals(protocol.ElementKind.SETTER));
383 expect(element.name, equals(name)); 383 expect(element.name, equals(name));
384 // TODO (danrubel) assert setter param 384 // TODO (danrubel) assert setter param
385 //expect(element.parameters, isNull); 385 //expect(element.parameters, isNull);
386 expect(element.returnType, isNull); 386 // TODO (danrubel) it would be better if this was always null
387 if (element.returnType != null) {
388 expect(element.returnType, 'dynamic');
389 }
387 return cs; 390 return cs;
388 } 391 }
389 392
390 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType, 393 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType,
391 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 394 [CompletionRelevance relevance = CompletionRelevance.DEFAULT,
392 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 395 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
393 CompletionSuggestion cs = 396 CompletionSuggestion cs =
394 assertSuggest(name, csKind: kind, relevance: relevance); 397 assertSuggest(name, csKind: kind, relevance: relevance);
395 expect(cs.returnType, equals(returnType)); 398 expect(cs.returnType, equals(returnType));
396 protocol.Element element = cs.element; 399 protocol.Element element = cs.element;
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 CompletionSuggestion assertSuggestLocalMethod(String name, 754 CompletionSuggestion assertSuggestLocalMethod(String name,
752 String declaringType, String returnType, [CompletionRelevance relevance = 755 String declaringType, String returnType, [CompletionRelevance relevance =
753 CompletionRelevance.DEFAULT]) { 756 CompletionRelevance.DEFAULT]) {
754 if (computer is LocalComputer) { 757 if (computer is LocalComputer) {
755 return assertSuggestMethod(name, declaringType, returnType, relevance); 758 return assertSuggestMethod(name, declaringType, returnType, relevance);
756 } else { 759 } else {
757 return assertNotSuggested(name); 760 return assertNotSuggested(name);
758 } 761 }
759 } 762 }
760 763
764 CompletionSuggestion assertSuggestLocalSetter(String name,
765 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) {
766 if (computer is LocalComputer) {
767 return assertSuggestSetter(name, relevance);
768 } else {
769 return assertNotSuggested(name);
770 }
771 }
772
761 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, 773 CompletionSuggestion assertSuggestLocalTopLevelVar(String name,
762 String returnType, [CompletionRelevance relevance = 774 String returnType, [CompletionRelevance relevance =
763 CompletionRelevance.DEFAULT]) { 775 CompletionRelevance.DEFAULT]) {
764 if (computer is LocalComputer) { 776 if (computer is LocalComputer) {
765 return assertSuggestTopLevelVar(name, returnType, relevance); 777 return assertSuggestTopLevelVar(name, returnType, relevance);
766 } else { 778 } else {
767 return assertNotSuggested(name); 779 return assertNotSuggested(name);
768 } 780 }
769 } 781 }
770 782
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 int T3; 1096 int T3;
1085 var _T4;'''); // not imported 1097 var _T4;'''); // not imported
1086 addTestSource(''' 1098 addTestSource('''
1087 import "/testAB.dart"; 1099 import "/testAB.dart";
1088 import "/testCD.dart" hide D; 1100 import "/testCD.dart" hide D;
1089 import "/testEEF.dart" show EE; 1101 import "/testEEF.dart" show EE;
1090 import "/testG.dart" as g; 1102 import "/testG.dart" as g;
1091 int T5; 1103 int T5;
1092 var _T6; 1104 var _T6;
1093 String get T7 => 'hello'; 1105 String get T7 => 'hello';
1106 set T8(int value) { }
1094 Z D2() {int x;} 1107 Z D2() {int x;}
1095 class X { 1108 class X {
1109 int get clog => 8;
1110 set blog(value) { }
1096 a() { 1111 a() {
1097 var f; 1112 var f;
1098 localF(int arg1) { } 1113 localF(int arg1) { }
1099 {var x;} 1114 {var x;}
1100 ^ var r; 1115 ^ var r;
1101 } 1116 }
1102 void b() { }} 1117 void b() { }}
1103 class Z { }'''); 1118 class Z { }''');
1104 computeFast(); 1119 computeFast();
1105 return computeFull((bool result) { 1120 return computeFull((bool result) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 // false, 1152 // false,
1138 // CompletionRelevance.LOW); 1153 // CompletionRelevance.LOW);
1139 assertSuggestTopLevelVarGetterSetter('T1', 'String'); 1154 assertSuggestTopLevelVarGetterSetter('T1', 'String');
1140 assertNotSuggested('_T2'); 1155 assertNotSuggested('_T2');
1141 //assertSuggestImportedTopLevelVar('T3', 'int', CompletionRelevance.LOW); 1156 //assertSuggestImportedTopLevelVar('T3', 'int', CompletionRelevance.LOW);
1142 assertNotSuggested('_T4'); 1157 assertNotSuggested('_T4');
1143 assertSuggestLocalTopLevelVar('T5', 'int'); 1158 assertSuggestLocalTopLevelVar('T5', 'int');
1144 assertSuggestLocalTopLevelVar('_T6', null); 1159 assertSuggestLocalTopLevelVar('_T6', null);
1145 assertNotSuggested('=='); 1160 assertNotSuggested('==');
1146 assertSuggestLocalGetter('T7', 'String'); 1161 assertSuggestLocalGetter('T7', 'String');
1162 assertSuggestLocalSetter('T8');
1163 assertSuggestLocalGetter('clog', 'int');
1164 assertSuggestLocalSetter('blog');
1147 // TODO (danrubel) suggest HtmlElement as low relevance 1165 // TODO (danrubel) suggest HtmlElement as low relevance
1148 assertNotSuggested('HtmlElement'); 1166 assertNotSuggested('HtmlElement');
1149 }); 1167 });
1150 } 1168 }
1151 1169
1152 test_Block_identifier_partial() { 1170 test_Block_identifier_partial() {
1153 addSource('/testAB.dart', ''' 1171 addSource('/testAB.dart', '''
1154 export "dart:math" hide max; 1172 export "dart:math" hide max;
1155 class A {int x;} 1173 class A {int x;}
1156 @deprecated D1() {int x;} 1174 @deprecated D1() {int x;}
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 }); 2106 });
2089 } 2107 }
2090 2108
2091 test_partFile_TypeName2() { 2109 test_partFile_TypeName2() {
2092 // SimpleIdentifier TypeName ConstructorName 2110 // SimpleIdentifier TypeName ConstructorName
2093 addSource('/testB.dart', ''' 2111 addSource('/testB.dart', '''
2094 lib B; 2112 lib B;
2095 int T1; 2113 int T1;
2096 F1() { } 2114 F1() { }
2097 class X {X.c(); X._d(); z() {}}'''); 2115 class X {X.c(); X._d(); z() {}}''');
2098 addSource('/testA.dart',''' 2116 addSource('/testA.dart', '''
2099 part of libA; 2117 part of libA;
2100 class B { }'''); 2118 class B { }''');
2101 addTestSource( ''' 2119 addTestSource('''
2102 library libA; 2120 library libA;
2103 import "/testB.dart"; 2121 import "/testB.dart";
2104 part "/testA.dart"; 2122 part "/testA.dart";
2105 class A { } 2123 class A { }
2106 main() {new ^} 2124 main() {new ^}
2107 var m;'''); 2125 var m;''');
2108 computeFast(); 2126 computeFast();
2109 return computeFull((bool result) { 2127 return computeFull((bool result) {
2110 assertSuggestLocalClass('A'); 2128 assertSuggestLocalClass('A');
2111 assertSuggestImportedClass('Object'); 2129 assertSuggestImportedClass('Object');
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 assertNotSuggested('bar2'); 2514 assertNotSuggested('bar2');
2497 assertNotSuggested('_B'); 2515 assertNotSuggested('_B');
2498 assertSuggestLocalClass('Y'); 2516 assertSuggestLocalClass('Y');
2499 assertSuggestLocalClass('C'); 2517 assertSuggestLocalClass('C');
2500 assertSuggestLocalVariable('f', null); 2518 assertSuggestLocalVariable('f', null);
2501 assertNotSuggested('x'); 2519 assertNotSuggested('x');
2502 assertNotSuggested('e'); 2520 assertNotSuggested('e');
2503 }); 2521 });
2504 } 2522 }
2505 } 2523 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/local_computer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698