Chromium Code Reviews| 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 ec5b94ba7cae02006cf7a3e7bf1e5371bca5884b..88d03ef95e0b6d2fd5fd039e85549b824ed7c4b0 100644 |
| --- a/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart |
| +++ b/pkg/analyzer_plugin/lib/utilities/completion/type_member_contributor.dart |
| @@ -22,6 +22,23 @@ import 'package:analyzer_plugin/utilities/completion/suggestion_builder.dart'; |
| * invocations and accesses. |
| */ |
| class TypeMemberContributor implements CompletionContributor { |
| + Future<Null> computeSuggestionsWithEntryPoint(CompletionRequest request, |
|
Brian Wilkerson
2017/06/13 20:50:19
Ditto: Is this a short-term work-around until you
maxkim
2017/06/13 21:11:40
EntryPoint is used as an optional parameter in com
|
| + 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 |
| + if (containingLibrary == null) { |
| + return; |
| + } |
| + |
| + // Recompute the target since resolution may have changed it |
| + Expression expression = _computeDotTarget(request, entryPoint); |
| + if (expression == null || expression.isSynthetic) { |
| + return; |
| + } |
| + _computeSuggestions(request, collector, containingLibrary, expression); |
| + } |
| + |
| @override |
| Future<Null> computeSuggestions( |
| CompletionRequest request, CompletionCollector collector) async { |
| @@ -33,10 +50,18 @@ class TypeMemberContributor implements CompletionContributor { |
| } |
| // Recompute the target since resolution may have changed it |
| - Expression expression = _computeDotTarget(request); |
| + Expression expression = _computeDotTarget(request, null); |
| if (expression == null || expression.isSynthetic) { |
| return; |
| } |
| + _computeSuggestions(request, collector, containingLibrary, expression); |
| + } |
| + |
| + void _computeSuggestions( |
| + CompletionRequest request, |
| + CompletionCollector collector, |
| + LibraryElement containingLibrary, |
| + Expression expression) { |
| if (expression is Identifier) { |
| Element element = expression.bestElement; |
| if (element is ClassElement) { |
| @@ -106,9 +131,10 @@ class TypeMemberContributor implements CompletionContributor { |
| /** |
| * Update the completion [target] and [dotTarget] based on the given [unit]. |
| */ |
| - Expression _computeDotTarget(CompletionRequest request) { |
| - CompletionTarget target = |
| - new CompletionTarget.forOffset(request.result.unit, request.offset); |
| + 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)) { |