public final class PsiManagerImpl extends PsiManagerEx implements Disposable
Disposable.Parent
Modifier and Type | Field and Description |
---|---|
static Topic<AnyPsiChangeListener> |
ANY_PSI_CHANGE_TOPIC |
Constructor and Description |
---|
PsiManagerImpl(Project project) |
Modifier and Type | Method and Description |
---|---|
void |
addPsiTreeChangeListener(PsiTreeChangeListener listener)
Adds a listener for receiving notifications about all changes in the PSI tree of the project.
|
void |
addPsiTreeChangeListener(PsiTreeChangeListener listener,
Disposable parentDisposable)
Adds a listener for receiving notifications about all changes in the PSI tree of the project.
|
void |
addTreeChangePreprocessor(PsiTreeChangePreprocessor preprocessor) |
void |
afterChange(boolean isPhysical) |
boolean |
areElementsEquivalent(PsiElement element1,
PsiElement element2)
Checks if the specified two PSI elements (possibly invalid) represent the same source element
or can are considered equivalent for resolve purposes.
|
void |
beforeChange(boolean isPhysical) |
void |
beforeChildAddition(PsiTreeChangeEventImpl event) |
void |
beforeChildMovement(PsiTreeChangeEventImpl event) |
void |
beforeChildRemoval(PsiTreeChangeEventImpl event) |
void |
beforeChildrenChange(PsiTreeChangeEventImpl event) |
void |
beforeChildReplacement(PsiTreeChangeEventImpl event) |
void |
beforePropertyChange(PsiTreeChangeEventImpl event) |
void |
childAdded(PsiTreeChangeEventImpl event) |
void |
childMoved(PsiTreeChangeEventImpl event) |
void |
childRemoved(PsiTreeChangeEventImpl event) |
void |
childrenChanged(PsiTreeChangeEventImpl event) |
void |
childReplaced(PsiTreeChangeEventImpl event) |
void |
cleanupForNextTest() |
void |
dispose()
Usually not invoked directly, see class javadoc.
|
void |
dropPsiCaches()
Clears all
CachedValue depending on PsiModificationTracker.MODIFICATION_COUNT and resolve caches. |
void |
dropResolveCacheRegularly(ProgressIndicator indicator) |
void |
dropResolveCaches()
Clears the resolve caches of the PSI manager.
|
PsiDirectory |
findDirectory(VirtualFile file)
Returns the PSI directory corresponding to the specified virtual file system directory.
|
PsiFile |
findFile(VirtualFile file)
Returns the PSI file corresponding to the specified virtual file.
|
FileViewProvider |
findViewProvider(VirtualFile file) |
void |
finishBatchFilesProcessingMode()
Notifies the PSI manager that a batch operation sequentially processing multiple files
is finishing.
|
FileManager |
getFileManager() |
PsiModificationTracker |
getModificationTracker()
Returns the modification tracker for the project, which can be used to get the PSI
modification count value.
|
Project |
getProject()
Returns the project with which the PSI manager is associated.
|
boolean |
isAssertOnFileLoading(VirtualFile file) |
boolean |
isBatchFilesProcessingMode() |
boolean |
isDisposed()
Checks if the PSI manager has been disposed and the PSI for this project can no
longer be used.
|
boolean |
isInProject(PsiElement element)
Checks if the specified PSI element belongs to the sources of the project.
|
void |
propertyChanged(PsiTreeChangeEventImpl event) |
void |
registerRunnableToRunAfterAnyChange(java.lang.Runnable runnable) |
void |
registerRunnableToRunOnAnyChange(java.lang.Runnable runnable) |
void |
registerRunnableToRunOnChange(java.lang.Runnable runnable) |
void |
reloadFromDisk(PsiFile file)
Reloads the contents of the specified PSI file and its associated document (if any) from the disk.
|
void |
removePsiTreeChangeListener(PsiTreeChangeListener listener)
Removes a listener for receiving notifications about all changes in the PSI tree of the project.
|
void |
removeTreeChangePreprocessor(PsiTreeChangePreprocessor preprocessor) |
void |
setAssertOnFileLoadingFilter(VirtualFileFilter filter,
Disposable parentDisposable) |
void |
startBatchFilesProcessingMode()
Notifies the PSI manager that a batch operation sequentially processing multiple files
is starting.
|
getInstanceEx
getInstance
changeUserMap, clearUserData, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMap
public static final Topic<AnyPsiChangeListener> ANY_PSI_CHANGE_TOPIC
public PsiManagerImpl(Project project)
public void dispose()
Disposable
dispose
in interface Disposable
public boolean isDisposed()
PsiManager
isDisposed
in class PsiManager
true
if the PSI manager is disposed, false
otherwise.public void dropResolveCaches()
PsiManager
dropResolveCaches
in class PsiManager
public void dropPsiCaches()
PsiManager
CachedValue
depending on PsiModificationTracker.MODIFICATION_COUNT
and resolve caches.
Can be used to reduce memory consumption in batch operations sequentially processing multiple files. Should be invoked on Swing thread.dropPsiCaches
in class PsiManager
public boolean isInProject(PsiElement element)
PsiManager
isInProject
in class PsiManager
element
- the element to check.true
if the element belongs to the sources of the project, false
otherwise.public void setAssertOnFileLoadingFilter(VirtualFileFilter filter, Disposable parentDisposable)
setAssertOnFileLoadingFilter
in class PsiManagerEx
public boolean isAssertOnFileLoading(VirtualFile file)
isAssertOnFileLoading
in class PsiManagerEx
public Project getProject()
PsiManager
getProject
in class PsiManager
public FileManager getFileManager()
getFileManager
in class PsiManagerEx
public boolean areElementsEquivalent(PsiElement element1, PsiElement element2)
PsiManager
Can be used to match two versions of the PSI tree with each other after a reparse.
For example, Java classes with the same fully-qualified name are equivalent, which is useful when working
with both library source and class roots. Source and compiled classes are definitely different (equals()
returns false
),
but for reference resolve or inheritance checks, they're equivalent.
areElementsEquivalent
in class PsiManager
element1
- the first element to check for equivalenceelement2
- the second element to check for equivalencetrue
if the elements are equivalent, false
if the elements are different or
it was not possible to determine the equivalencepublic PsiFile findFile(VirtualFile file)
PsiManager
findFile
in class PsiManager
file
- the file for which the PSI is requested.null
if file
is a directory, an invalid virtual file,
or the current project is a dummy or default project.public FileViewProvider findViewProvider(VirtualFile file)
findViewProvider
in class PsiManager
public PsiDirectory findDirectory(VirtualFile file)
PsiManager
findDirectory
in class PsiManager
file
- the directory for which the PSI is requested.null
if there is no PSI for the specified directory in this project.public void reloadFromDisk(PsiFile file)
PsiManager
reloadFromDisk
in class PsiManager
file
- the PSI file to reload.public void addPsiTreeChangeListener(PsiTreeChangeListener listener)
PsiManager
addPsiTreeChangeListener
in class PsiManager
listener
- the listener instance.public void addPsiTreeChangeListener(PsiTreeChangeListener listener, Disposable parentDisposable)
PsiManager
addPsiTreeChangeListener
in class PsiManager
listener
- the listener instance.parentDisposable
- object, after whose disposing the listener should be removedpublic void removePsiTreeChangeListener(PsiTreeChangeListener listener)
PsiManager
removePsiTreeChangeListener
in class PsiManager
listener
- the listener instance.public void beforeChildAddition(PsiTreeChangeEventImpl event)
beforeChildAddition
in class PsiManagerEx
public void beforeChildRemoval(PsiTreeChangeEventImpl event)
beforeChildRemoval
in class PsiManagerEx
public void beforeChildReplacement(PsiTreeChangeEventImpl event)
beforeChildReplacement
in class PsiManagerEx
public void beforeChildrenChange(PsiTreeChangeEventImpl event)
public void beforeChildMovement(PsiTreeChangeEventImpl event)
public void beforePropertyChange(PsiTreeChangeEventImpl event)
public void childAdded(PsiTreeChangeEventImpl event)
public void childRemoved(PsiTreeChangeEventImpl event)
public void childReplaced(PsiTreeChangeEventImpl event)
public void childMoved(PsiTreeChangeEventImpl event)
public void childrenChanged(PsiTreeChangeEventImpl event)
public void propertyChanged(PsiTreeChangeEventImpl event)
public void addTreeChangePreprocessor(PsiTreeChangePreprocessor preprocessor)
public void removeTreeChangePreprocessor(PsiTreeChangePreprocessor preprocessor)
public void registerRunnableToRunOnChange(java.lang.Runnable runnable)
registerRunnableToRunOnChange
in class PsiManagerEx
runnable
- to be run before physical PSI changepublic void registerRunnableToRunOnAnyChange(java.lang.Runnable runnable)
registerRunnableToRunOnAnyChange
in class PsiManagerEx
runnable
- to be run before physical or non-physical PSI changepublic void registerRunnableToRunAfterAnyChange(java.lang.Runnable runnable)
registerRunnableToRunAfterAnyChange
in class PsiManagerEx
public void beforeChange(boolean isPhysical)
beforeChange
in class PsiManagerEx
public void afterChange(boolean isPhysical)
afterChange
in class PsiManagerEx
public PsiModificationTracker getModificationTracker()
PsiManager
getModificationTracker
in class PsiManager
public void startBatchFilesProcessingMode()
PsiManager
startBatchFilesProcessingMode
in class PsiManager
public void finishBatchFilesProcessingMode()
PsiManager
finishBatchFilesProcessingMode
in class PsiManager
public boolean isBatchFilesProcessingMode()
isBatchFilesProcessingMode
in class PsiManagerEx
public void cleanupForNextTest()
public void dropResolveCacheRegularly(ProgressIndicator indicator)