public abstract class AbstractFileViewProvider extends UserDataHolderBase implements FileViewProvider
Modifier and Type | Field and Description |
---|---|
static Key<java.lang.Object> |
FREE_THREADED |
Modifier | Constructor and Description |
---|---|
protected |
AbstractFileViewProvider(PsiManager manager,
VirtualFile virtualFile,
boolean eventSystemEnabled) |
Modifier and Type | Method and Description |
---|---|
void |
beforeContentsSynchronized()
Invoked before document or VFS changes are processed that affect PSI inside the corresponding file.
|
FileViewProvider |
clone() |
void |
contentsSynchronized()
Invoked after PSI in the corresponding file is synchronized with the corresponding document, which can happen
after VFS, document or PSI changes.
|
protected PsiFile |
createFile(Language lang) |
protected PsiFile |
createFile(Project project,
VirtualFile file,
FileType fileType) |
protected PsiFile |
createFile(VirtualFile file,
FileType fileType,
Language language) |
PsiElement |
findElementAt(int offset,
Language language) |
static PsiElement |
findElementAt(PsiElement psiFile,
int offset) |
PsiReference |
findReferenceAt(int offset,
Language language) |
protected static PsiReference |
findReferenceAt(PsiFile psiFile,
int offset) |
abstract PsiFile |
getCachedPsi(Language target) |
abstract java.util.List<PsiFile> |
getCachedPsiFiles() |
java.lang.CharSequence |
getContents() |
Document |
getDocument() |
PsiLock |
getFilePsiLock() |
FileType |
getFileType() |
abstract java.util.List<FileElement> |
getKnownTreeRoots() |
PsiManagerEx |
getManager() |
long |
getModificationStamp() |
PsiFile |
getPsi(Language target) |
protected abstract PsiFile |
getPsiInner(Language target) |
PsiFile |
getStubBindingRoot() |
VirtualFile |
getVirtualFile() |
boolean |
isEventSystemEnabled() |
static boolean |
isFreeThreaded(FileViewProvider provider) |
protected boolean |
isIgnored() |
boolean |
isPhysical() |
void |
markInvalidated() |
void |
markPossiblyInvalidated() |
void |
onContentReload() |
void |
registerAsCopy(AbstractFileViewProvider copy) |
void |
rootChanged(PsiFile psiFile)
Invoked when any PSI change happens in any of the PSI files corresponding to this view provider.
|
protected boolean |
shouldCreatePsi() |
boolean |
supportsIncrementalReparse(Language rootLanguage) |
java.lang.String |
toString() |
changeUserMap, clearUserData, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMap
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createCopy, findElementAt, findElementAt, findReferenceAt, getAllFiles, getBaseLanguage, getLanguages, hasLanguage
putUserDataIfAbsent, replace
getUserData, putUserData
public static final Key<java.lang.Object> FREE_THREADED
protected AbstractFileViewProvider(PsiManager manager, VirtualFile virtualFile, boolean eventSystemEnabled)
protected boolean shouldCreatePsi()
public static boolean isFreeThreaded(FileViewProvider provider)
public PsiLock getFilePsiLock()
protected final boolean isIgnored()
protected PsiFile createFile(Project project, VirtualFile file, FileType fileType)
protected PsiFile createFile(VirtualFile file, FileType fileType, Language language)
public final PsiManagerEx getManager()
getManager
in interface FileViewProvider
public java.lang.CharSequence getContents()
getContents
in interface FileViewProvider
PsiDocumentManager.getLastCommittedText(Document)
.FileViewProvider.getDocument()
,
PsiDocumentManager.isUncommited(Document)
public VirtualFile getVirtualFile()
getVirtualFile
in interface FileViewProvider
LightVirtualFile
for most non-physical files.public Document getDocument()
getDocument
in interface FileViewProvider
null
for binary or files without events enabled.FileType.isBinary()
,
PsiBinaryFile
,
FileViewProvider.isEventSystemEnabled()
public final PsiFile getPsi(Language target)
getPsi
in interface FileViewProvider
null
if the language is not presentpublic FileViewProvider clone()
clone
in interface FileViewProvider
clone
in class UserDataHolderBase
LightVirtualFile
, not physical and with PSI events disabled.FileViewProvider.isPhysical()
,
FileViewProvider.isEventSystemEnabled()
,
FileViewProvider.createCopy(VirtualFile)
public PsiElement findElementAt(int offset, Language language)
findElementAt
in interface FileViewProvider
FileViewProvider.getBaseLanguage()
,
FileViewProvider.findElementAt(int)
public PsiReference findReferenceAt(int offset, Language language)
findReferenceAt
in interface FileViewProvider
FileViewProvider.getBaseLanguage()
,
PsiElement.findReferenceAt(int)
,
FileViewProvider.findReferenceAt(int)
protected static PsiReference findReferenceAt(PsiFile psiFile, int offset)
public static PsiElement findElementAt(PsiElement psiFile, int offset)
public void beforeContentsSynchronized()
FileViewProvider
beforeContentsSynchronized
in interface FileViewProvider
public void contentsSynchronized()
FileViewProvider
Multi-language file view providers may override this method to recalculate template data languages.
contentsSynchronized
in interface FileViewProvider
FileViewProvider.getLanguages()
public final void onContentReload()
public void rootChanged(PsiFile psiFile)
FileViewProvider
rootChanged
in interface FileViewProvider
psiFile
- the file where PSI has just been changed.public boolean isEventSystemEnabled()
isEventSystemEnabled
in interface FileViewProvider
true
for physical files and for some non-physical as well.PsiTreeChangeListener
,
PsiFileFactory.createFileFromText(String, FileType, CharSequence, long, boolean)
,
PsiElement.isPhysical()
public boolean isPhysical()
isPhysical
in interface FileViewProvider
PsiFile.getVirtualFile()
returns non-null.
Not to be confused with PsiElement.isPhysical()
which (for historical reasons) returns getViewProvider().isEventSystemEnabled()
FileViewProvider.isEventSystemEnabled()
,
PsiElement.isPhysical()
public long getModificationStamp()
getModificationStamp
in interface FileViewProvider
VirtualFile
or Document
.
If a document is modified but not yet committed, the result is the same as PsiDocumentManager.getLastCommittedStamp(Document)
VirtualFile.getModificationStamp()
,
Document.getModificationStamp()
public boolean supportsIncrementalReparse(Language rootLanguage)
supportsIncrementalReparse
in interface FileViewProvider
FileViewProvider.getLanguages()
public java.lang.String toString()
toString
in class java.lang.Object
public abstract java.util.List<PsiFile> getCachedPsiFiles()
public abstract java.util.List<FileElement> getKnownTreeRoots()
public final void markInvalidated()
public final void markPossiblyInvalidated()
public final void registerAsCopy(AbstractFileViewProvider copy)
public PsiFile getStubBindingRoot()
getStubBindingRoot
in interface FileViewProvider
FileViewProvider.getBaseLanguage()
public final FileType getFileType()
getFileType
in interface FileViewProvider
getVirtualFile().getFileType()
, but cached.