public abstract class PsiDocumentManagerBase extends PsiDocumentManager implements DocumentListener, Disposable
Modifier and Type | Class and Description |
---|---|
class |
PsiDocumentManagerBase.PriorityEventCollector |
PsiDocumentManager.Listener
Disposable.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).
|
getInstance
protected final Project myProject
protected final DocumentCommitProcessor myDocumentCommitProcessor
protected PsiDocumentManagerBase(Project project)
public PsiFile getPsiFile(Document document)
PsiDocumentManager
getPsiFile
in class PsiDocumentManager
document
- the document for which the PSI file is requested.public PsiFile getCachedPsiFile(Document document)
PsiDocumentManager
getCachedPsiFile
in class PsiDocumentManager
document
- 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)
PsiDocumentManager
getDocument
in class PsiDocumentManager
file
- the file for which the document is requested.null
if the file is binary or has no associated document.public Document getCachedDocument(PsiFile file)
PsiDocumentManager
getCachedDocument
in class PsiDocumentManager
file
- the file for which the document is requested.null
if there is currently no cached document for the file.public void commitAllDocuments()
PsiDocumentManager
TransactionGuard
)commitAllDocuments
in class PsiDocumentManager
public boolean commitAllDocumentsUnderProgress()
PsiDocumentManager
PsiDocumentManager.commitAllDocuments()
Should be called in UI thread and outside of write-actioncommitAllDocumentsUnderProgress
in class PsiDocumentManager
public boolean doCommitWithoutReparse(Document document)
public void performForCommittedDocument(Document doc, java.lang.Runnable action)
PsiDocumentManager
performForCommittedDocument
in class PsiDocumentManager
public 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)
PsiDocumentManager
FileViewProvider.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 PsiDocumentManager
doc
- 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)
PsiDocumentManager
commitAndRunReadAction
in class PsiDocumentManager
computation
- the operation to execute.public void reparseFiles(java.util.Collection<? extends VirtualFile> files, boolean includeOpenFiles)
PsiDocumentManager
reparseFiles
in class PsiDocumentManager
files
- the files to reparse.includeOpenFiles
- if true, the files opened in editor tabs will also be reparsed.public void commitAndRunReadAction(java.lang.Runnable runnable)
PsiDocumentManager
commitAndRunReadAction
in class PsiDocumentManager
runnable
- the operation to execute.public boolean performWhenAllCommitted(java.lang.Runnable action)
performWhenAllCommitted
in class PsiDocumentManager
action
- to run when all documents committedpublic void performLaterWhenAllCommitted(java.lang.Runnable runnable)
PsiDocumentManager
PsiDocumentManager.performLaterWhenAllCommitted(Runnable, ModalityState)
using ModalityState.defaultModalityState()
performLaterWhenAllCommitted
in class PsiDocumentManager
public void performLaterWhenAllCommitted(java.lang.Runnable runnable, ModalityState modalityState)
PsiDocumentManager
performLaterWhenAllCommitted
in class PsiDocumentManager
public boolean hasEventSystemEnabledUncommittedDocuments()
public void addListener(PsiDocumentManager.Listener listener)
addListener
in class PsiDocumentManager
public void removeListener(PsiDocumentManager.Listener listener)
removeListener
in class PsiDocumentManager
public boolean isDocumentBlockedByPsi(Document doc)
PsiDocumentManager
PsiDocumentManager.doPostponedOperationsAndUnblockDocument(com.intellij.openapi.editor.Document)
.isDocumentBlockedByPsi
in class PsiDocumentManager
doc
- the document to check.public void doPostponedOperationsAndUnblockDocument(Document doc)
PsiDocumentManager
doPostponedOperationsAndUnblockDocument
in class PsiDocumentManager
doc
- the document to apply the changes to.public java.lang.CharSequence getLastCommittedText(Document document)
getLastCommittedText
in class PsiDocumentManager
ImmutableCharSequence
public long getLastCommittedStamp(Document document)
getLastCommittedStamp
in class PsiDocumentManager
Document.getModificationStamp()
,
FileViewProvider.getModificationStamp()
public Document getLastCommittedDocument(PsiFile file)
PsiDocumentManager
getLastCommittedDocument
in class PsiDocumentManager
file
- 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()
PsiDocumentManager
getUncommittedDocuments
in class PsiDocumentManager
PsiDocumentManager.commitDocument(Document)
public boolean isUncommited(Document document)
PsiDocumentManager
isUncommited
in class PsiDocumentManager
document
- the document to check.PsiDocumentManager.commitDocument(Document)
public boolean isCommitted(Document document)
PsiDocumentManager
isCommitted
in class PsiDocumentManager
document
- the document to check.public boolean hasUncommitedDocuments()
PsiDocumentManager
hasUncommitedDocuments
in class PsiDocumentManager
public void beforeDocumentChange(DocumentEvent event)
DocumentListener
beforeDocumentChange
in interface DocumentListener
event
- the event containing the information about the change.protected void beforeDocumentChangeOnUnlockedDocument(FileViewProvider viewProvider)
public void documentChanged(DocumentEvent event)
DocumentListener
documentChanged
in interface DocumentListener
event
- the event containing the information about the change.public void bulkUpdateStarting(Document document)
DocumentListener
bulk mode
being enabled.bulkUpdateStarting
in interface DocumentListener
public void bulkUpdateFinished(Document document)
DocumentListener
bulk mode
being disabled.bulkUpdateFinished
in interface DocumentListener
public void clearUncommittedDocuments()
public void disableBackgroundCommit(Disposable parentDisposable)
public void dispose()
Disposable
dispose
in interface Disposable
public PsiToDocumentSynchronizer getSynchronizer()
public void reparseFileFromText(PsiFileImpl file)
public boolean isDefaultProject()