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

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

Issue 1260593005: update suggestion element return type to have type param (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 services.completion.contributor.dart.invocation; 5 library services.completion.contributor.dart.invocation;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 9 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
10 import 'package:analysis_server/src/services/completion/local_declaration_visito r.dart'; 10 import 'package:analysis_server/src/services/completion/local_declaration_visito r.dart';
11 import 'package:analysis_server/src/services/completion/local_suggestion_builder .dart'; 11 import 'package:analysis_server/src/services/completion/local_suggestion_builder .dart'
12 hide createSuggestion;
12 import 'package:analysis_server/src/services/completion/optype.dart'; 13 import 'package:analysis_server/src/services/completion/optype.dart';
13 import 'package:analysis_server/src/services/completion/suggestion_builder.dart' ; 14 import 'package:analysis_server/src/services/completion/suggestion_builder.dart' ;
15 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
16 show createSuggestion;
14 import 'package:analyzer/src/generated/ast.dart'; 17 import 'package:analyzer/src/generated/ast.dart';
15 import 'package:analyzer/src/generated/element.dart'; 18 import 'package:analyzer/src/generated/element.dart';
16 19
17 import '../../protocol_server.dart' 20 import '../../protocol_server.dart'
18 show CompletionSuggestion, CompletionSuggestionKind; 21 show CompletionSuggestion, CompletionSuggestionKind;
19 import '../../protocol_server.dart' as protocol; 22 import '../../protocol_server.dart' as protocol;
20 23
21 /** 24 /**
22 * A contributor for calculating invocation / access suggestions 25 * A contributor for calculating invocation / access suggestions
23 * `completion.getSuggestions` request results. 26 * `completion.getSuggestions` request results.
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (directive is ImportDirective) { 401 if (directive is ImportDirective) {
399 if (directive.prefix != null) { 402 if (directive.prefix != null) {
400 if (directive.prefix.name == element.name) { 403 if (directive.prefix.name == element.name) {
401 // Suggest elements from the imported library 404 // Suggest elements from the imported library
402 LibraryElement library = directive.uriElement; 405 LibraryElement library = directive.uriElement;
403 LibraryElementSuggestionBuilder.suggestionsFor(request, 406 LibraryElementSuggestionBuilder.suggestionsFor(request,
404 CompletionSuggestionKind.INVOCATION, library, 407 CompletionSuggestionKind.INVOCATION, library,
405 request.target.containingNode.parent is TypeName); 408 request.target.containingNode.parent is TypeName);
406 modified = true; 409 modified = true;
407 if (directive.deferredKeyword != null) { 410 if (directive.deferredKeyword != null) {
408 String completion = 'loadLibrary'; 411 FunctionElement loadLibFunct = library.loadLibraryFunction;
409 CompletionSuggestion suggestion = new CompletionSuggestion( 412 request.addSuggestion(createSuggestion(loadLibFunct));
410 CompletionSuggestionKind.INVOCATION, DART_RELEVANCE_DEFAULT,
411 completion, completion.length, 0, false, false,
412 parameterNames: [],
413 parameterTypes: [],
414 requiredParameterCount: 0,
415 hasNamedParameters: false,
416 returnType: 'void');
417 suggestion.element = new protocol.Element(
418 protocol.ElementKind.FUNCTION, completion,
419 protocol.Element.makeFlags(),
420 parameters: '()', returnType: 'void');
421 request.addSuggestion(suggestion);
422 } 413 }
423 } 414 }
424 } 415 }
425 } 416 }
426 } 417 }
427 return new Future.value(modified); 418 return new Future.value(modified);
428 } 419 }
429 420
430 @override 421 @override
431 Future<bool> visitPropertyAccessorElement(PropertyAccessorElement element) { 422 Future<bool> visitPropertyAccessorElement(PropertyAccessorElement element) {
432 if (element != null) { 423 if (element != null) {
433 PropertyInducingElement elemVar = element.variable; 424 PropertyInducingElement elemVar = element.variable;
434 if (elemVar != null) { 425 if (elemVar != null) {
435 InterfaceTypeSuggestionBuilder.suggestionsFor(request, elemVar.type); 426 InterfaceTypeSuggestionBuilder.suggestionsFor(request, elemVar.type);
436 } 427 }
437 return new Future.value(true); 428 return new Future.value(true);
438 } 429 }
439 return new Future.value(false); 430 return new Future.value(false);
440 } 431 }
441 432
442 @override 433 @override
443 Future<bool> visitVariableElement(VariableElement element) { 434 Future<bool> visitVariableElement(VariableElement element) {
444 InterfaceTypeSuggestionBuilder.suggestionsFor(request, element.type); 435 InterfaceTypeSuggestionBuilder.suggestionsFor(request, element.type);
445 return new Future.value(true); 436 return new Future.value(true);
446 } 437 }
447 } 438 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698