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

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

Issue 2565633002: Reorganize InheritedRefenenceContributor to serve angular completion (Closed)
Patch Set: Fix bad merge. Tests passing. Created 4 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/inherited_reference_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/inherited_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/inherited_reference_contributor.dart
index 9553dbaf7aa04f7a9664d529aa5d8e56cf5de4ab..8065c15083f902f5769cc59421733e583d86dc95 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/inherited_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/inherited_reference_contributor.dart
@@ -62,37 +62,54 @@ class InheritedReferenceContributor extends DartCompletionContributor
if (!request.includeIdentifiers) {
return EMPTY_LIST;
}
+
ClassDeclaration classDecl = _enclosingClass(request.target);
if (classDecl == null || classDecl.element == null) {
return EMPTY_LIST;
}
-
containingLibrary = request.libraryElement;
+ return _computeSuggestionsForClass2(resolutionMap
+ .elementDeclaredByClassDeclaration(classDecl), request);
+ }
+
+ List<CompletionSuggestion> _computeSuggestionsForClass2(
+ ClassElement classElement, DartCompletionRequest request,
+ {bool skipChildClass: true}) {
bool isFunctionalArgument = request.target.isFunctionalArgument();
kind = isFunctionalArgument
? CompletionSuggestionKind.IDENTIFIER
: CompletionSuggestionKind.INVOCATION;
- OpType optype = (request as DartCompletionRequestImpl).opType;
- for (InterfaceType type in resolutionMap
- .elementDeclaredByClassDeclaration(classDecl)
- .allSupertypes) {
- if (!isFunctionalArgument) {
- for (PropertyAccessorElement elem in type.accessors) {
- if (elem.isGetter) {
- if (optype.includeReturnValueSuggestions) {
- addSuggestion(elem);
- }
- } else {
- if (optype.includeVoidReturnSuggestions) {
- addSuggestion(elem);
- }
- }
- }
- }
- for (MethodElement elem in type.methods) {
- if (elem.returnType == null) {
- addSuggestion(elem);
- } else if (!elem.returnType.isVoid) {
+ OpType optype = request.opType;
+
+ if (!skipChildClass) {
+ _addSuggestionsForType(classElement.type, optype,
+ isFunctionalArgument: isFunctionalArgument);
+ }
+
+ for (InterfaceType type in classElement.allSupertypes) {
+ _addSuggestionsForType(type, optype,
+ isFunctionalArgument: isFunctionalArgument);
+ }
+ return suggestions;
+ }
+
+ List<CompletionSuggestion> computeSuggestionsForClass(
+ ClassElement classElement, DartCompletionRequest request,
+ {bool skipChildClass: true}) {
+ if (!request.includeIdentifiers) {
+ return EMPTY_LIST;
+ }
+ containingLibrary = request.libraryElement;
+
+ return _computeSuggestionsForClass2(classElement, request,
+ skipChildClass: skipChildClass);
+ }
+
+ _addSuggestionsForType(InterfaceType type, OpType optype,
+ {bool isFunctionalArgument: false}) {
+ if (!isFunctionalArgument) {
+ for (PropertyAccessorElement elem in type.accessors) {
+ if (elem.isGetter) {
if (optype.includeReturnValueSuggestions) {
addSuggestion(elem);
}
@@ -103,6 +120,18 @@ class InheritedReferenceContributor extends DartCompletionContributor
}
}
}
- return suggestions;
+ for (MethodElement elem in type.methods) {
+ if (elem.returnType == null) {
+ addSuggestion(elem);
+ } else if (!elem.returnType.isVoid) {
+ if (optype.includeReturnValueSuggestions) {
+ addSuggestion(elem);
+ }
+ } else {
+ if (optype.includeVoidReturnSuggestions) {
+ addSuggestion(elem);
+ }
+ }
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698