Shoved object methods all the way down in autocomplete menu

This commit is contained in:
bigguy345 committed 2026-01-04 19:15:32 +02:00
1 parent 080b41a3b9
commit a36cc044bd
2 files changed
+26 -9

No files matched your search

@@ -508,22 +508,16 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
@Override
public int compareTo(AutocompleteItem other) {
// First by match score (descending)
// First by match score (descending) - this includes all penalties and boosts
if (this.matchScore != other.matchScore) {
return other.matchScore - this.matchScore;
}
// Push inherited Object methods to the bottom
boolean thisIsObjectMethod = this.isInheritedObjectMethod();
boolean otherIsObjectMethod = other.isInheritedObjectMethod();
if (thisIsObjectMethod != otherIsObjectMethod) {
return thisIsObjectMethod ? 1 : -1; // Object methods go to bottom
}
// Then by kind priority
if (this.kind.getPriority() != other.kind.getPriority()) {
return this.kind.getPriority() - other.kind.getPriority();
}
// Finally alphabetically
return this.name.compareToIgnoreCase(other.name);
}
@@ -357,6 +357,7 @@ public class JavaAutocompleteProvider implements AutocompleteProvider {
item.calculateMatchScore("", false);
applyUsageBoost(item, tracker, ownerFullName);
applyStaticPenalty(item, isMemberAccess, isStaticContext);
applyObjectMethodPenalty(item);
}
return;
}
@@ -365,7 +366,7 @@ public class JavaAutocompleteProvider implements AutocompleteProvider {
// For member access (after dot), allow fuzzy/contains matching
boolean requirePrefix = !isMemberAccess;
// Filter, score, apply usage boosts, and apply static penalties
// Filter, score, apply usage boosts, and apply penalties
Iterator<AutocompleteItem> iter = items.iterator();
while (iter.hasNext()) {
AutocompleteItem item = iter.next();
@@ -375,6 +376,7 @@ public class JavaAutocompleteProvider implements AutocompleteProvider {
} else {
applyUsageBoost(item, tracker, ownerFullName);
applyStaticPenalty(item, isMemberAccess, isStaticContext);
applyObjectMethodPenalty(item);
}
}
}
@@ -422,6 +424,27 @@ public class JavaAutocompleteProvider implements AutocompleteProvider {
}
}
/**
* Apply penalty to inherited Object methods to push them to bottom.
* Strong matches get lighter penalty, weak matches get pushed all the way down.
*/
private void applyObjectMethodPenalty(AutocompleteItem item) {
if (!item.isInheritedObjectMethod()) {
return;
}
int matchScore = item.getMatchScore();
// Strong prefix matches (score >= 900) get a moderate penalty
// Everything else gets pushed to the very bottom
if (matchScore >= 900) {
// Strong match - moderate penalty to keep it visible but below normal methods
item.addScoreBoost(-500);
} else {
// Weak match - heavy penalty to push to bottom
item.addScoreBoost(-10000);
}
}
/**
* Builder class for AutocompleteItem to handle cases without source data.
*/