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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart

Issue 1516883002: do not suggest completions for cascade on library prefix - fixes #25215 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart
index 15e7f0f9e89c80397f05945d41632b215226cadf..350221fecc7fe99a88590c7dc67f1d2100434173 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/type_member_contributor.dart
@@ -8,14 +8,13 @@ import 'dart:async';
import 'dart:collection';
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
-import 'package:analysis_server/src/provisional/completion/dart/completion_target.dart';
import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
+import 'package:analysis_server/src/services/completion/local_declaration_visitor.dart';
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.dart';
import '../../../protocol_server.dart'
show CompletionSuggestion, CompletionSuggestionKind;
-import 'package:analysis_server/src/services/completion/local_declaration_visitor.dart';
/**
* A contributor for calculating instance invocation / access suggestions
@@ -27,8 +26,7 @@ class TypeMemberContributor extends DartCompletionContributor {
DartCompletionRequest request) async {
// Determine if the target looks like a prefixed identifier,
// a method invocation, or a property access
- Expression parsedExpression =
- _getTargetExpression(request.target, request.offset);
+ Expression parsedExpression = request.dotTarget;
if (parsedExpression == null) {
return EMPTY_LIST;
}
@@ -43,8 +41,7 @@ class TypeMemberContributor extends DartCompletionContributor {
}
// Recompute the target since resolution may have changed it
- Expression expression =
- _getTargetExpression(request.target, request.offset);
+ Expression expression = request.dotTarget;
if (expression == null || expression.isSynthetic) {
return EMPTY_LIST;
}
@@ -113,39 +110,6 @@ class TypeMemberContributor extends DartCompletionContributor {
}
return EMPTY_LIST;
}
-
- /**
- * Return the expression to the left of the 'dot' or `null` if none.
- */
- Expression _getTargetExpression(CompletionTarget target, int offset) {
- 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 == offset) {
- return node.realTarget;
- } else {
- return null;
- }
- }
- if (node is PropertyAccess) {
- if (identical(node.propertyName, target.entity)) {
- return node.realTarget;
- } else if (node.isCascaded && node.operator.offset + 1 == offset) {
- return node.realTarget;
- } else {
- return null;
- }
- }
- if (node is PrefixedIdentifier) {
- if (identical(node.identifier, target.entity)) {
- return node.prefix;
- } else {
- return null;
- }
- }
- return null;
- }
}
/**

Powered by Google App Engine
This is Rietveld 408576698