Class HandlyXtextDocument
- java.lang.Object
-
- org.eclipse.jface.text.AbstractDocument
-
- org.eclipse.jface.text.Document
-
- org.eclipse.xtext.ui.editor.model.XtextDocument
-
- org.eclipse.handly.xtext.ui.editor.HandlyXtextDocument
-
- All Implemented Interfaces:
IHandlyXtextDocument,org.eclipse.jface.text.IDocument,org.eclipse.jface.text.IDocumentExtension,org.eclipse.jface.text.IDocumentExtension2,org.eclipse.jface.text.IDocumentExtension3,org.eclipse.jface.text.IDocumentExtension4,org.eclipse.jface.text.IRepairableDocument,org.eclipse.jface.text.IRepairableDocumentExtension,org.eclipse.xtext.ui.editor.model.IXtextDocument,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>
public class HandlyXtextDocument extends org.eclipse.xtext.ui.editor.model.XtextDocument implements IHandlyXtextDocument
ExtendsXtextDocumentfor Handly reconciling story. ImplementsIHandlyXtextDocument.Bind this class in place of the default
XtextDocumentif you haveHandlyXtextEditorCallbackconfigured. 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 }- Restriction:
- This class is not intended to be extended by clients.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.xtext.ui.editor.model.XtextDocument
org.eclipse.xtext.ui.editor.model.XtextDocument.XtextDocumentLocker
-
Nested classes/interfaces inherited from interface org.eclipse.jface.text.IDocumentExtension
org.eclipse.jface.text.IDocumentExtension.IReplace
-
Nested classes/interfaces inherited from interface org.eclipse.handly.xtext.ui.editor.IHandlyXtextDocument
IHandlyXtextDocument.IUndoableUnitOfWork<R,P>
-
-
Constructor Summary
Constructors Constructor Description HandlyXtextDocument(org.eclipse.xtext.ui.editor.model.DocumentTokenSource tokenSource, org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer composer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IDocumentChangeapplyChange(IDocumentChange change)Applies the given change to this document.voiddisposeInput()ISnapshotgetReconciledSnapshot()Returns the document snapshot that the document model was most recentlyreconciledwith.<T> Tmodify(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.booleanneedsReconciling()Returns whether the document model is out of sync with the document text and needs to bereconciled.voidreconcile(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)Reconciles the document model so it is up to date again.voidsetInput(org.eclipse.xtext.resource.XtextResource resource)-
Methods inherited from class org.eclipse.xtext.ui.editor.model.XtextDocument
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
-
Methods inherited from class org.eclipse.jface.text.AbstractDocument
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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.handly.xtext.ui.editor.IHandlyXtextDocument
readOnly
-
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
-
-
-
-
Method Detail
-
setInput
public void setInput(org.eclipse.xtext.resource.XtextResource resource)
- Overrides:
setInputin classorg.eclipse.xtext.ui.editor.model.XtextDocument
-
disposeInput
public void disposeInput()
- Overrides:
disposeInputin classorg.eclipse.xtext.ui.editor.model.XtextDocument
-
getReconciledSnapshot
public ISnapshot getReconciledSnapshot()
Description copied from interface:IHandlyXtextDocumentReturns the document snapshot that the document model was most recentlyreconciledwith. Returnsnullif this document has no Xtext resource (i.e., either the resource has yet to be set or it has already been disposed).- Specified by:
getReconciledSnapshotin interfaceIHandlyXtextDocument- Returns:
- the most recently reconciled snapshot, or
null
-
needsReconciling
public boolean needsReconciling()
Description copied from interface:IHandlyXtextDocumentReturns whether the document model is out of sync with the document text and needs to bereconciled.- Specified by:
needsReconcilingin interfaceIHandlyXtextDocument- Returns:
trueif reconciling is needed, andfalseotherwise
-
reconcile
public void reconcile(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)Description copied from interface:IHandlyXtextDocumentReconciles 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
forceparameter controls whether the document model has to be reconciled even if it is already in sync with the document text.- Specified by:
reconcilein interfaceIHandlyXtextDocument- 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, ornullif progress reporting is not desired. The caller must not rely onIProgressMonitor.done()having been called by the receiver
-
modify
public <T> T modify(org.eclipse.xtext.util.concurrent.IUnitOfWork<T,org.eclipse.xtext.resource.XtextResource> work)
Description copied from interface:IHandlyXtextDocumentExecutes 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 beinformedof an undo change that can beappliedto 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 invokereconcilebefore calling this method to ensure a fresh snapshot; reconciling happens automatically before the top-level unit of work is run.- Specified by:
modifyin interfaceIHandlyXtextDocument- Specified by:
modifyin interfaceorg.eclipse.xtext.util.concurrent.IWriteAccess<org.eclipse.xtext.resource.XtextResource>- Overrides:
modifyin classorg.eclipse.xtext.ui.editor.model.XtextDocument- 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)
-
applyChange
public IDocumentChange applyChange(IDocumentChange change) throws org.eclipse.jface.text.BadLocationException
Description copied from interface:IHandlyXtextDocumentApplies 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
StaleSnapshotExceptionis thrown.- Specified by:
applyChangein interfaceIHandlyXtextDocument- Parameters:
change- a document change (notnull)- Returns:
- undo change, if requested by the given change.
Otherwise,
null - Throws:
org.eclipse.jface.text.BadLocationException- if one of the edits in the change's edit tree could not be executed
-
-