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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/local_computer.dart

Issue 962243003: fix constructor suggestion element names (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge 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 services.completion.computer.dart.local; 5 library services.completion.computer.dart.local;
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 190
191 /** 191 /**
192 * For the given class and constructor, 192 * For the given class and constructor,
193 * add a suggestion of the form B(...) or B.name(...). 193 * add a suggestion of the form B(...) or B.name(...).
194 * If the given constructor is `null` 194 * If the given constructor is `null`
195 * then add a default constructor suggestion. 195 * then add a default constructor suggestion.
196 */ 196 */
197 CompletionSuggestion _addSuggestion( 197 CompletionSuggestion _addSuggestion(
198 ClassDeclaration classDecl, ConstructorDeclaration constructorDecl) { 198 ClassDeclaration classDecl, ConstructorDeclaration constructorDecl) {
199 SimpleIdentifier elemId;
199 String completion = classDecl.name.name; 200 String completion = classDecl.name.name;
200 if (constructorDecl != null) { 201 if (constructorDecl != null) {
201 SimpleIdentifier elemId = constructorDecl.name; 202 elemId = constructorDecl.name;
202 if (elemId != null) { 203 if (elemId != null) {
203 String name = elemId.name; 204 String name = elemId.name;
204 if (name != null && name.length > 0) { 205 if (name != null && name.length > 0) {
205 completion = '$completion.$name'; 206 completion = '$completion.$name';
206 } 207 }
207 } 208 }
208 } 209 }
209 bool isDeprecated = 210 bool isDeprecated =
210 constructorDecl != null && _isDeprecated(constructorDecl); 211 constructorDecl != null && _isDeprecated(constructorDecl);
211 List<String> parameterNames = new List<String>(); 212 List<String> parameterNames = new List<String>();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 paramBuf.write(' '); 244 paramBuf.write(' ');
244 paramBuf.write(paramName); 245 paramBuf.write(paramName);
245 ++paramCount; 246 ++paramCount;
246 } 247 }
247 } 248 }
248 if (paramCount > requiredParameterCount) { 249 if (paramCount > requiredParameterCount) {
249 paramBuf.write(hasNamedParameters ? '}' : ']'); 250 paramBuf.write(hasNamedParameters ? '}' : ']');
250 } 251 }
251 paramBuf.write(')'); 252 paramBuf.write(')');
252 protocol.Element element = _createElement( 253 protocol.Element element = _createElement(
253 protocol.ElementKind.CONSTRUCTOR, null, 254 protocol.ElementKind.CONSTRUCTOR, elemId,
254 parameters: paramBuf.toString()); 255 parameters: paramBuf.toString());
255 element.name = completion;
256 element.returnType = classDecl.name.name; 256 element.returnType = classDecl.name.name;
257 CompletionSuggestion suggestion = new CompletionSuggestion( 257 CompletionSuggestion suggestion = new CompletionSuggestion(
258 CompletionSuggestionKind.INVOCATION, 258 CompletionSuggestionKind.INVOCATION,
259 isDeprecated ? DART_RELEVANCE_LOW : DART_RELEVANCE_DEFAULT, completion, 259 isDeprecated ? DART_RELEVANCE_LOW : DART_RELEVANCE_DEFAULT, completion,
260 completion.length, 0, isDeprecated, false, 260 completion.length, 0, isDeprecated, false,
261 declaringType: classDecl.name.name, 261 declaringType: classDecl.name.name,
262 element: element, 262 element: element,
263 parameterNames: parameterNames, 263 parameterNames: parameterNames,
264 parameterTypes: parameterTypes, 264 parameterTypes: parameterTypes,
265 requiredParameterCount: requiredParameterCount, 265 requiredParameterCount: requiredParameterCount,
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 bool _isVoid(TypeName returnType) { 682 bool _isVoid(TypeName returnType) {
683 if (returnType != null) { 683 if (returnType != null) {
684 Identifier id = returnType.name; 684 Identifier id = returnType.name;
685 if (id != null && id.name == 'void') { 685 if (id != null && id.name == 'void') {
686 return true; 686 return true;
687 } 687 }
688 } 688 }
689 return false; 689 return false;
690 } 690 }
691 } 691 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698