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

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

Issue 1291283002: suggest prefixed constructors - fixes #23210 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart b/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
index f3a9db439758e230a9f9b400c85c08ed3bc17fba..0a6ca2cb6d8b29a144ed394d1c95ec734a4000f2 100644
--- a/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
@@ -19,7 +19,6 @@ import 'package:analyzer/src/generated/element.dart';
import '../../protocol_server.dart'
show CompletionSuggestion, CompletionSuggestionKind;
-import '../../protocol_server.dart' as protocol;
/**
* A contributor for calculating invocation / access suggestions
@@ -110,7 +109,6 @@ class _FieldFormalSuggestionBuilder implements SuggestionBuilder {
ConstructorDeclaration constructorDecl =
node.getAncestor((p) => p is ConstructorDeclaration);
if (constructorDecl != null) {
-
// Compute fields already referenced
List<String> referencedFields = new List<String>();
for (FormalParameter param in constructorDecl.parameters.parameters) {
@@ -213,7 +211,6 @@ class _InvocationAstVisitor extends GeneralizingAstVisitor<SuggestionBuilder> {
* and if found, tries to determine a type for that declaration.
*/
class _LocalBestTypeVisitor extends LocalDeclarationVisitor {
-
/**
* The name for the declaration to be found.
*/
@@ -403,9 +400,13 @@ class _PrefixedIdentifierSuggestionBuilder
if (directive.prefix.name == element.name) {
// Suggest elements from the imported library
LibraryElement library = directive.uriElement;
+ AstNode node = request.target.containingNode;
+ bool typesOnly = node.parent is TypeName;
+ bool instCreation =
+ typesOnly && node.parent.parent is ConstructorName;
LibraryElementSuggestionBuilder.suggestionsFor(request,
- CompletionSuggestionKind.INVOCATION, library,
- request.target.containingNode.parent is TypeName);
+ CompletionSuggestionKind.INVOCATION, library, typesOnly,
+ instCreation);
modified = true;
if (directive.deferredKeyword != null) {
FunctionElement loadLibFunct = library.loadLibraryFunction;

Powered by Google App Engine
This is Rietveld 408576698