| Index: pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
|
| index f951371e8f281e33ee1217315eda96ebd9191eb7..c226403d43be9fb468d0f489cd6c779b52c47648 100644
|
| --- a/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
|
| +++ b/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
|
| @@ -8,8 +8,8 @@ import 'dart:async';
|
| import 'dart:collection';
|
|
|
| import 'package:analysis_server/src/protocol_server.dart' as protocol;
|
| -import 'package:analysis_server/src/protocol_server.dart' hide Element,
|
| - ElementKind;
|
| +import 'package:analysis_server/src/protocol_server.dart'
|
| + hide Element, ElementKind;
|
| import 'package:analysis_server/src/services/completion/dart_completion_manager.dart';
|
| import 'package:analyzer/src/generated/ast.dart';
|
| import 'package:analyzer/src/generated/element.dart';
|
| @@ -24,7 +24,6 @@ const String DYNAMIC = 'dynamic';
|
| CompletionSuggestion createSuggestion(Element element,
|
| {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
|
| int relevance: DART_RELEVANCE_DEFAULT}) {
|
| -
|
| String nameForType(DartType type) {
|
| if (type == null) {
|
| return DYNAMIC;
|
| @@ -56,14 +55,9 @@ CompletionSuggestion createSuggestion(Element element,
|
|
|
| String completion = element.displayName;
|
| bool isDeprecated = element.isDeprecated;
|
| - CompletionSuggestion suggestion = new CompletionSuggestion(
|
| - kind,
|
| - isDeprecated ? DART_RELEVANCE_LOW : relevance,
|
| - completion,
|
| - completion.length,
|
| - 0,
|
| - isDeprecated,
|
| - false);
|
| + CompletionSuggestion suggestion = new CompletionSuggestion(kind,
|
| + isDeprecated ? DART_RELEVANCE_LOW : relevance, completion,
|
| + completion.length, 0, isDeprecated, false);
|
| suggestion.element = protocol.newElement_fromEngine(element);
|
| Element enclosingElement = element.enclosingElement;
|
| if (enclosingElement is ClassElement) {
|
| @@ -71,15 +65,18 @@ CompletionSuggestion createSuggestion(Element element,
|
| }
|
| suggestion.returnType = returnType;
|
| if (element is ExecutableElement && element is! PropertyAccessorElement) {
|
| - suggestion.parameterNames = element.parameters.map(
|
| - (ParameterElement parameter) => parameter.name).toList();
|
| - suggestion.parameterTypes = element.parameters.map(
|
| - (ParameterElement parameter) => parameter.type.displayName).toList();
|
| + suggestion.parameterNames = element.parameters
|
| + .map((ParameterElement parameter) => parameter.name)
|
| + .toList();
|
| + suggestion.parameterTypes = element.parameters
|
| + .map((ParameterElement parameter) => parameter.type.displayName)
|
| + .toList();
|
| suggestion.requiredParameterCount = element.parameters.where(
|
| (ParameterElement parameter) =>
|
| parameter.parameterKind == ParameterKind.REQUIRED).length;
|
| suggestion.hasNamedParameters = element.parameters.any(
|
| - (ParameterElement parameter) => parameter.parameterKind == ParameterKind.NAMED);
|
| + (ParameterElement parameter) =>
|
| + parameter.parameterKind == ParameterKind.NAMED);
|
| }
|
| return suggestion;
|
| }
|
| @@ -89,7 +86,6 @@ CompletionSuggestion createSuggestion(Element element,
|
| * that is defined in the given class.
|
| */
|
| visitInheritedTypeNames(ClassDeclaration node, void inherited(String name)) {
|
| -
|
| void visit(TypeName type) {
|
| if (type != null) {
|
| Identifier id = type.name;
|
| @@ -133,8 +129,8 @@ visitInheritedTypeNames(ClassDeclaration node, void inherited(String name)) {
|
| * For each class identifier in the hierarchy that is not defined locally,
|
| * call the [imported] function.
|
| */
|
| -void visitInheritedTypes(ClassDeclaration node, void
|
| - local(ClassDeclaration classNode), void imported(String typeName)) {
|
| +void visitInheritedTypes(ClassDeclaration node,
|
| + void local(ClassDeclaration classNode), void imported(String typeName)) {
|
| CompilationUnit unit = node.getAncestor((p) => p is CompilationUnit);
|
| List<ClassDeclaration> todo = new List<ClassDeclaration>();
|
| todo.add(node);
|
| @@ -205,7 +201,8 @@ abstract class ElementSuggestionBuilder {
|
| !_completions.add(completion)) {
|
| return;
|
| }
|
| - CompletionSuggestion suggestion = createSuggestion(element, kind: kind, relevance: relevance);
|
| + CompletionSuggestion suggestion =
|
| + createSuggestion(element, kind: kind, relevance: relevance);
|
| if (suggestion != null) {
|
| request.suggestions.add(suggestion);
|
| }
|
| @@ -272,8 +269,8 @@ class InterfaceTypeSuggestionBuilder {
|
| }
|
| }
|
| String identifier = element.displayName;
|
| - int alreadyGenerated =
|
| - _completionTypesGenerated.putIfAbsent(identifier, () => _COMPLETION_TYPE_NONE);
|
| + int alreadyGenerated = _completionTypesGenerated.putIfAbsent(
|
| + identifier, () => _COMPLETION_TYPE_NONE);
|
| if (element is MethodElement) {
|
| // Anything shadows a method.
|
| if (alreadyGenerated != _COMPLETION_TYPE_NONE) {
|
| @@ -389,8 +386,8 @@ class InterfaceTypeSuggestionBuilder {
|
| type = request.cache.objectClassElement.type;
|
| }
|
| if (type is InterfaceType) {
|
| - return new InterfaceTypeSuggestionBuilder(
|
| - request)._buildSuggestions(type, library);
|
| + return new InterfaceTypeSuggestionBuilder(request)._buildSuggestions(
|
| + type, library);
|
| }
|
| }
|
| }
|
| @@ -400,8 +397,8 @@ class InterfaceTypeSuggestionBuilder {
|
| * the visible members in that library. Clients should call
|
| * [LibraryElementSuggestionBuilder.suggestionsFor].
|
| */
|
| -class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor with
|
| - ElementSuggestionBuilder {
|
| +class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor
|
| + with ElementSuggestionBuilder {
|
| final DartCompletionRequest request;
|
| final CompletionSuggestionKind kind;
|
|
|
| @@ -452,8 +449,8 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor with
|
| * This class visits elements in a class and provides suggestions based upon
|
| * the visible named constructors in that class.
|
| */
|
| -class NamedConstructorSuggestionBuilder extends GeneralizingElementVisitor with
|
| - ElementSuggestionBuilder implements SuggestionBuilder {
|
| +class NamedConstructorSuggestionBuilder extends GeneralizingElementVisitor
|
| + with ElementSuggestionBuilder implements SuggestionBuilder {
|
| final DartCompletionRequest request;
|
|
|
| NamedConstructorSuggestionBuilder(this.request);
|
|
|