com.intellij.psi
Class PsiDocumentManager

java.lang.Object
  extended by com.intellij.psi.PsiDocumentManager

public abstract class PsiDocumentManager
extends java.lang.Object

Manages the relationship between documents and PSI trees.


Nested Class Summary
static interface PsiDocumentManager.Listener
          Listener for receiving notifications about creation of Document and PsiFile instances.
 
Constructor Summary
PsiDocumentManager()
           
 
Method Summary
abstract  void addListener(PsiDocumentManager.Listener listener)
          Adds a listener for receiving notifications about creation of Document and PsiFile instances.
abstract  void commitAllDocuments()
          Commits (updates the PSI tree for) all modified but not committed documents.
abstract
<T> T
commitAndRunReadAction(Computable<T> computation)
          Commits the documents and runs the specified operation, which returns a value, in a read action.
abstract  void commitAndRunReadAction(java.lang.Runnable runnable)
          Commits the documents and runs the specified operation, which does not return a value, in a read action.
abstract  void commitDocument(Document document)
          Updates the PSI tree for the specified document.
abstract  Document getCachedDocument(PsiFile file)
          Returns the cached document for the specified PSI file.
abstract  PsiFile getCachedPsiFile(Document document)
          Returns the cached PSI file for the specified document.
abstract  Document getDocument(PsiFile file)
          Returns the document for the specified PSI file.
static PsiDocumentManager getInstance(Project project)
          Returns the document manager instance for the specified project.
abstract  PsiFile getPsiFile(Document document)
          Returns the PSI file for the specified document.
abstract  Document[] getUncommittedDocuments()
          Returns the list of documents which have been modified but not committed.
abstract  boolean hasUncommitedDocuments()
          Checks if any modified documents have not been committed.
abstract  boolean isUncommited(Document document)
          Checks if the specified document has been committed.
abstract  void removeListener(PsiDocumentManager.Listener listener)
          Removes a listener for receiving notifications about creation of Document and PsiFile instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PsiDocumentManager

public PsiDocumentManager()
Method Detail

getInstance

public static PsiDocumentManager getInstance(Project project)
Returns the document manager instance for the specified project.

Parameters:
project - the project for which the document manager is requested.
Returns:
the document manager instance.

getPsiFile

public abstract PsiFile getPsiFile(Document document)
Returns the PSI file for the specified document.

Parameters:
document - the document for which the PSI file is requested.
Returns:
the PSI file instance.

getCachedPsiFile

@Nullable
public abstract PsiFile getCachedPsiFile(Document document)
Returns the cached PSI file for the specified document.

Parameters:
document - the document for which the PSI file is requested.
Returns:
the PSI file instance, or null if there is currently no cached PSI tree for the file.

getDocument

public abstract Document getDocument(PsiFile file)
Returns the document for the specified PSI file.

Parameters:
file - the file for which the document is requested.
Returns:
the document instance, or null if the file is binary or has no associated document.

getCachedDocument

@Nullable
public abstract Document getCachedDocument(PsiFile file)
Returns the cached document for the specified PSI file.

Parameters:
file - the file for which the document is requested.
Returns:
the document instance, or null if there is currently no cached document for the file.

commitAllDocuments

public abstract void commitAllDocuments()
Commits (updates the PSI tree for) all modified but not committed documents. Before a modified document is committed, accessing its PSI may return elements corresponding to original (unmodified) state of the document.


commitDocument

public abstract void commitDocument(Document document)
Updates the PSI tree for the specified document. Before a modified document is committed, accessing its PSI may return elements corresponding to original (unmodified) state of the document.

Parameters:
document - the document to commit.

getUncommittedDocuments

public abstract Document[] getUncommittedDocuments()
Returns the list of documents which have been modified but not committed.

Returns:
the list of uncommitted documents.
See Also:
commitDocument(com.intellij.openapi.editor.Document)

isUncommited

public abstract boolean isUncommited(Document document)
Checks if the specified document has been committed.

Parameters:
document - the document to check.
Returns:
true if the document was modified but not committed, false otherwise
See Also:
commitDocument(com.intellij.openapi.editor.Document)

hasUncommitedDocuments

public abstract boolean hasUncommitedDocuments()
Checks if any modified documents have not been committed.

Returns:
true if there are uncommitted documents, false otherwise

commitAndRunReadAction

public abstract void commitAndRunReadAction(java.lang.Runnable runnable)
Commits the documents and runs the specified operation, which does not return a value, in a read action. Can be called from a thread other than the Swing dispatch thread.

Parameters:
runnable - the operation to execute.

commitAndRunReadAction

public abstract <T> T commitAndRunReadAction(Computable<T> computation)
Commits the documents and runs the specified operation, which returns a value, in a read action. Can be called from a thread other than the Swing dispatch thread.

Parameters:
computation - the operation to execute.
Returns:
the value returned by the operation.

addListener

public abstract void addListener(PsiDocumentManager.Listener listener)
Adds a listener for receiving notifications about creation of Document and PsiFile instances.

Parameters:
listener - the listener to add.

removeListener

public abstract void removeListener(PsiDocumentManager.Listener listener)
Removes a listener for receiving notifications about creation of Document and PsiFile instances.

Parameters:
listener - the listener to add.