public class ClsFileImpl extends PsiBinaryFileImpl implements PsiJavaFile, PsiFileWithStubSupport, PsiFileEx, Queryable, PsiClassOwnerEx, PsiCompiledFile
Queryable.Contributor, Queryable.PrintInfo, Queryable.Util
Modifier and Type | Field and Description |
---|---|
static Attribute[] |
EMPTY_ATTRIBUTES |
FLAGS_LOCKED, ICON_PLACEHOLDER
BATCH_REFERENCE_PROCESSING
Constructor and Description |
---|
ClsFileImpl(FileViewProvider viewProvider) |
Modifier and Type | Method and Description |
---|---|
void |
accept(PsiElementVisitor visitor)
Passes the element to the specified visitor.
|
void |
appendMirrorText(int indentLevel,
java.lang.StringBuilder buffer)
Deprecated.
Shouldn't be called from outside or overridden
|
static PsiJavaFileStub |
buildFileStub(VirtualFile file,
byte [] bytes) |
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.
|
static java.lang.CharSequence |
decompile(VirtualFile file) |
PsiElement |
findElementAt(int offset)
Finds a leaf PSI element at the specified offset from the start of the text range of this node.
|
PsiJavaCodeReferenceElement |
findImportReferenceTo(PsiClass aClass)
Returns the single-class import statement which references
the specified class, or null if there is no such statement.
|
PsiReference |
findReferenceAt(int offset)
Finds a reference at the specified offset from the start of the text range of this node.
|
PsiFile |
getCachedMirror() |
PsiElement [] |
getChildren()
Returns the array of children for the PSI element.
|
PsiClass [] |
getClasses() |
java.util.Set<java.lang.String> |
getClassNames() |
PsiFile |
getContainingFile()
Returns the file containing the PSI element.
|
PsiFile |
getDecompiledPsiFile() |
PsiJavaCodeReferenceElement [] |
getImplicitlyImportedPackageReferences()
returns the list of reference elements for the
implicitly imported packages (for example, java.lang).
|
java.lang.String [] |
getImplicitlyImportedPackages()
Returns the list of names of implicitly imported packages
(for example, java.lang).
|
PsiImportList |
getImportList()
Returns the import list contained in the file.
|
Language |
getLanguage()
Returns the language of the PSI element.
|
LanguageLevel |
getLanguageLevel() |
PsiElement |
getMirror()
Returns the corresponding PSI element in a decompiled file created by the IDE from
the library element.
|
PsiJavaModule |
getModuleDeclaration()
Returns a Java module declaration element, or
null if the file is not a module-info one. |
PsiElement |
getNavigationElement()
Returns the PSI element which should be used as a navigation target
when navigation to this PSI element is requested.
|
PsiElement [] |
getOnDemandImports(boolean includeImplicit,
boolean checkIncludes)
Returns the list of classes or packages which have been
imported on demand (for example, javax.swing.*)
|
java.lang.String |
getPackageName()
Returns the name of the package to which the file belongs.
|
PsiPackageStatement |
getPackageStatement()
Returns the package statement contained in the file.
|
PsiClass [] |
getSingleClassImports(boolean checkIncludes)
Returns the list of classes which have been imported as
single-class imports.
|
int |
getStartOffsetInParent()
Returns the text offset of the PSI element relative to its parent.
|
PsiClassHolderFileStub<?> |
getStub() |
StubbedSpine |
getStubbedSpine() |
StubTree |
getStubTree() |
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.
|
boolean |
importClass(PsiClass aClass)
Adds an import statement for importing the specified class.
|
boolean |
isContentsLoaded() |
boolean |
isValid()
Checks if this PSI element is valid.
|
void |
onContentReload() |
boolean |
processDeclarations(PsiScopeProcessor processor,
ResolveState state,
PsiElement lastParent,
PsiElement place)
Passes the declarations contained in this PSI element and its children
for processing to the specified scope processor.
|
void |
putInfo(java.util.Map<java.lang.String,java.lang.String> info) |
void |
setMirror(TreeElement element)
Deprecated.
Shouldn't be called from outside or overridden
|
PsiElement |
setName(java.lang.String name)
Renames the element.
|
void |
setPackageName(java.lang.String packageName) |
char [] |
textToCharArray()
Returns the text of the PSI element as a character array.
|
java.lang.String |
toString()
toString() should never be presented to the user.
|
add, addAfter, addBefore, checkAdd, checkDelete, copy, delete, getContainingDirectory, getContext, getFileType, getManager, getModificationStamp, getName, getNode, getOriginalFile, getParent, getParentDirectory, getPsiRoots, getViewProvider, getVirtualFile, isDirectory, isPhysical, isWritable, markInvalidated, processChildren, replace, subtreeChanged, textMatches, textMatches
acceptChildren, addRange, addRangeAfter, addRangeBefore, canNavigate, canNavigateToSource, deleteChildRange, findChildByClass, findChildrenByClass, findNotNullChildByClass, getFirstChild, getLastChild, getNextSibling, getOriginalElement, getPresentation, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getUseScope, isEquivalentTo, navigate, notNullChild, textContains
buildRowIcon, computeBaseIcon, createLayeredIcon, getAdjustedBaseIcon, getBaseIcon, getElementIcon, getIcon, iconWithVisibilityIfNeeded, isNativeFileType, isVisibilitySupported, overlayIcons, registerIconLayer, transformFlags
changeUserMap, clearUserData, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMap
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
markInvalidated
public ClsFileImpl(FileViewProvider viewProvider)
public PsiFile getContainingFile()
PsiElement
getContainingFile
in interface PsiElement
getContainingFile
in class PsiBinaryFileImpl
public boolean isValid()
PsiElement
PsiDocumentManager.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 PsiElement
isValid
in class PsiBinaryFileImpl
PsiUtilCore.ensureValid(PsiElement)
public Language getLanguage()
PsiElement
getLanguage
in interface PsiElement
getLanguage
in class PsiBinaryFileImpl
public PsiElement [] getChildren()
PsiElement
getChildren
in interface PsiElement
getChildren
in class PsiBinaryFileImpl
public PsiClass [] getClasses()
getClasses
in interface PsiClassOwner
public PsiPackageStatement getPackageStatement()
PsiJavaFile
getPackageStatement
in interface PsiJavaFile
public java.lang.String getPackageName()
PsiJavaFile
getPackageName
in interface PsiClassOwner
getPackageName
in interface PsiJavaFile
public void setPackageName(java.lang.String packageName) throws IncorrectOperationException
setPackageName
in interface PsiClassOwner
IncorrectOperationException
public PsiImportList getImportList()
PsiJavaFile
getImportList
in interface PsiJavaFile
public boolean importClass(PsiClass aClass)
PsiImportHolder
importClass
in interface PsiImportHolder
aClass
- the class to import.public PsiElement [] getOnDemandImports(boolean includeImplicit, boolean checkIncludes)
PsiJavaFile
getOnDemandImports
in interface PsiJavaFile
includeImplicit
- if true, implicitly imported packages (like java.lang) are included.checkIncludes
- deprecated, no longer usedpublic PsiClass [] getSingleClassImports(boolean checkIncludes)
PsiJavaFile
getSingleClassImports
in interface PsiJavaFile
checkIncludes
- deprecated, no longer used.public java.lang.String [] getImplicitlyImportedPackages()
PsiJavaFile
getImplicitlyImportedPackages
in interface PsiJavaFile
public java.util.Set<java.lang.String> getClassNames()
getClassNames
in interface PsiClassOwnerEx
public PsiJavaCodeReferenceElement [] getImplicitlyImportedPackageReferences()
PsiJavaFile
getImplicitlyImportedPackageReferences
in interface PsiJavaFile
public PsiJavaCodeReferenceElement findImportReferenceTo(PsiClass aClass)
PsiJavaFile
findImportReferenceTo
in interface PsiJavaFile
aClass
- the class to return the import statement for.public LanguageLevel getLanguageLevel()
getLanguageLevel
in interface PsiJavaFile
public PsiJavaModule getModuleDeclaration()
PsiJavaFile
null
if the file is not a module-info one.getModuleDeclaration
in interface PsiJavaFile
public PsiElement setName(java.lang.String name) throws IncorrectOperationException
PsiNamedElement
setName
in interface PsiNamedElement
setName
in class PsiBinaryFileImpl
name
- 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
PsiCheckedRenameElement
checkSetName
in interface PsiCheckedRenameElement
checkSetName
in class PsiBinaryFileImpl
name
- the new name to check the renaming possibility for.IncorrectOperationException
- if the rename is not supported or not possible for some reason.@Deprecated public void appendMirrorText(int indentLevel, java.lang.StringBuilder buffer)
@Deprecated public void setMirror(TreeElement element) throws ClsElementImpl.InvalidMirrorException
public PsiElement getNavigationElement()
PsiElement
this
or substitute a different element if this element
does not have an associated file and offset. (For example, if the source code
of a library is attached to a project, the navigation element for a compiled
library class is its source class.)getNavigationElement
in interface PsiElement
getNavigationElement
in class PsiElementBase
public PsiElement getMirror()
PsiCompiledElement
getMirror
in interface PsiCompiledElement
public java.lang.String getText()
PsiElement
getText
in interface PsiElement
getText
in class PsiBinaryFileImpl
PsiElement.textMatches(java.lang.CharSequence)
,
PsiElement.textContains(char)
public int getTextLength()
PsiElement
getTextLength
in interface PsiElement
getTextLength
in class PsiBinaryFileImpl
public PsiFile getDecompiledPsiFile()
getDecompiledPsiFile
in interface PsiCompiledFile
public PsiFile getCachedMirror()
public void accept(PsiElementVisitor visitor)
PsiElement
accept
in interface PsiElement
accept
in class PsiBinaryFileImpl
visitor
- the visitor to pass the element to.public java.lang.String toString()
PsiElement
toString
in interface PsiElement
toString
in class PsiBinaryFileImpl
public final TextRange getTextRange()
PsiElement
getTextRange
in interface PsiElement
getTextRange
in class PsiBinaryFileImpl
public final int getStartOffsetInParent()
PsiElement
getStartOffsetInParent
in interface PsiElement
getStartOffsetInParent
in class PsiBinaryFileImpl
public final PsiElement findElementAt(int offset)
PsiElement
findElementAt
in interface PsiElement
findElementAt
in class PsiBinaryFileImpl
offset
- the relative offset for which the PSI element is requested.public PsiReference findReferenceAt(int offset)
PsiElement
findReferenceAt
in interface PsiElement
findReferenceAt
in class PsiElementBase
offset
- the relative offset for which the reference is requested.public final int getTextOffset()
PsiElement
PsiNamedElement
, this should return the offset in the file of the
name identifier.)getTextOffset
in interface PsiElement
getTextOffset
in class PsiBinaryFileImpl
public char [] textToCharArray()
PsiElement
textToCharArray
in interface PsiElement
textToCharArray
in class PsiBinaryFileImpl
public PsiClassHolderFileStub<?> getStub()
public boolean processDeclarations(PsiScopeProcessor processor, ResolveState state, PsiElement lastParent, PsiElement place)
PsiElement
processDeclarations
in interface PsiElement
processDeclarations
in class PsiElementBase
processor
- the processor receiving the declarations.lastParent
- the child of this element has been processed during the previous
step of the tree up walk (declarations under this element do not need
to be processed again)place
- the original element from which the tree up walk was initiated.public StubTree getStubTree()
getStubTree
in interface PsiFileWithStubSupport
PsiElement.getNode()
or PsiElement.getText()
.public StubbedSpine getStubbedSpine()
getStubbedSpine
in interface PsiFileWithStubSupport
public boolean isContentsLoaded()
isContentsLoaded
in interface PsiFileEx
isContentsLoaded
in class PsiBinaryFileImpl
public void onContentReload()
onContentReload
in interface PsiFileEx
onContentReload
in class PsiBinaryFileImpl
public void putInfo(java.util.Map<java.lang.String,java.lang.String> info)
putInfo
in interface Queryable
putInfo
in class PsiBinaryFileImpl
public static java.lang.CharSequence decompile(VirtualFile file)
public static PsiJavaFileStub buildFileStub(VirtualFile file, byte [] bytes) throws ClsFormatException
ClsFormatException