Interface IHandlyXtextDocument
- All Superinterfaces:
org.eclipse.jface.text.IDocument
,org.eclipse.jface.text.IDocumentExtension3
,org.eclipse.xtext.util.concurrent.IReadAccess<org.eclipse.xtext.resource.XtextResource>
,org.eclipse.xtext.util.concurrent.IReadAccess.Priority<org.eclipse.xtext.resource.XtextResource>
,org.eclipse.xtext.util.concurrent.IWriteAccess<org.eclipse.xtext.resource.XtextResource>
,org.eclipse.xtext.ui.editor.model.IXtextDocument
- All Known Implementing Classes:
HandlyXtextDocument
IXtextDocument
.- Restriction:
- This interface is not intended to be extended by clients.
- Restriction:
- This interface is not intended to be implemented by clients.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Represents an undoable unit of work.Nested classes/interfaces inherited from interface org.eclipse.xtext.util.concurrent.IReadAccess
org.eclipse.xtext.util.concurrent.IReadAccess.Priority<State extends Object>
-
Field Summary
Fields inherited from interface org.eclipse.jface.text.IDocument
DEFAULT_CATEGORY, DEFAULT_CONTENT_TYPE
Fields inherited from interface org.eclipse.jface.text.IDocumentExtension3
DEFAULT_PARTITIONING
-
Method Summary
Modifier and TypeMethodDescriptionapplyChange
(IDocumentChange change) Applies the given change to this document.Returns the document snapshot that the document model was most recentlyreconciled
with.<T> T
modify
(org.eclipse.xtext.util.concurrent.IUnitOfWork<T, org.eclipse.xtext.resource.XtextResource> work) Executes the given unit of work under the document's write lock.boolean
Returns whether the document model is out of sync with the document text and needs to bereconciled
.<T> T
readOnly
(org.eclipse.xtext.util.concurrent.IUnitOfWork<T, org.eclipse.xtext.resource.XtextResource> work) Executes the given unit of work under the document's read lock.void
reconcile
(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Reconciles the document model so it is up to date again.Methods inherited from interface org.eclipse.jface.text.IDocument
addDocumentListener, addDocumentPartitioningListener, addPosition, addPosition, addPositionCategory, addPositionUpdater, addPrenotifiedDocumentListener, computeIndexInCategory, computeNumberOfLines, computePartitioning, containsPosition, containsPositionCategory, get, get, getChar, getContentType, getDocumentPartitioner, getLegalContentTypes, getLegalLineDelimiters, getLength, getLineDelimiter, getLineInformation, getLineInformationOfOffset, getLineLength, getLineOffset, getLineOfOffset, getNumberOfLines, getNumberOfLines, getPartition, getPositionCategories, getPositions, getPositionUpdaters, insertPositionUpdater, removeDocumentListener, removeDocumentPartitioningListener, removePosition, removePosition, removePositionCategory, removePositionUpdater, removePrenotifiedDocumentListener, replace, search, set, setDocumentPartitioner
Methods inherited from interface org.eclipse.jface.text.IDocumentExtension3
computePartitioning, getContentType, getDocumentPartitioner, getLegalContentTypes, getPartition, getPartitionings, setDocumentPartitioner
Methods inherited from interface org.eclipse.xtext.util.concurrent.IReadAccess
tryReadOnly, tryReadOnly, tryReadOnly
Methods inherited from interface org.eclipse.xtext.util.concurrent.IReadAccess.Priority
priorityReadOnly, tryPriorityReadOnly, tryPriorityReadOnly, tryPriorityReadOnly
Methods inherited from interface org.eclipse.xtext.util.concurrent.IWriteAccess
tryModify, tryModify, tryModify
Methods inherited from interface org.eclipse.xtext.ui.editor.model.IXtextDocument
addModelListener, addXtextDocumentContentObserver, getAdapter, getResourceURI, removeModelListener, removeXtextDocumentContentObserver
-
Method Details
-
needsReconciling
boolean needsReconciling()Returns whether the document model is out of sync with the document text and needs to bereconciled
.- Returns:
true
if reconciling is needed, andfalse
otherwise
-
reconcile
void reconcile(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) Reconciles the document model so it is up to date again.Note that a document model with cross-document references may become out of date even when it is in sync with the document text. The
force
parameter controls whether the document model has to be reconciled even if it is already in sync with the document text.- Parameters:
force
- controls whether the document model has to be reconciled even if it is already in sync with the the document textmonitor
- a progress monitor, ornull
if progress reporting is not desired. The caller must not rely onIProgressMonitor.done()
having been called by the receiver- Throws:
org.eclipse.core.runtime.OperationCanceledException
- if this method is canceledNoXtextResourceException
- ifforce
istrue
and the document has no Xtext resource (i.e., either the resource has yet to be set or it has already been disposed)
-
getReconciledSnapshot
ISnapshot getReconciledSnapshot()Returns the document snapshot that the document model was most recentlyreconciled
with. Returnsnull
if this document has no Xtext resource (i.e., either the resource has yet to be set or it has already been disposed).- Returns:
- the most recently reconciled snapshot, or
null
-
readOnly
<T> T readOnly(org.eclipse.xtext.util.concurrent.IUnitOfWork<T, org.eclipse.xtext.resource.XtextResource> work) Executes the given unit of work under the document's read lock. The unit of work must not modify the Xtext resource or expose any references to it. Read-only units of work may nest into each other.While inside the dynamic context of the unit of work, the Xtext resource is guaranteed to be based on the most recently
reconciled snapshot
. Usually, there is no need for clients to invokereconcile
before calling this method to ensure a fresh snapshot; reconciling happens automatically before the top-level unit of work is run.- Specified by:
readOnly
in interfaceorg.eclipse.xtext.util.concurrent.IReadAccess<org.eclipse.xtext.resource.XtextResource>
- Parameters:
work
- a read-only unit of work (notnull
)- Returns:
- the unit of work's result (may be
null
). Must not contain any references to the Xtext resource or its contents (semantic objects or parse tree nodes)
-
modify
<T> T modify(org.eclipse.xtext.util.concurrent.IUnitOfWork<T, org.eclipse.xtext.resource.XtextResource> work) Executes the given unit of work under the document's write lock. The unit of work may modify the Xtext resource but must not expose any references to it.The document text is automatically updated so it is reconciled with the resource modifications performed by the unit of work. Units of work may be nested; changes are only applied to the document after successful completion of the top-level modification, i.e., when all work is done. If the top-level unit of work is
undoable
, it will beinformed
of an undo change that can beapplied
to the document to revert any modifications made by the whole transaction.Before the top-level unit of work is run, the Xtext resource is guaranteed to be based on the most recently
reconciled snapshot
. That snapshot is regarded as the base snapshot for the whole transaction, i.e., if it turns out to be stale when changes are to be applied to the document, this method will throw aStaleSnapshotException
. Usually, there is no need for clients to invokereconcile
before calling this method to ensure a fresh snapshot; reconciling happens automatically before the top-level unit of work is run.- Specified by:
modify
in interfaceorg.eclipse.xtext.util.concurrent.IWriteAccess<org.eclipse.xtext.resource.XtextResource>
- Parameters:
work
- a modifying unit of work (notnull
)- Returns:
- the unit of work's result (may be
null
). Must not contain any references to the Xtext resource or its contents (semantic objects or parse tree nodes) - Throws:
StaleSnapshotException
- if the document text has changed since the inception of the transaction's base snapshot
-
applyChange
IDocumentChange applyChange(IDocumentChange change) throws org.eclipse.jface.text.BadLocationException Applies the given change to this document.Note that an update conflict may occur if the document text has changed since the inception of the snapshot on which the given change is based. In that case, a
StaleSnapshotException
is thrown.- Parameters:
change
- a document change (notnull
)- Returns:
- undo change, if requested by the given change.
Otherwise,
null
- Throws:
StaleSnapshotException
- if the document text has changed since the inception of the snapshot on which the given change is basedorg.eclipse.text.edits.MalformedTreeException
- if the change's edit tree is not in a valid stateorg.eclipse.jface.text.BadLocationException
- if one of the edits in the change's edit tree could not be executed
-