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

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

Issue 1121773003: Sort the containing method first in completions following super (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 7 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/suggestion_builder.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart b/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
index 02f7ed0b1330abb00ff970c545ba34fc5ffc139a..07ee0742f50419a6274c451dd74e48371f73a704 100644
--- a/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/suggestion_builder.dart
@@ -294,7 +294,7 @@ class InterfaceTypeSuggestionBuilder {
* Add a suggestion based upon the given element, provided that it is not
* shadowed by a previously added suggestion.
*/
- void addSuggestion(Element element) {
+ void addSuggestion(Element element, {int relevance: DART_RELEVANCE_DEFAULT}) {
if (element.isPrivate) {
LibraryElement elementLibrary = element.library;
LibraryElement unitLibrary = request.unit.element.library;
@@ -339,14 +339,15 @@ class InterfaceTypeSuggestionBuilder {
assert(false);
return;
}
- CompletionSuggestion suggestion = createSuggestion(element, kind: kind);
+ CompletionSuggestion suggestion =
+ createSuggestion(element, kind: kind, relevance: relevance);
if (suggestion != null) {
request.addSuggestion(suggestion);
}
}
- void _buildSuggestions(
- InterfaceType type, LibraryElement library, bool isSuper) {
+ void _buildSuggestions(InterfaceType type, LibraryElement library,
+ bool isSuper, String containingMethodName) {
if (isSuper) {
// Suggest members from superclass if the target is "super"
type = type.superclass;
@@ -358,11 +359,15 @@ class InterfaceTypeSuggestionBuilder {
// completions. If multiple elements are found that complete to the same
// identifier, addSuggestion will discard all but the first (with a few
// exceptions to handle getter/setter pairs).
- for (InterfaceType targetType in _getTypeOrdering(type)) {
+ List<InterfaceType> types = _getTypeOrdering(type);
+ for (InterfaceType targetType in types) {
for (MethodElement method in targetType.methods) {
// Exclude static methods when completion on an instance
if (!method.isStatic) {
- addSuggestion(method);
+ addSuggestion(method,
+ relevance: method.name == containingMethodName
+ ? DART_RELEVANCE_HIGH
+ : DART_RELEVANCE_DEFAULT);
}
}
for (PropertyAccessorElement propertyAccessor in targetType.accessors) {
@@ -421,7 +426,7 @@ class InterfaceTypeSuggestionBuilder {
* Add suggestions for the visible members in the given interface
*/
static void suggestionsFor(DartCompletionRequest request, DartType type,
- {bool isSuper: false}) {
+ {bool isSuper: false, String containingMethodName: null}) {
CompilationUnit compilationUnit =
request.target.containingNode.getAncestor((n) => n is CompilationUnit);
LibraryElement library = compilationUnit.element.library;
@@ -430,7 +435,7 @@ class InterfaceTypeSuggestionBuilder {
}
if (type is InterfaceType) {
return new InterfaceTypeSuggestionBuilder(request)._buildSuggestions(
- type, library, isSuper);
+ type, library, isSuper, containingMethodName);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698