public final class CompletionParameters
extends java.lang.Object
Constructor and Description |
---|
CompletionParameters(PsiElement position,
PsiFile originalFile,
CompletionType completionType,
int offset,
int invocationCount,
Editor editor,
CompletionProcess process) |
Modifier and Type | Method and Description |
---|---|
CompletionType |
getCompletionType() |
Editor |
getEditor() |
int |
getInvocationCount() |
int |
getOffset() |
PsiFile |
getOriginalFile() |
PsiElement |
getOriginalPosition() |
PsiElement |
getPosition()
Return the leaf PSI element in the "completion file" at offset
getOffset() . |
CompletionProcess |
getProcess() |
boolean |
isAutoPopup() |
boolean |
isCompleteOnlyNotImported() |
boolean |
isExtendedCompletion() |
boolean |
isTestingMode() |
void |
setCompleteOnlyNotImported(boolean onlyNonImported) |
void |
setIsTestingMode(boolean runTestingMode) |
CompletionParameters |
withInvocationCount(int newCount) |
CompletionParameters |
withPosition(PsiElement element,
int offset) |
CompletionParameters |
withType(CompletionType type) |
public CompletionParameters(PsiElement position, PsiFile originalFile, CompletionType completionType, int offset, int invocationCount, Editor editor, CompletionProcess process)
public CompletionParameters withType(CompletionType type)
public CompletionParameters withInvocationCount(int newCount)
public PsiElement getPosition()
getOffset()
.
"Completion file" is a PSI file used for completion purposes. Most often it's a non-physical copy of the file being edited
(the original file can be accessed from PsiFile.getOriginalFile()
or getOriginalFile()
).
A special 'dummy identifier' string is inserted to the copied file at caret offset (removing the selection).
Most often this string is an identifier (see CompletionInitializationContext.DUMMY_IDENTIFIER
).
It can be changed via CompletionContributor.beforeCompletion(CompletionInitializationContext)
method.
Why? This way there'll always be some non-empty element there, which usually reduces the number of
possible cases to be considered inside a CompletionContributor
.
Also, even if completion was invoked in the middle of a white space, a reference might appear there after dummy identifier is inserted,
and its PsiReference.getVariants()
can then be suggested.
If the dummy identifier is empty, then the file isn't copied and this method returns whatever is at caret in the original file.public PsiElement getOriginalPosition()
public PsiFile getOriginalFile()
public CompletionType getCompletionType()
public int getOffset()
public int getInvocationCount()
public boolean isAutoPopup()
public CompletionParameters withPosition(PsiElement element, int offset)
public boolean isExtendedCompletion()
public Editor getEditor()
public CompletionProcess getProcess()
public boolean isTestingMode()
public void setIsTestingMode(boolean runTestingMode)
public boolean isCompleteOnlyNotImported()
public void setCompleteOnlyNotImported(boolean onlyNonImported)