public interface IHandlyXtextDocument
extends org.eclipse.xtext.ui.editor.model.IXtextDocument
IXtextDocument
.Modifier and Type | Interface and Description |
---|---|
static interface |
IHandlyXtextDocument.IUndoableUnitOfWork<R,P>
Represents an undoable unit of work.
|
Modifier and Type | Method and Description |
---|---|
IDocumentChange |
applyChange(IDocumentChange change)
Applies the given change to this document.
|
ISnapshot |
getReconciledSnapshot()
Returns the document snapshot that the document model was most recently
reconciled 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 |
needsReconciling()
Returns whether the document model is out of sync
with the document text and needs to be
reconciled . |
<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.
|
addModelListener, addXtextDocumentContentObserver, getAdapter, removeModelListener, removeXtextDocumentContentObserver
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
computePartitioning, getContentType, getDocumentPartitioner, getLegalContentTypes, getPartition, getPartitionings, setDocumentPartitioner
tryReadOnly, tryReadOnly, tryReadOnly
boolean needsReconciling()
reconciled
.true
if reconciling is needed,
and false
otherwisevoid reconcile(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
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.
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, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done()
having been called by the receiverorg.eclipse.core.runtime.OperationCanceledException
- if this method is canceledNoXtextResourceException
- if force
is true
and the document has no Xtext resource (i.e., either the resource
has yet to be set or it has already been disposed)ISnapshot getReconciledSnapshot()
reconciled
with. Returns
null
if this document has no Xtext resource (i.e., either
the resource has yet to be set or it has already been disposed).null
<T> T readOnly(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,org.eclipse.xtext.resource.XtextResource> work)
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 invoke reconcile
before calling this method to ensure
a fresh snapshot; reconciling happens automatically before the
top-level unit of work is run.
readOnly
in interface org.eclipse.xtext.util.concurrent.IReadAccess<org.eclipse.xtext.resource.XtextResource>
work
- a read-only unit of work (not null
)null
).
Must not contain any references to the Xtext resource or its contents
(semantic objects or parse tree nodes)<T> T modify(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,org.eclipse.xtext.resource.XtextResource> work)
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 be informed
of an undo change that can be applied
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 a
StaleSnapshotException
. Usually, there is no need for clients
to invoke reconcile
before calling this method to ensure a fresh snapshot; reconciling
happens automatically before the top-level unit of work is run.
modify
in interface org.eclipse.xtext.util.concurrent.IWriteAccess<org.eclipse.xtext.resource.XtextResource>
work
- a modifying unit of work (not null
)null
).
Must not contain any references to the Xtext resource or its contents
(semantic objects or parse tree nodes)StaleSnapshotException
- if the document text has changed
since the inception of the transaction's base snapshotIDocumentChange applyChange(IDocumentChange change) throws org.eclipse.jface.text.BadLocationException
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.
change
- a document change (not null
)null
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 executedCopyright (c) 2014, 2018 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0