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

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

Issue 1380223003: Issue 23694. Include 'docSummary' and 'docComplete' into CompletionSuggestion. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: tweak Created 5 years, 2 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
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/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/protocol.dart' as protocol 10 import 'package:analysis_server/src/protocol.dart' as protocol
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 CompletionSuggestion assertSuggest(String completion, 115 CompletionSuggestion assertSuggest(String completion,
116 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION, 116 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION,
117 int relevance: DART_RELEVANCE_DEFAULT, 117 int relevance: DART_RELEVANCE_DEFAULT,
118 String importUri, 118 String importUri,
119 protocol.ElementKind elemKind: null, 119 protocol.ElementKind elemKind: null,
120 bool isDeprecated: false, 120 bool isDeprecated: false,
121 bool isPotential: false, 121 bool isPotential: false,
122 String elemFile, 122 String elemFile,
123 int elemOffset}) { 123 int elemOffset,
124 docCompleteMatcher,
125 docSummaryMatcher}) {
124 CompletionSuggestion cs = 126 CompletionSuggestion cs =
125 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind); 127 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind);
126 if (cs == null) { 128 if (cs == null) {
127 failedCompletion( 129 failedCompletion(
128 'expected $completion $csKind $elemKind', request.suggestions); 130 'expected $completion $csKind $elemKind', request.suggestions);
129 } 131 }
130 expect(cs.kind, equals(csKind)); 132 expect(cs.kind, equals(csKind));
131 if (isDeprecated) { 133 if (isDeprecated) {
132 expect(cs.relevance, equals(DART_RELEVANCE_LOW)); 134 expect(cs.relevance, equals(DART_RELEVANCE_LOW));
133 } else { 135 } else {
(...skipping 11 matching lines...) Expand all
145 expect(cs.element.location.length, isNotNull); 147 expect(cs.element.location.length, isNotNull);
146 expect(cs.element.location.startColumn, isNotNull); 148 expect(cs.element.location.startColumn, isNotNull);
147 expect(cs.element.location.startLine, isNotNull); 149 expect(cs.element.location.startLine, isNotNull);
148 } 150 }
149 if (elemFile != null) { 151 if (elemFile != null) {
150 expect(cs.element.location.file, elemFile); 152 expect(cs.element.location.file, elemFile);
151 } 153 }
152 if (elemOffset != null) { 154 if (elemOffset != null) {
153 expect(cs.element.location.offset, elemOffset); 155 expect(cs.element.location.offset, elemOffset);
154 } 156 }
157 if (docCompleteMatcher != null) {
158 expect(cs.docComplete, docCompleteMatcher);
159 }
160 if (docSummaryMatcher != null) {
161 expect(cs.docSummary, docSummaryMatcher);
162 }
155 return cs; 163 return cs;
156 } 164 }
157 165
158 CompletionSuggestion assertSuggestClass(String name, 166 CompletionSuggestion assertSuggestClass(String name,
159 {int relevance: DART_RELEVANCE_DEFAULT, 167 {int relevance: DART_RELEVANCE_DEFAULT,
160 String importUri, 168 String importUri,
161 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 169 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
162 bool isDeprecated: false, 170 bool isDeprecated: false,
163 String elemFile, 171 String elemFile,
164 int elemOffset}) { 172 int elemOffset,
173 docCompleteMatcher,
174 docSummaryMatcher}) {
165 CompletionSuggestion cs = assertSuggest(name, 175 CompletionSuggestion cs = assertSuggest(name,
166 csKind: kind, 176 csKind: kind,
167 relevance: relevance, 177 relevance: relevance,
168 importUri: importUri, 178 importUri: importUri,
169 isDeprecated: isDeprecated, 179 isDeprecated: isDeprecated,
170 elemFile: elemFile, 180 elemFile: elemFile,
171 elemOffset: elemOffset); 181 elemOffset: elemOffset,
182 docCompleteMatcher: docCompleteMatcher,
183 docSummaryMatcher: docSummaryMatcher);
172 protocol.Element element = cs.element; 184 protocol.Element element = cs.element;
173 expect(element, isNotNull); 185 expect(element, isNotNull);
174 expect(element.kind, equals(protocol.ElementKind.CLASS)); 186 expect(element.kind, equals(protocol.ElementKind.CLASS));
175 expect(element.name, equals(name)); 187 expect(element.name, equals(name));
176 expect(element.parameters, isNull); 188 expect(element.parameters, isNull);
177 expect(element.returnType, isNull); 189 expect(element.returnType, isNull);
178 assertHasNoParameterInfo(cs); 190 assertHasNoParameterInfo(cs);
179 return cs; 191 return cs;
180 } 192 }
181 193
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // The returnType represents the type of a field 241 // The returnType represents the type of a field
230 expect(element.returnType, type != null ? type : 'dynamic'); 242 expect(element.returnType, type != null ? type : 'dynamic');
231 assertHasNoParameterInfo(cs); 243 assertHasNoParameterInfo(cs);
232 return cs; 244 return cs;
233 } 245 }
234 246
235 CompletionSuggestion assertSuggestFunction(String name, String returnType, 247 CompletionSuggestion assertSuggestFunction(String name, String returnType,
236 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 248 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
237 bool deprecated: false, 249 bool deprecated: false,
238 int relevance: DART_RELEVANCE_DEFAULT, 250 int relevance: DART_RELEVANCE_DEFAULT,
239 String importUri}) { 251 String importUri,
252 docCompleteMatcher,
253 docSummaryMatcher}) {
240 CompletionSuggestion cs = assertSuggest(name, 254 CompletionSuggestion cs = assertSuggest(name,
241 csKind: kind, 255 csKind: kind,
242 relevance: relevance, 256 relevance: relevance,
243 importUri: importUri, 257 importUri: importUri,
244 isDeprecated: deprecated); 258 isDeprecated: deprecated,
259 docCompleteMatcher: docCompleteMatcher,
260 docSummaryMatcher: docSummaryMatcher);
245 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 261 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
246 protocol.Element element = cs.element; 262 protocol.Element element = cs.element;
247 expect(element, isNotNull); 263 expect(element, isNotNull);
248 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); 264 expect(element.kind, equals(protocol.ElementKind.FUNCTION));
249 expect(element.name, equals(name)); 265 expect(element.name, equals(name));
250 expect(element.isDeprecated, equals(deprecated)); 266 expect(element.isDeprecated, equals(deprecated));
251 String param = element.parameters; 267 String param = element.parameters;
252 expect(param, isNotNull); 268 expect(param, isNotNull);
253 expect(param[0], equals('(')); 269 expect(param[0], equals('('));
254 expect(param[param.length - 1], equals(')')); 270 expect(param[param.length - 1], equals(')'));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 347 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
332 // Library prefix should only be suggested by ImportedReferenceContributor 348 // Library prefix should only be suggested by ImportedReferenceContributor
333 return assertNotSuggested(prefix); 349 return assertNotSuggested(prefix);
334 } 350 }
335 351
336 CompletionSuggestion assertSuggestMethod( 352 CompletionSuggestion assertSuggestMethod(
337 String name, String declaringType, String returnType, 353 String name, String declaringType, String returnType,
338 {int relevance: DART_RELEVANCE_DEFAULT, 354 {int relevance: DART_RELEVANCE_DEFAULT,
339 String importUri, 355 String importUri,
340 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 356 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
341 bool isDeprecated: false}) { 357 bool isDeprecated: false,
358 docCompleteMatcher,
359 docSummaryMatcher}) {
342 CompletionSuggestion cs = assertSuggest(name, 360 CompletionSuggestion cs = assertSuggest(name,
343 csKind: kind, 361 csKind: kind,
344 relevance: relevance, 362 relevance: relevance,
345 importUri: importUri, 363 importUri: importUri,
346 isDeprecated: isDeprecated); 364 isDeprecated: isDeprecated,
365 docCompleteMatcher: docCompleteMatcher,
366 docSummaryMatcher: docSummaryMatcher);
347 expect(cs.declaringType, equals(declaringType)); 367 expect(cs.declaringType, equals(declaringType));
348 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 368 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
349 protocol.Element element = cs.element; 369 protocol.Element element = cs.element;
350 expect(element, isNotNull); 370 expect(element, isNotNull);
351 expect(element.kind, equals(protocol.ElementKind.METHOD)); 371 expect(element.kind, equals(protocol.ElementKind.METHOD));
352 expect(element.name, equals(name)); 372 expect(element.name, equals(name));
353 String param = element.parameters; 373 String param = element.parameters;
354 expect(param, isNotNull); 374 expect(param, isNotNull);
355 expect(param[0], equals('(')); 375 expect(param[0], equals('('));
356 expect(param[param.length - 1], equals(')')); 376 expect(param[param.length - 1], equals(')'));
(...skipping 4346 matching lines...) Expand 10 before | Expand all | Expand 10 after
4703 assertNotSuggested('bar2'); 4723 assertNotSuggested('bar2');
4704 assertNotSuggested('_B'); 4724 assertNotSuggested('_B');
4705 assertSuggestLocalClass('Y'); 4725 assertSuggestLocalClass('Y');
4706 assertSuggestLocalClass('C'); 4726 assertSuggestLocalClass('C');
4707 assertSuggestLocalVariable('f', null); 4727 assertSuggestLocalVariable('f', null);
4708 assertNotSuggested('x'); 4728 assertNotSuggested('x');
4709 assertNotSuggested('e'); 4729 assertNotSuggested('e');
4710 }); 4730 });
4711 } 4731 }
4712 } 4732 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698