public abstract class LightPsiFileImpl extends PsiElementBase implements PsiFileEx
Iconable.IconFlags, Iconable.LastComputedIconFLAGS_LOCKED, ICON_PLACEHOLDERBATCH_REFERENCE_PROCESSINGEMPTY_ARRAYARRAY_FACTORYICON_FLAG_IGNORE_MASK, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITYEMPTY_NAVIGATABLE_ELEMENT_ARRAYEMPTY_NAVIGATION_ITEM_ARRAY| Constructor and Description |
|---|
LightPsiFileImpl(FileViewProvider provider,
Language language) |
| Modifier and Type | Method and Description |
|---|---|
void |
acceptChildren(PsiElementVisitor visitor)
Passes the children of the element to the specified visitor.
|
PsiElement |
add(PsiElement element)
Adds a child to this PSI element.
|
PsiElement |
addAfter(PsiElement element,
PsiElement anchor)
Adds a child to this PSI element, after the specified anchor element.
|
PsiElement |
addBefore(PsiElement element,
PsiElement anchor)
Adds a child to this PSI element, before the specified anchor element.
|
PsiElement |
addRange(PsiElement first,
PsiElement last)
Adds a range of elements as children to this PSI element.
|
PsiElement |
addRangeAfter(PsiElement first,
PsiElement last,
PsiElement anchor)
Adds a range of elements as children to this PSI element, after the specified anchor element.
|
PsiElement |
addRangeBefore(PsiElement first,
PsiElement last,
PsiElement anchor)
Adds a range of elements as children to this PSI element, before the specified anchor element.
|
void |
checkAdd(PsiElement element)
Checks if it is possible to add the specified element as a child to this element,
and throws an exception if the add is not possible.
|
void |
checkDelete()
Checks if it is possible to delete the specified element from the tree,
and throws an exception if the add is not possible.
|
void |
checkSetName(java.lang.String name)
Checks if it is possible to rename the element to the specified name,
and throws an exception if the rename is not possible.
|
abstract void |
clearCaches()
Invalidate any file-specific cache in this method.
|
protected LightPsiFileImpl |
clone() |
PsiElement |
copy()
Creates a copy of the file containing the PSI element and returns the corresponding
element in the created copy.
|
abstract LightPsiFileImpl |
copyLight(FileViewProvider viewProvider) |
void |
delete()
Deletes this PSI element from the tree.
|
void |
deleteChildRange(PsiElement first,
PsiElement last)
Deletes a range of children of this PSI element from the tree.
|
PsiElement |
findElementAt(int offset)
Finds a leaf PSI element at the specified offset from the start of the text range of this node.
|
PsiReference |
findReferenceAt(int offset)
Finds a reference at the specified offset from the start of the text range of this node.
|
abstract PsiElement [] |
getChildren()
Returns the array of children for the PSI element.
|
PsiDirectory |
getContainingDirectory()
Returns the directory containing the file.
|
PsiFile |
getContainingFile()
Returns the file containing the PSI element.
|
PsiElement |
getContext()
Returns the element which should be used as the parent of this element in a tree up
walk during a resolve operation.
|
PsiElement |
getFirstChild()
Returns the first child of the PSI element.
|
Language |
getLanguage()
Returns the language of the PSI element.
|
PsiElement |
getLastChild()
Returns the last child of the PSI element.
|
PsiManager |
getManager()
Returns the PSI manager for the project to which the PSI element belongs.
|
long |
getModificationStamp()
Gets the modification stamp value.
|
java.lang.String |
getName()
Returns the name of the element.
|
FileASTNode |
getNode()
Returns the AST node corresponding to the element.
|
PsiFile |
getOriginalFile()
If the file is a non-physical copy of a file, returns the original file which had
been copied.
|
PsiDirectory |
getParent()
Returns the parent of the PSI element.
|
PsiDirectory |
getParentDirectory() |
Project |
getProject()
Returns the project to which the PSI element belongs.
|
PsiFile [] |
getPsiRoots()
If the file contains multiple interspersed languages, returns the roots for
PSI trees for each of these languages.
|
PsiReference [] |
getReferences()
Returns all references from this PSI element to other PSI elements.
|
int |
getStartOffsetInParent()
Returns the text offset of the PSI element relative to its parent.
|
java.lang.String |
getText()
Returns the text of the PSI element.
|
int |
getTextLength()
Returns the length of text of the PSI element.
|
int |
getTextOffset()
Returns the offset in the file to which the caret should be placed
when performing the navigation to the element.
|
TextRange |
getTextRange()
Returns the text range in the document occupied by the PSI element.
|
FileViewProvider |
getViewProvider() |
VirtualFile |
getVirtualFile()
Returns the virtual file corresponding to the PSI file.
|
boolean |
isContentsLoaded() |
boolean |
isPhysical()
Checks if an actual source or class file corresponds to the element.
|
boolean |
isValid()
Checks if this PSI element is valid.
|
boolean |
isWritable()
Checks if the contents of the element can be modified (if it belongs to a
non-read-only source file.)
|
void |
markInvalidated() |
void |
navigate(boolean requestFocus)
Open editor and select/navigate to the object there if possible.
|
void |
onContentReload() |
boolean |
processChildren(PsiElementProcessor<PsiFileSystemItem> processor) |
PsiElement |
replace(PsiElement newElement)
Replaces this PSI element (along with all its children) with another element
(along with the children).
|
void |
setIsValidExplicitly(boolean b) |
PsiElement |
setName(java.lang.String name)
Renames the element.
|
void |
setOriginalFile(PsiFile originalFile) |
void |
subtreeChanged()
Called by the PSI framework when the contents of the file changes.
|
boolean |
textContains(char c)
Checks if the text of this element contains the specified character.
|
boolean |
textMatches(java.lang.CharSequence text)
Checks if the text of this PSI element is equal to the specified character sequence.
|
boolean |
textMatches(PsiElement element)
Checks if the text of this PSI element is equal to the text of the specified PSI element.
|
char [] |
textToCharArray()
Returns the text of the PSI element as a character array.
|
accept, canNavigate, canNavigateToSource, findChildByClass, findChildrenByClass, findNotNullChildByClass, getNavigationElement, getNextSibling, getOriginalElement, getPresentation, getPrevSibling, getReference, getResolveScope, getUseScope, isEquivalentTo, notNullChild, processDeclarationsbuildRowIcon, computeBaseIcon, createLayeredIcon, getAdjustedBaseIcon, getBaseIcon, getElementIcon, getIcon, iconWithVisibilityIfNeeded, isNativeFileType, isVisibilitySupported, overlayIcons, registerIconLayer, transformFlagschangeUserMap, clearUserData, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMapequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetFileElementType, getFileTypeisDirectoryaccept, getCopyableUserData, getNavigationElement, getNextSibling, getOriginalElement, getOwnReferences, getPrevSibling, getReference, getResolveScope, getTextRangeInParent, getUseScope, isEquivalentTo, processDeclarations, putCopyableUserData, toStringgetUserData, putUserDatagetPresentationcanNavigate, canNavigateToSourcepublic LightPsiFileImpl(FileViewProvider provider, Language language)
public VirtualFile getVirtualFile()
PsiFilegetVirtualFile in interface PsiFilegetVirtualFile in interface PsiFileSystemItemnull if the file exists only in memory.public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor)
processChildren in interface PsiFileSystemItempublic boolean isValid()
PsiElementPsiDocumentManager.commitDocument(com.intellij.openapi.editor.Document)).
(In this case an attempt to change PSI will result in an exception).
Any access to invalid elements results in PsiInvalidElementAccessException.
Once invalid, elements can't become valid again.
Elements become invalid in following cases:
PsiElement.delete())isValid in interface PsiElementisValid in class PsiElementBasePsiUtilCore.ensureValid(PsiElement)public void setIsValidExplicitly(boolean b)
public java.lang.String getText()
PsiElementgetText in interface PsiElementPsiElement.textMatches(java.lang.CharSequence),
PsiElement.textContains(char)public long getModificationStamp()
PsiFilegetModificationStamp in interface PsiFileVirtualFile.getModificationStamp()public void subtreeChanged()
PsiFilePsiFile.clearCaches()
since file contents can be reloaded completely (without any specific subtree change) without this method being called.subtreeChanged in interface PsiFilepublic abstract void clearCaches()
PsiFileclearCaches in interface PsiFileprotected LightPsiFileImpl clone()
clone in class UserDataHolderBasepublic java.lang.String getName()
PsiNamedElementgetName in interface NavigationItemgetName in interface PsiFileSystemItemgetName in interface PsiNamedElementgetName in class PsiElementBasepublic PsiElement setName(java.lang.String name) throws IncorrectOperationException
PsiNamedElementsetName in interface PsiNamedElementname - the new element name.this
or a different element if the rename caused the element to be replaced).IncorrectOperationException - if the modification is not supported or not possible for some reason.public void checkSetName(java.lang.String name)
throws IncorrectOperationException
PsiCheckedRenameElementcheckSetName in interface PsiCheckedRenameElementname - the new name to check the renaming possibility for.IncorrectOperationException - if the rename is not supported or not possible for some reason.public PsiDirectory getParent()
PsiElementgetParent in interface PsiElementgetParent in interface PsiFilegetParent in interface PsiFileSystemItempublic PsiDirectory getContainingDirectory()
PsiFilegetContainingDirectory in interface PsiFilenull if the file exists only in memory.public PsiDirectory getParentDirectory()
public PsiFile getContainingFile()
PsiElementgetContainingFile in interface PsiElementgetContainingFile in class PsiElementBasepublic void delete()
throws IncorrectOperationException
PsiElementdelete in interface PsiElementdelete in class PsiElementBaseIncorrectOperationException - if the modification is not supported
or not possible for some reason (for example, the file containing the element is read-only).public void checkDelete()
throws IncorrectOperationException
PsiElementcheckDelete in interface PsiElementcheckDelete in class PsiElementBaseIncorrectOperationException - if the modification is not supported or not possible for some reason.public PsiFile getOriginalFile()
PsiFilegetOriginalFile in interface PsiFilepublic void setOriginalFile(PsiFile originalFile)
public PsiFile [] getPsiRoots()
PsiFilegetPsiRoots in interface PsiFilethis
if the file has only a single language.public boolean isPhysical()
PsiElementPsiDocumentManager.getDocument(PsiFile) returns null for non-physical elements.
Not to be confused with FileViewProvider.isPhysical().isPhysical in interface PsiElementisPhysical in class PsiElementBasepublic Language getLanguage()
PsiElementgetLanguage in interface PsiElementpublic FileViewProvider getViewProvider()
getViewProvider in interface PsiFilepublic PsiManager getManager()
PsiElementgetManager in interface PsiElementgetManager in class PsiElementBasepublic Project getProject()
PsiElementgetProject in interface PsiElementgetProject in class PsiElementBasepublic void acceptChildren(PsiElementVisitor visitor)
PsiElementacceptChildren in interface PsiElementacceptChildren in class PsiElementBasevisitor - the visitor to pass the children to.public final PsiElement copy()
PsiElementcopy in interface PsiElementcopy in class PsiElementBasepublic final void checkAdd(PsiElement element) throws IncorrectOperationException
PsiElementcheckAdd in interface PsiElementcheckAdd in class PsiElementBaseelement - the child element to check the add possibility.IncorrectOperationException - if the modification is not supported or not possible for some reason.public PsiReference [] getReferences()
PsiElementPsiPolyVariantReference should be used instead
of returning multiple references.
Actually, it's preferable to call PsiReferenceService.getReferences(com.intellij.psi.PsiElement, com.intellij.psi.PsiReferenceService.Hints) instead
as it allows adding references by plugins when the element implements ContributedReferenceHost.getReferences in interface PsiElementgetReferences in class PsiElementBasePsiReferenceService.getReferences(com.intellij.psi.PsiElement, com.intellij.psi.PsiReferenceService.Hints),
ReferencesSearchpublic void navigate(boolean requestFocus)
Navigatablenavigate in interface Navigatablenavigate in class PsiElementBaserequestFocus - true if focus requesting is necessarypublic PsiElement findElementAt(int offset)
PsiElementfindElementAt in interface PsiElementoffset - the relative offset for which the PSI element is requested.public PsiReference findReferenceAt(int offset)
PsiElementfindReferenceAt in interface PsiElementfindReferenceAt in class PsiElementBaseoffset - the relative offset for which the reference is requested.public char [] textToCharArray()
PsiElementtextToCharArray in interface PsiElementpublic boolean isContentsLoaded()
isContentsLoaded in interface PsiFileExpublic void onContentReload()
onContentReload in interface PsiFileExpublic boolean isWritable()
PsiElementisWritable in interface PsiElementisWritable in class PsiElementBasepublic abstract PsiElement [] getChildren()
PsiElementgetChildren in interface PsiElementpublic PsiElement getFirstChild()
PsiElementgetFirstChild in interface PsiElementgetFirstChild in class PsiElementBasepublic PsiElement getLastChild()
PsiElementgetLastChild in interface PsiElementgetLastChild in class PsiElementBasepublic TextRange getTextRange()
PsiElementgetTextRange in interface PsiElementpublic int getStartOffsetInParent()
PsiElementgetStartOffsetInParent in interface PsiElementpublic int getTextLength()
PsiElementgetTextLength in interface PsiElementpublic int getTextOffset()
PsiElementPsiNamedElement, this should return the offset in the file of the
name identifier.)getTextOffset in interface PsiElementpublic boolean textMatches(PsiElement element)
PsiElementtextMatches in interface PsiElementtextMatches in class PsiElementBaseelement - the element to compare the text with.public boolean textMatches(java.lang.CharSequence text)
PsiElementtextMatches in interface PsiElementtextMatches in class PsiElementBasetext - the character sequence to compare with.public boolean textContains(char c)
PsiElementtextContains in interface PsiElementtextContains in class PsiElementBasec - the character to search for.public PsiElement add(PsiElement element) throws IncorrectOperationException
PsiElementadd in interface PsiElementadd in class PsiElementBaseelement - the child element to add.element or its copy).IncorrectOperationException - if the modification is not supported or not possible for some reason.public PsiElement addBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException
PsiElementaddBefore in interface PsiElementaddBefore in class PsiElementBaseelement - the child element to add.anchor - the anchor before which the child element is inserted (must be a child of this PSI element)element or its copy).IncorrectOperationException - if the modification is not supported or not possible for some reason.public PsiElement addAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException
PsiElementaddAfter in interface PsiElementaddAfter in class PsiElementBaseelement - the child element to add.anchor - the anchor after which the child element is inserted (must be a child of this PSI element)element or its copy).IncorrectOperationException - if the modification is not supported or not possible for some reason.public PsiElement addRange(PsiElement first, PsiElement last) throws IncorrectOperationException
PsiElementaddRange in interface PsiElementaddRange in class PsiElementBasefirst - the first child element to add.last - the last child element to add (must have the same parent as first)first or its copy).IncorrectOperationException - if the modification is not supported or not possible for some reason.public final PsiElement addRangeBefore(PsiElement first, PsiElement last, PsiElement anchor) throws IncorrectOperationException
PsiElementaddRangeBefore in interface PsiElementaddRangeBefore in class PsiElementBasefirst - the first child element to add.last - the last child element to add (must have the same parent as first)anchor - the anchor before which the child element is inserted (must be a child of this PSI element)first or its copy).IncorrectOperationException - if the modification is not supported or not possible for some reason.public final PsiElement addRangeAfter(PsiElement first, PsiElement last, PsiElement anchor) throws IncorrectOperationException
PsiElementaddRangeAfter in interface PsiElementaddRangeAfter in class PsiElementBasefirst - the first child element to add.last - the last child element to add (must have the same parent as first)anchor - the anchor after which the child element is inserted (must be a child of this PSI element)first or its copy).IncorrectOperationException - if the modification is not supported or not possible for some reason.public void deleteChildRange(PsiElement first, PsiElement last) throws IncorrectOperationException
PsiElementdeleteChildRange in interface PsiElementdeleteChildRange in class PsiElementBasefirst - the first child to delete (must be a child of this PSI element)last - the last child to delete (must be a child of this PSI element)IncorrectOperationException - if the modification is not supported or not possible for some reason.public PsiElement replace(PsiElement newElement) throws IncorrectOperationException
PsiElementreplace in interface PsiElementreplace in class PsiElementBasenewElement - the element to replace this element with.newElement or its copy)IncorrectOperationException - if the modification is not supported or not possible for some reason.public FileASTNode getNode()
PsiElementgetNode in interface PsiElementgetNode in interface PsiFilepublic abstract LightPsiFileImpl copyLight(FileViewProvider viewProvider)
public PsiElement getContext()
PsiElementgetParent(),
but the context can be overridden for some elements like code fragments (see
JavaCodeFragmentFactory.createCodeBlockCodeFragment(String, PsiElement, boolean)).getContext in interface PsiElementgetContext in class PsiElementBasepublic void markInvalidated()
markInvalidated in interface PsiFileEx