public final class TargetElementUtilBase
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ELEMENT_NAME_ACCEPTED
A flag used in
findTargetElement(Editor, int, int) indicating that if a element declaration name (e.g. |
static int |
REFERENCED_ELEMENT_ACCEPTED
A flag used in
findTargetElement(Editor, int, int) indicating that if a reference is found at the specified offset,
it should be resolved and the result returned. |
Constructor and Description |
---|
TargetElementUtilBase() |
Modifier and Type | Method and Description |
---|---|
static int |
adjustOffset(PsiFile file,
Document document,
int offset)
Attempts to adjust the
offset in the file to point to an identifier ,
single quote, double quote, closing bracket or parentheses by moving it back by a single character. |
static PsiReference |
findReference(Editor editor,
int offset) |
static PsiElement |
findTargetElement(Editor editor,
int flags)
Note: this method can perform slow PSI activity (e.g.
|
static PsiElement |
findTargetElement(Editor editor,
int flags,
int offset)
Note: this method can perform slow PSI activity (e.g.
|
static PsiElement |
getNamedElement(PsiElement element,
int offsetInElement) |
public static final int REFERENCED_ELEMENT_ACCEPTED
findTargetElement(Editor, int, int)
indicating that if a reference is found at the specified offset,
it should be resolved and the result returned.public static final int ELEMENT_NAME_ACCEPTED
findTargetElement(Editor, int, int)
indicating that if a element declaration name (e.g. class name identifier)
is found at the specified offset, the declared element should be returned.public static int adjustOffset(PsiFile file, Document document, int offset)
offset
in the file
to point to an identifier
,
single quote, double quote, closing bracket or parentheses by moving it back by a single character. Does nothing if there are no
identifiers around, or the offset
is already in one.file
- language source for the isIdentifierPart(PsiFile, CharSequence, int)
PsiTreeUtilKt#elementsAroundOffsetUp(PsiFile, int)
public static PsiElement getNamedElement(PsiElement element, int offsetInElement)
public static PsiReference findReference(Editor editor, int offset)
public static PsiElement findTargetElement(Editor editor, int flags)
PsiReference.resolve()
, so please avoid calling it from Swing thread.editor
- editorflags
- a combination of REFERENCED_ELEMENT_ACCEPTED
, ELEMENT_NAME_ACCEPTED
findTargetElement(Editor, int, int)
public static PsiElement findTargetElement(Editor editor, int flags, int offset)
PsiReference.resolve()
, so please avoid calling it from Swing thread.editor
- editorflags
- a combination of REFERENCED_ELEMENT_ACCEPTED
, ELEMENT_NAME_ACCEPTED
offset
- offset in the editor's documentfindTargetElement(Editor, int)