public class HandlyXtextDocument extends org.eclipse.xtext.ui.editor.model.XtextDocument implements IHandlyXtextDocument
XtextDocument
for Handly reconciling story.
Implements IHandlyXtextDocument
.
Bind this class in place of the default XtextDocument
if you
have HandlyXtextEditorCallback
configured. Note that if you bind
this class, you should also bind other classes pertaining to Handly/Xtext
integration:
public Class<? extends XtextDocument> bindXtextDocument() { return HandlyXtextDocument.class; } public Class<? extends IReconciler> bindIReconciler() { return HandlyXtextReconciler.class; } public Class<? extends DirtyStateEditorSupport> bindDirtyStateEditorSupport() { return HandlyDirtyStateEditorSupport.class; // or its subclass }
org.eclipse.xtext.ui.editor.model.XtextDocument.XtextDocumentLocker
IHandlyXtextDocument.IUndoableUnitOfWork<R,P>
Constructor and Description |
---|
HandlyXtextDocument(org.eclipse.xtext.ui.editor.model.DocumentTokenSource tokenSource,
org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer composer) |
Modifier and Type | Method and Description |
---|---|
IDocumentChange |
applyChange(IDocumentChange change)
Applies the given change to the document.
|
void |
disposeInput() |
ISnapshot |
getReconciledSnapshot()
Returns the snapshot from which the document's resource was parsed
in the last
reconcile
operation, or null if the document has no resource (either
not set or already disposed). |
<T> T |
modify(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,org.eclipse.xtext.resource.XtextResource> work)
Executes the given unit of work under the (exclusive) write lock.
|
boolean |
needsReconciling()
Returns whether the resource contents is out of sync
with the document contents and needs to be reconciled.
|
void |
reconcile(boolean force,
org.eclipse.core.runtime.IProgressMonitor monitor)
Re-parses the resource so it becomes reconciled with the document contents.
|
boolean |
reconcile(org.eclipse.xtext.ui.editor.model.IXtextDocumentContentObserver.Processor processor)
Re-parses the resource so it becomes reconciled with the document contents.
|
void |
setInput(org.eclipse.xtext.resource.XtextResource resource) |
addModelListener, addPosition, addPosition, addXtextDocumentContentObserver, checkAndUpdateAnnotations, createDocumentLocker, ensureThatStateIsNotReturned, fireDocumentChanged, fireRewriteSessionChanged, getAdapter, getCancelIndicator, getLastDamage, getPositions, getPositions, getResourceLock, getResourceURI, getTokens, getValidationJob, hasPendingUpdates, internalModify, notifyModelListeners, priorityReadOnly, readOnly, removeModelListener, removePosition, removePosition, removeXtextDocumentContentObserver, setOutdated, setValidationJob, updateContentBeforeRead
acceptPostNotificationReplaces, addDocumentListener, addDocumentPartitioningListener, addDocumentRewriteSessionListener, addPositionCategory, addPositionUpdater, addPrenotifiedDocumentListener, checkStateOfPartitioner, completeInitialization, computeIndexInCategory, computeIndexInPositionList, computeIndexInPositionList, computeNumberOfLines, computePartitioning, computePartitioning, containsPosition, containsPositionCategory, doFireDocumentChanged, doFireDocumentChanged, doFireDocumentChanged2, fireDocumentAboutToBeChanged, fireDocumentPartitioningChanged, fireDocumentPartitioningChanged, fireDocumentPartitioningChanged, get, get, getActiveRewriteSession, getChar, getContentType, getContentType, getDefaultLineDelimiter, getDocumentListeners, getDocumentManagedPositions, getDocumentPartitioner, getDocumentPartitioner, getDocumentPartitioningListeners, getLegalContentTypes, getLegalContentTypes, getLegalLineDelimiters, getLength, getLineDelimiter, getLineInformation, getLineInformationOfOffset, getLineLength, getLineOffset, getLineOfOffset, getModificationStamp, getNumberOfLines, getNumberOfLines, getPartition, getPartition, getPartitionings, getPositionCategories, getPositionUpdaters, getStore, getTracker, ignorePostNotificationReplaces, insertPositionUpdater, registerPostNotificationReplace, removeDocumentListener, removeDocumentPartitioningListener, removeDocumentRewriteSessionListener, removePositionCategory, removePositionUpdater, removePrenotifiedDocumentListener, repairLineInformation, replace, replace, resumeListenerNotification, resumePostNotificationProcessing, search, set, set, setDocumentPartitioner, setDocumentPartitioner, setInitialLineDelimiter, setLineTracker, setTextStore, startRewriteSession, startRewriteSessionOnPartitioners, startSequentialRewrite, stopListenerNotification, stopPostNotificationProcessing, stopRewriteSession, stopRewriteSessionOnPartitioners, stopSequentialRewrite, updateDocumentStructures, updatePositions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
readOnly
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
@Inject public HandlyXtextDocument(org.eclipse.xtext.ui.editor.model.DocumentTokenSource tokenSource, org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer composer)
public void setInput(org.eclipse.xtext.resource.XtextResource resource)
setInput
in class org.eclipse.xtext.ui.editor.model.XtextDocument
public void disposeInput()
disposeInput
in class org.eclipse.xtext.ui.editor.model.XtextDocument
public ISnapshot getReconciledSnapshot()
IHandlyXtextDocument
reconcile
operation, or null
if the document has no resource (either
not set or already disposed). Note that the returned snapshot may
turn out to be stale.getReconciledSnapshot
in interface IHandlyXtextDocument
null
public boolean needsReconciling()
IHandlyXtextDocument
needsReconciling
in interface IHandlyXtextDocument
true
if reconciling is needed,
false
otherwisepublic void reconcile(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
IHandlyXtextDocument
force == false
.reconcile
in interface IHandlyXtextDocument
force
- indicates whether reconciling has to be performed
even if it is not neededmonitor
- a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done()
having been called by the receiverpublic boolean reconcile(org.eclipse.xtext.ui.editor.model.IXtextDocumentContentObserver.Processor processor)
processor
- the processor to execute the reconciling unit of work
(not null
)true
if the document had any changes to be reconciled,
false
otherwisepublic <T> T modify(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,org.eclipse.xtext.resource.XtextResource> work)
IHandlyXtextDocument
Automatically updates the document contents 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 the work is done. If the top-level unit of work is
undoable
, it will be notified
of an undo change that can be later applied
to the document to revert modifications made by
the whole transaction.
Before the top-level unit of work is run, the resource contents
is guaranteed to be based on the last 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
StaleSnapshotException
. Usually, there is no need for clients
to do a reconcile
before calling this method to ensure a fresh snapshot. Reconciling
will happen automatically before the top-level unit of work is run.
modify
in interface IHandlyXtextDocument
modify
in interface org.eclipse.xtext.util.concurrent.IWriteAccess<org.eclipse.xtext.resource.XtextResource>
modify
in class org.eclipse.xtext.ui.editor.model.XtextDocument
work
- a modifying unit of work - must not be null
null
.
Must not contain any references to the resource or its contents
(both semantic objects and parse tree nodes)public IDocumentChange applyChange(IDocumentChange change) throws org.eclipse.jface.text.BadLocationException
IHandlyXtextDocument
StaleSnapshotException
is thrown.applyChange
in interface IHandlyXtextDocument
change
- a document change - must not be null
null
org.eclipse.jface.text.BadLocationException
- if one of the edits in the tree
can't be executed