public class PrioritizedLookupElement<T extends LookupElement> extends LookupElementDecorator<T>
PrioritizedLookupElement
allows to plug into 3 CompletionWeigher
s: "priority", "explicitProximity" and
"grouping". Standard weigher list includes the following ones in the specified order:
PriorityWeigher
class) based on the value passed via withPriority(LookupElement, double)
PrefixMatchingWeigher
class) checks prefix matchingStatisticsWeigher
class) bubbles up the most frequently used itemsExplicitProximityWeigher
class) based on the value passed via withExplicitProximity(LookupElement, int)
LookupElementProximityWeigher
class)GroupingWeigher
class) based on the value passed via withGrouping(LookupElement, int)
PrioritizedLookupElement
is normally used when you want to control lookup sorting in simple cases, like when you have
control over ALL the items in lookup. Be especially careful with using withPriority(LookupElement, double)
as the corresponding weigher has the top precedence. Other way to control completion items order is implementing a custom CompletionWeigher
,
(see CompletionService.RELEVANCE_KEY
).Dump lookup element weights to log
' action when the completion lookup is
shown (Ctrl+Alt+Shift+W / Cmd+Alt+Shift+W), the action also copies the debug info to the Clipboard.CompletionContributor
Modifier and Type | Field and Description |
---|---|
static ClassConditionKey<PrioritizedLookupElement> |
CLASS_CONDITION_KEY |
EMPTY_ARRAY
Modifier and Type | Method and Description |
---|---|
int |
getExplicitProximity() |
int |
getGrouping() |
double |
getPriority() |
static LookupElement |
withExplicitProximity(LookupElement element,
int explicitProximity) |
static LookupElement |
withGrouping(LookupElement element,
int grouping) |
static LookupElement |
withPriority(LookupElement element,
double priority) |
as, as, equals, getAllLookupStrings, getAutoCompletionPolicy, getDelegate, getLookupString, getObject, getPsiElement, handleInsert, hashCode, isCaseSensitive, isValid, isWorthShowingInAutoPopup, renderElement, toString, withInsertHandler, withRenderer
requiresCommittedDocuments
changeUserMap, clearUserData, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMap
public static final ClassConditionKey<PrioritizedLookupElement> CLASS_CONDITION_KEY
public double getPriority()
public int getGrouping()
public int getExplicitProximity()
public static LookupElement withPriority(LookupElement element, double priority)
public static LookupElement withGrouping(LookupElement element, int grouping)
public static LookupElement withExplicitProximity(LookupElement element, int explicitProximity)