Index: pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart |
diff --git a/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart b/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart |
index d6cb2e8648ed3f04623f5e491d41be1a2841e52d..ef70ec23edfaa57400d4cc828e2c90b905df961b 100644 |
--- a/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart |
+++ b/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart |
@@ -23,10 +23,14 @@ import 'package:analyzer_plugin/utilities/completion/suggestion_builder.dart'; |
*/ |
class TypeMemberContributor implements CompletionContributor { |
/** |
- * Clients should not overload this function. |
+ * Plugin contributors should primarily overload this function. |
+ * Should more parameters be needed for autocompletion needs, the |
+ * overloaded function should define those parameters and |
+ * call on `computeSuggestionsWithEntryPoint`. |
*/ |
- Future<Null> computeSuggestionsWithEntryPoint(CompletionRequest request, |
- CompletionCollector collector, AstNode entryPoint) async { |
+ @override |
+ Future<Null> computeSuggestions( |
+ DartCompletionRequest request, CompletionCollector collector) async { |
LibraryElement containingLibrary = request.result.libraryElement; |
// Gracefully degrade if the library element is not resolved |
// e.g. detached part file or source change |
@@ -35,7 +39,7 @@ class TypeMemberContributor implements CompletionContributor { |
} |
// Recompute the target since resolution may have changed it |
- Expression expression = _computeDotTarget(request, entryPoint); |
+ Expression expression = _computeDotTarget(request, null); |
if (expression == null || expression.isSynthetic) { |
return; |
} |
@@ -43,14 +47,10 @@ class TypeMemberContributor implements CompletionContributor { |
} |
/** |
- * Plugin contributors should primarily overload this function. |
- * Should more parameters be needed for autocompletion needs, the |
- * overloaded function should define those parameters and |
- * call on `computeSuggestionsWithEntryPoint`. |
+ * Clients should not overload this function. |
*/ |
- @override |
- Future<Null> computeSuggestions( |
- CompletionRequest request, CompletionCollector collector) async { |
+ Future<Null> computeSuggestionsWithEntryPoint(DartCompletionRequest request, |
+ CompletionCollector collector, AstNode entryPoint) async { |
LibraryElement containingLibrary = request.result.libraryElement; |
// Gracefully degrade if the library element is not resolved |
// e.g. detached part file or source change |
@@ -59,15 +59,46 @@ class TypeMemberContributor implements CompletionContributor { |
} |
// Recompute the target since resolution may have changed it |
- Expression expression = _computeDotTarget(request, null); |
+ Expression expression = _computeDotTarget(request, entryPoint); |
if (expression == null || expression.isSynthetic) { |
return; |
} |
_computeSuggestions(request, collector, containingLibrary, expression); |
} |
+ /** |
+ * Update the completion [target] and [dotTarget] based on the given [unit]. |
+ */ |
+ Expression _computeDotTarget( |
+ DartCompletionRequest request, AstNode entryPoint) { |
+ CompletionTarget target = new CompletionTarget.forOffset( |
+ request.result.unit, request.offset, |
+ entryPoint: entryPoint); |
+ AstNode node = target.containingNode; |
+ if (node is MethodInvocation) { |
+ if (identical(node.methodName, target.entity)) { |
+ return node.realTarget; |
+ } else if (node.isCascaded && node.operator.offset + 1 == target.offset) { |
+ return node.realTarget; |
+ } |
+ } |
+ if (node is PropertyAccess) { |
+ if (identical(node.propertyName, target.entity)) { |
+ return node.realTarget; |
+ } else if (node.isCascaded && node.operator.offset + 1 == target.offset) { |
+ return node.realTarget; |
+ } |
+ } |
+ if (node is PrefixedIdentifier) { |
+ if (identical(node.identifier, target.entity)) { |
+ return node.prefix; |
+ } |
+ } |
+ return null; |
+ } |
+ |
void _computeSuggestions( |
- CompletionRequest request, |
+ DartCompletionRequest request, |
CompletionCollector collector, |
LibraryElement containingLibrary, |
Expression expression) { |
@@ -136,36 +167,6 @@ class TypeMemberContributor implements CompletionContributor { |
builder.buildSuggestions(type, containingMethodName); |
} |
} |
- |
- /** |
- * Update the completion [target] and [dotTarget] based on the given [unit]. |
- */ |
- Expression _computeDotTarget(CompletionRequest request, AstNode entryPoint) { |
- CompletionTarget target = new CompletionTarget.forOffset( |
- request.result.unit, request.offset, |
- entryPoint: entryPoint); |
- AstNode node = target.containingNode; |
- if (node is MethodInvocation) { |
- if (identical(node.methodName, target.entity)) { |
- return node.realTarget; |
- } else if (node.isCascaded && node.operator.offset + 1 == target.offset) { |
- return node.realTarget; |
- } |
- } |
- if (node is PropertyAccess) { |
- if (identical(node.propertyName, target.entity)) { |
- return node.realTarget; |
- } else if (node.isCascaded && node.operator.offset + 1 == target.offset) { |
- return node.realTarget; |
- } |
- } |
- if (node is PrefixedIdentifier) { |
- if (identical(node.identifier, target.entity)) { |
- return node.prefix; |
- } |
- } |
- return null; |
- } |
} |
/** |