public abstract class PsiDocumentManagerBase extends PsiDocumentManager implements DocumentListener, Disposable
| Modifier and Type | Class and Description |
|---|---|
class |
PsiDocumentManagerBase.PriorityEventCollector |
PsiDocumentManager.ListenerDisposable.Parent| Modifier and Type | Field and Description |
|---|---|
protected DocumentCommitProcessor |
myDocumentCommitProcessor |
protected Project |
myProject |
ARRAY_FACTORY, EMPTY_ARRAY| Modifier | Constructor and Description |
|---|---|
protected |
PsiDocumentManagerBase(Project project) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(PsiDocumentManager.Listener listener) |
static void |
addRunOnCommit(Document document,
java.lang.Runnable action) |
void |
associatePsi(Document document,
PsiFile file) |
void |
beforeDocumentChange(DocumentEvent event)
Called before the text of the document is changed.
|
protected void |
beforeDocumentChangeOnUnlockedDocument(FileViewProvider viewProvider) |
void |
bulkUpdateFinished(Document document)
Notifies about
bulk mode being disabled. |
void |
bulkUpdateStarting(Document document)
Notifies about
bulk mode being enabled. |
static void |
cachePsi(Document document,
PsiFile file)
Deprecated.
|
boolean |
cancelAndRunWhenAllCommitted(java.lang.Object key,
java.lang.Runnable action)
Cancel previously registered action and schedules (new) action to be executed when all documents are committed.
|
static boolean |
checkConsistency(PsiFile psiFile,
Document document) |
void |
clearUncommittedDocuments() |
void |
commitAllDocuments()
Commits (updates the PSI tree for) all modified but not committed documents.
|
boolean |
commitAllDocumentsUnderProgress()
Commits all modified but not committed documents under modal dialog (see
PsiDocumentManager.commitAllDocuments()
Should be called in UI thread and outside of write-action |
<T> T |
commitAndRunReadAction(Computable<T> computation)
Commits the documents and runs the specified operation, which returns a value, in a read action.
|
void |
commitAndRunReadAction(java.lang.Runnable runnable)
Commits the documents and runs the specified operation, which does not return a value, in a read action.
|
void |
commitDocument(Document doc)
Updates the PSI tree for the specified document.
|
void |
disableBackgroundCommit(Disposable parentDisposable) |
void |
dispose()
Usually not invoked directly, see class javadoc.
|
boolean |
doCommitWithoutReparse(Document document) |
void |
documentChanged(DocumentEvent event)
Called after the text of the document has been changed.
|
void |
doPostponedOperationsAndUnblockDocument(Document doc)
Applies pending changes made through the PSI to the specified document.
|
protected boolean |
finishCommitInWriteAction(Document document,
java.util.List<? extends BooleanRunnable> finishProcessors,
java.util.List<? extends BooleanRunnable> reparseInjectedProcessors,
boolean synchronously,
boolean forceNoPsiCommit) |
protected DocumentWindow |
freezeWindow(DocumentWindow document) |
Document |
getCachedDocument(PsiFile file)
Returns the cached document for the specified PSI file.
|
PsiFile |
getCachedPsiFile(Document document)
Returns the cached PSI file for the specified document.
|
Document |
getDocument(PsiFile file)
Returns the document for the specified PSI file.
|
java.util.List<DocumentEvent> |
getEventsSinceCommit(Document document) |
DocumentEx |
getLastCommittedDocument(Document document) |
Document |
getLastCommittedDocument(PsiFile file)
Returns the document for specified PsiFile intended to be used when working with committed PSI, e.g.
|
long |
getLastCommittedStamp(Document document) |
java.lang.CharSequence |
getLastCommittedText(Document document) |
PsiFile |
getPsiFile(Document document)
Returns the PSI file for the specified document.
|
PsiToDocumentSynchronizer |
getSynchronizer() |
Document [] |
getUncommittedDocuments()
Returns the list of documents which have been modified but not committed.
|
boolean |
hasEventSystemEnabledUncommittedDocuments() |
boolean |
hasUncommitedDocuments()
Checks if any modified documents have not been committed.
|
boolean |
isCommitInProgress() |
boolean |
isCommitted(Document document)
Checks if the PSI tree for the specified document is up to date (its state reflects the latest changes made
to the document content).
|
boolean |
isDefaultProject() |
boolean |
isDocumentBlockedByPsi(Document doc)
Checks if the PSI tree corresponding to the specified document has been modified and the changes have not
yet been applied to the document.
|
static boolean |
isFullReparseInProgress() |
boolean |
isUncommited(Document document)
Checks if the specified document has been committed.
|
void |
performForCommittedDocument(Document doc,
java.lang.Runnable action)
If the document is committed, runs action synchronously, otherwise schedules to execute it right after it has been committed.
|
void |
performLaterWhenAllCommitted(java.lang.Runnable runnable)
|
void |
performLaterWhenAllCommitted(java.lang.Runnable runnable,
ModalityState modalityState)
Schedule the runnable to be executed on Swing thread when all the documents with event-system-enabled PSI
are committed at some later moment in a given modality state.
|
boolean |
performWhenAllCommitted(java.lang.Runnable action)
Schedules action to be executed when all documents are committed.
|
void |
removeListener(PsiDocumentManager.Listener listener) |
void |
reparseFileFromText(PsiFileImpl file) |
void |
reparseFiles(java.util.Collection<? extends VirtualFile> files,
boolean includeOpenFiles)
Reparses the specified set of files after an external configuration change that would cause them to be parsed differently
(for example, a language level change in the settings).
|
getInstanceprotected final Project myProject
protected final DocumentCommitProcessor myDocumentCommitProcessor
protected PsiDocumentManagerBase(Project project)
public PsiFile getPsiFile(Document document)
PsiDocumentManagergetPsiFile in class PsiDocumentManagerdocument - the document for which the PSI file is requested.public PsiFile getCachedPsiFile(Document document)
PsiDocumentManagergetCachedPsiFile in class PsiDocumentManagerdocument - the document for which the PSI file is requested.null if there is currently no cached PSI tree for the file.public Document getDocument(PsiFile file)
PsiDocumentManagergetDocument in class PsiDocumentManagerfile - the file for which the document is requested.null if the file is binary or has no associated document.public Document getCachedDocument(PsiFile file)
PsiDocumentManagergetCachedDocument in class PsiDocumentManagerfile - the file for which the document is requested.null if there is currently no cached document for the file.public void commitAllDocuments()
PsiDocumentManagerTransactionGuard)commitAllDocuments in class PsiDocumentManagerpublic boolean commitAllDocumentsUnderProgress()
PsiDocumentManagerPsiDocumentManager.commitAllDocuments()
Should be called in UI thread and outside of write-actioncommitAllDocumentsUnderProgress in class PsiDocumentManagerpublic boolean doCommitWithoutReparse(Document document)
public void performForCommittedDocument(Document doc, java.lang.Runnable action)
PsiDocumentManagerperformForCommittedDocument in class PsiDocumentManagerpublic boolean cancelAndRunWhenAllCommitted(java.lang.Object key,
java.lang.Runnable action)
key - the (unique) id of the action.action - The action to be executed after automatic commit.
This action will overwrite any action which was registered under this key earlier.
The action will be executed in EDT.public static void addRunOnCommit(Document document, java.lang.Runnable action)
public void commitDocument(Document doc)
PsiDocumentManagerFileViewProvider.isEventSystemEnabled()), should be called in UI thread in a write-safe context (see TransactionGuard).
For other documents, can be called in background thread with read access. It's the responsibility of the caller to properly synchronize
that PSI and ensure no other threads are reading or modifying it concurrently.commitDocument in class PsiDocumentManagerdoc - the document to commit.protected boolean finishCommitInWriteAction(Document document, java.util.List<? extends BooleanRunnable> finishProcessors, java.util.List<? extends BooleanRunnable> reparseInjectedProcessors, boolean synchronously, boolean forceNoPsiCommit)
public boolean isCommitInProgress()
public static boolean isFullReparseInProgress()
public <T> T commitAndRunReadAction(Computable<T> computation)
PsiDocumentManagercommitAndRunReadAction in class PsiDocumentManagercomputation - the operation to execute.public void reparseFiles(java.util.Collection<? extends VirtualFile> files, boolean includeOpenFiles)
PsiDocumentManagerreparseFiles in class PsiDocumentManagerfiles - the files to reparse.includeOpenFiles - if true, the files opened in editor tabs will also be reparsed.public void commitAndRunReadAction(java.lang.Runnable runnable)
PsiDocumentManagercommitAndRunReadAction in class PsiDocumentManagerrunnable - the operation to execute.public boolean performWhenAllCommitted(java.lang.Runnable action)
performWhenAllCommitted in class PsiDocumentManageraction - to run when all documents committedpublic void performLaterWhenAllCommitted(java.lang.Runnable runnable)
PsiDocumentManagerPsiDocumentManager.performLaterWhenAllCommitted(Runnable, ModalityState) using ModalityState.defaultModalityState()performLaterWhenAllCommitted in class PsiDocumentManagerpublic void performLaterWhenAllCommitted(java.lang.Runnable runnable,
ModalityState modalityState)
PsiDocumentManagerperformLaterWhenAllCommitted in class PsiDocumentManagerpublic boolean hasEventSystemEnabledUncommittedDocuments()
public void addListener(PsiDocumentManager.Listener listener)
addListener in class PsiDocumentManagerpublic void removeListener(PsiDocumentManager.Listener listener)
removeListener in class PsiDocumentManagerpublic boolean isDocumentBlockedByPsi(Document doc)
PsiDocumentManagerPsiDocumentManager.doPostponedOperationsAndUnblockDocument(com.intellij.openapi.editor.Document).isDocumentBlockedByPsi in class PsiDocumentManagerdoc - the document to check.public void doPostponedOperationsAndUnblockDocument(Document doc)
PsiDocumentManagerdoPostponedOperationsAndUnblockDocument in class PsiDocumentManagerdoc - the document to apply the changes to.public java.lang.CharSequence getLastCommittedText(Document document)
getLastCommittedText in class PsiDocumentManagerImmutableCharSequencepublic long getLastCommittedStamp(Document document)
getLastCommittedStamp in class PsiDocumentManagerDocument.getModificationStamp(),
FileViewProvider.getModificationStamp()public Document getLastCommittedDocument(PsiFile file)
PsiDocumentManagergetLastCommittedDocument in class PsiDocumentManagerfile - the file for which the document is requested.PsiDocumentManager.getDocument(PsiFile). For uncommitted documents, the text is PsiDocumentManager.getLastCommittedText(Document) and
the modification stamp is PsiDocumentManager.getLastCommittedStamp(Document).public DocumentEx getLastCommittedDocument(Document document)
protected DocumentWindow freezeWindow(DocumentWindow document)
public java.util.List<DocumentEvent> getEventsSinceCommit(Document document)
public Document [] getUncommittedDocuments()
PsiDocumentManagergetUncommittedDocuments in class PsiDocumentManagerPsiDocumentManager.commitDocument(Document)public boolean isUncommited(Document document)
PsiDocumentManagerisUncommited in class PsiDocumentManagerdocument - the document to check.PsiDocumentManager.commitDocument(Document)public boolean isCommitted(Document document)
PsiDocumentManagerisCommitted in class PsiDocumentManagerdocument - the document to check.public boolean hasUncommitedDocuments()
PsiDocumentManagerhasUncommitedDocuments in class PsiDocumentManagerpublic void beforeDocumentChange(DocumentEvent event)
DocumentListenerbeforeDocumentChange in interface DocumentListenerevent - the event containing the information about the change.protected void beforeDocumentChangeOnUnlockedDocument(FileViewProvider viewProvider)
public void documentChanged(DocumentEvent event)
DocumentListenerdocumentChanged in interface DocumentListenerevent - the event containing the information about the change.public void bulkUpdateStarting(Document document)
DocumentListenerbulk mode being enabled.bulkUpdateStarting in interface DocumentListenerpublic void bulkUpdateFinished(Document document)
DocumentListenerbulk mode being disabled.bulkUpdateFinished in interface DocumentListenerpublic void clearUncommittedDocuments()
public void disableBackgroundCommit(Disposable parentDisposable)
public void dispose()
Disposabledispose in interface Disposablepublic PsiToDocumentSynchronizer getSynchronizer()
public void reparseFileFromText(PsiFileImpl file)
public boolean isDefaultProject()