public abstract class PsiReferenceBase<T extends PsiElement> extends java.lang.Object implements PsiReference
Modifier and Type | Class and Description |
---|---|
static class |
PsiReferenceBase.Immediate<T extends PsiElement> |
static class |
PsiReferenceBase.Poly<T extends PsiElement> |
Modifier and Type | Field and Description |
---|---|
protected T |
myElement |
protected boolean |
mySoft |
ARRAY_FACTORY, EMPTY_ARRAY
Constructor and Description |
---|
PsiReferenceBase(T element)
Reference range is obtained from
ElementManipulator.getRangeInElement(PsiElement) . |
PsiReferenceBase(T element,
boolean soft)
Reference range is obtained from
ElementManipulator.getRangeInElement(PsiElement) . |
PsiReferenceBase(T element,
TextRange rangeInElement) |
PsiReferenceBase(T element,
TextRange rangeInElement,
boolean soft) |
Modifier and Type | Method and Description |
---|---|
PsiElement |
bindToElement(PsiElement element)
Changes the reference so that it starts to point to the specified element.
|
protected TextRange |
calculateDefaultRangeInElement() |
static <T extends PsiElement> |
createSelfReference(T element,
PsiElement resolveTo) |
static <T extends PsiElement> |
createSelfReference(T element,
TextRange rangeInElement,
PsiElement resolveTo) |
java.lang.String |
getCanonicalText()
Returns the name of the reference target element which does not depend on import statements
and other context (for example, the full-qualified name of the class if the reference targets
a Java class).
|
T |
getElement()
Returns the underlying (referencing) element of the reference.
|
TextRange |
getRangeInElement()
Returns the part of the underlying element which serves as a reference, or the complete
text range of the element if the entire element is a reference.
|
java.lang.String |
getValue() |
PsiElement |
handleElementRename(java.lang.String newElementName)
Called when the reference target element has been renamed, in order to change the reference
text according to the new name.
|
boolean |
isReferenceTo(PsiElement element)
Checks if the reference targets the specified element.
|
boolean |
isSoft()
Returns
false if the underlying element is guaranteed to be a reference, or true
if the underlying element is a possible reference which should not be reported as
an error if it fails to resolve. |
void |
setRangeInElement(TextRange rangeInElement) |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getVariants, resolve, resolveReference, resolvesTo
getAbsoluteRange
protected final T extends PsiElement myElement
protected boolean mySoft
public PsiReferenceBase(T element, TextRange rangeInElement, boolean soft)
element
- Underlying element.rangeInElement
- Reference range relative to given element
.soft
- Whether reference may fail to resolve
.public PsiReferenceBase(T element, TextRange rangeInElement)
element
- Underlying element.rangeInElement
- Reference range relative to given element
.public PsiReferenceBase(T element, boolean soft)
ElementManipulator.getRangeInElement(PsiElement)
.element
- Underlying element.soft
- Whether reference may fail to resolve
.public PsiReferenceBase(T element)
ElementManipulator.getRangeInElement(PsiElement)
.element
- Underlying element.public void setRangeInElement(TextRange rangeInElement)
public java.lang.String getValue()
public T getElement()
PsiReference
getElement
in interface PsiSymbolReference
getElement
in interface PsiReference
public TextRange getRangeInElement()
PsiReference
PsiElement text: qualified.LongName PsiReferences: [Ref1---]X[Ref2--]where
Ref1
would resolve to a "namespace" and Ref2
to an "element".getRangeInElement
in interface PsiSymbolReference
getRangeInElement
in interface PsiReference
protected TextRange calculateDefaultRangeInElement()
public java.lang.String getCanonicalText()
PsiReference
getCanonicalText
in interface PsiReference
public PsiElement handleElementRename(java.lang.String newElementName) throws IncorrectOperationException
PsiReference
handleElementRename
in interface PsiReference
newElementName
- the new name of the target element.IncorrectOperationException
- if the rename cannot be handled for some reason.public PsiElement bindToElement(PsiElement element) throws IncorrectOperationException
PsiReference
bindToElement
in interface PsiReference
element
- the element which should become the target of the reference.IncorrectOperationException
- if the rebind cannot be handled for some reason.public boolean isReferenceTo(PsiElement element)
PsiReference
isReferenceTo
in interface PsiReference
element
- the element to check target for.true
if the reference targets that element, false
otherwise.public static <T extends PsiElement> PsiReferenceBase<T> createSelfReference(T element, PsiElement resolveTo)
public static <T extends PsiElement> PsiReferenceBase<T> createSelfReference(T element, TextRange rangeInElement, PsiElement resolveTo)
public boolean isSoft()
PsiReference
false
if the underlying element is guaranteed to be a reference, or true
if the underlying element is a possible reference which should not be reported as
an error if it fails to resolve. For example, a text in an XML file which looks
like a full-qualified Java class name is a soft reference.isSoft
in interface PsiReference
true
if the reference is soft, false
otherwise.public java.lang.String toString()
toString
in class java.lang.Object