public class FrozenDocument extends java.lang.Object implements DocumentEx
EMPTY_ARRAY, PROP_WRITABLE| Modifier and Type | Method and Description |
|---|---|
FrozenDocument |
applyEvent(DocumentEvent event,
int newStamp) |
void |
clearLineModificationFlags() |
RangeMarker |
createGuardedBlock(int startOffset,
int endOffset)
Marks a range of text in the document as read-only (attempts to modify text in the
range cause
ReadOnlyFragmentModificationException to be thrown). |
LineIterator |
createLineIterator() |
RangeMarker |
createRangeMarker(int startOffset,
int endOffset,
boolean surviveOnExternalChange)
Creates a range marker which points to the specified range of text in the document and
is automatically adjusted when the document text is changed.
|
void |
deleteString(int startOffset,
int endOffset)
Deletes the specified range of text from the document.
|
java.lang.CharSequence |
getCharsSequence()
Use this method instead of
Document.getText() if you do not need to create a copy of the content. |
java.lang.CharSequence |
getImmutableCharSequence() |
int |
getLineCount()
Returns the number of lines in the document.
|
int |
getLineEndOffset(int line)
Returns the end offset for the line with the specified number.
|
int |
getLineNumber(int offset)
Returns the line number (0-based) corresponding to the specified offset in the document.
|
int |
getLineSeparatorLength(int line) |
int |
getLineStartOffset(int line)
Returns the start offset for the line with the specified number.
|
long |
getModificationStamp()
Gets the modification stamp value.
|
RangeMarker |
getOffsetGuard(int offset)
Returns the read-only marker covering the specified offset in the document.
|
RangeMarker |
getRangeGuard(int start,
int end)
Returns the read-only marker covering the specified range in the document.
|
java.lang.String |
getText()
Retrieves a copy of the document content.
|
java.lang.String |
getText(TextRange range) |
<T> T |
getUserData(Key<T> key) |
void |
insertString(int offset,
java.lang.CharSequence s)
Inserts the specified text at the specified offset in the document.
|
boolean |
isWritable()
Checks if the document text is read-only.
|
boolean |
processRangeMarkers(Processor<? super RangeMarker> processor)
Get all range markers
and hand them to the
processor in their RangeMarker.getStartOffset() order |
boolean |
processRangeMarkersOverlappingWith(int start,
int end,
Processor<? super RangeMarker> processor)
Get range markers which
TextRange.intersects(int, int) the specified range
and hand them to the processor in their RangeMarker.getStartOffset() order |
<T> void |
putUserData(Key<T> key,
T value)
Add a new user data value to this object.
|
void |
registerRangeMarker(RangeMarkerEx rangeMarker,
int start,
int end,
boolean greedyToLeft,
boolean greedyToRight,
int layer) |
void |
removeEditReadOnlyListener(EditReadOnlyListener listener) |
void |
removeGuardedBlock(RangeMarker block)
Removes a marker marking a range of text in the document as read-only.
|
boolean |
removeRangeMarker(RangeMarkerEx rangeMarker) |
void |
replaceString(int startOffset,
int endOffset,
java.lang.CharSequence s)
Replaces the specified range of text in the document with the specified string.
|
void |
replaceText(java.lang.CharSequence chars,
long newModificationStamp) |
void |
setModificationStamp(long modificationStamp) |
void |
setReadOnly(boolean isReadOnly)
Marks the document as read-only or read/write.
|
void |
setStripTrailingSpacesEnabled(boolean isEnabled) |
void |
setText(java.lang.CharSequence text) |
void |
startGuardedBlockChecking()
Enables checking for read-only markers when the document is modified.
|
void |
stopGuardedBlockChecking()
Disables checking for read-only markers when the document is modified.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddEditReadOnlyListener, getGuardedBlocks, getModificationSequence, isInEventsHandling, moveText, suppressGuardedExceptions, unSuppressGuardedExceptionsaddDocumentListener, addDocumentListener, addPropertyChangeListener, createRangeMarker, createRangeMarker, fireReadOnlyModificationAttempt, getChars, getTextLength, isInBulkUpdate, isLineModified, removeDocumentListener, removePropertyChangeListener, setCyclicBufferSize, setInBulkUpdatepublic FrozenDocument applyEvent(DocumentEvent event, int newStamp)
public LineIterator createLineIterator()
createLineIterator in interface DocumentExpublic void setModificationStamp(long modificationStamp)
setModificationStamp in interface DocumentExpublic void replaceText(java.lang.CharSequence chars,
long newModificationStamp)
replaceText in interface DocumentExpublic void clearLineModificationFlags()
clearLineModificationFlags in interface DocumentExpublic boolean removeRangeMarker(RangeMarkerEx rangeMarker)
removeRangeMarker in interface DocumentExpublic void registerRangeMarker(RangeMarkerEx rangeMarker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer)
registerRangeMarker in interface DocumentExpublic boolean processRangeMarkers(Processor<? super RangeMarker> processor)
DocumentExprocessor in their RangeMarker.getStartOffset() orderprocessRangeMarkers in interface DocumentExpublic boolean processRangeMarkersOverlappingWith(int start,
int end,
Processor<? super RangeMarker> processor)
DocumentExTextRange.intersects(int, int) the specified range
and hand them to the processor in their RangeMarker.getStartOffset() orderprocessRangeMarkersOverlappingWith in interface DocumentExpublic java.lang.String getText()
DocumentDocument.getCharsSequence() whenever it's possible.public java.lang.String getText(TextRange range)
public java.lang.CharSequence getCharsSequence()
DocumentDocument.getText() if you do not need to create a copy of the content.
Content represented by returned CharSequence is subject to change whenever document is modified via delete/replace/insertString method
calls. It is necessary to obtain Application.runWriteAction() to modify content of the document though so threading issues won't
arise.getCharsSequence in interface DocumentDocument.getTextLength()public java.lang.CharSequence getImmutableCharSequence()
getImmutableCharSequence in interface DocumentImmutableCharSequencepublic int getLineCount()
DocumentgetLineCount in interface Documentpublic int getLineNumber(int offset)
DocumentgetLineNumber in interface Documentoffset - the offset to get the line number for (must be in the range from 0 to
getTextLength()-1)public int getLineStartOffset(int line)
DocumentgetLineStartOffset in interface Documentline - the line number (from 0 to getLineCount()-1)public int getLineEndOffset(int line)
DocumentgetLineEndOffset in interface Documentline - the line number (from 0 to getLineCount()-1)public void insertString(int offset,
java.lang.CharSequence s)
DocumentinsertString in interface Documentoffset - the offset to insert the text at.s - the text to insert.public void deleteString(int startOffset,
int endOffset)
DocumentdeleteString in interface DocumentstartOffset - the start offset of the range to delete.endOffset - the end offset of the range to delete.public void replaceString(int startOffset,
int endOffset,
java.lang.CharSequence s)
DocumentreplaceString in interface DocumentstartOffset - the start offset of the range to replace.endOffset - the end offset of the range to replace.s - the text to replace with.public boolean isWritable()
DocumentisWritable in interface Documenttrue if the document text is writable, false if it is read-only.Document.fireReadOnlyModificationAttempt()public long getModificationStamp()
DocumentgetModificationStamp in interface DocumentPsiFile.getModificationStamp(),
VirtualFile.getModificationStamp()public RangeMarker createRangeMarker(int startOffset, int endOffset, boolean surviveOnExternalChange)
DocumentcreateRangeMarker in interface DocumentstartOffset - the start offset for the range of text covered by the marker.endOffset - the end offset for the range of text covered by the marker.surviveOnExternalChange - if true, the marker is not invalidated by external changes.public void setReadOnly(boolean isReadOnly)
DocumentsetReadOnly in interface DocumentisReadOnly - the new value of the read-only flag.Document.isWritable(),
Document.fireReadOnlyModificationAttempt()public RangeMarker createGuardedBlock(int startOffset, int endOffset)
DocumentReadOnlyFragmentModificationException to be thrown).createGuardedBlock in interface DocumentstartOffset - the start offset of the text range to mark as read-only.endOffset - the end offset of the text range to mark as read-only.Document.removeGuardedBlock(RangeMarker),
Document.startGuardedBlockChecking(),
EditorActionManager.setReadonlyFragmentModificationHandler(com.intellij.openapi.editor.actionSystem.ReadonlyFragmentModificationHandler)public void removeGuardedBlock(RangeMarker block)
DocumentremoveGuardedBlock in interface Documentblock - the marker to remove.Document.createGuardedBlock(int, int)public RangeMarker getOffsetGuard(int offset)
DocumentgetOffsetGuard in interface Documentoffset - the offset for which the marker is requested.null if the specified offset is not covered by a read-only marker.public RangeMarker getRangeGuard(int start, int end)
DocumentgetRangeGuard in interface Documentstart - the start offset of the range for which the marker is requested.end - the end offset of the range for which the marker is requested.null if the specified range is not covered by a read-only marker.public void startGuardedBlockChecking()
DocumentstartGuardedBlockChecking in interface DocumentDocument.createGuardedBlock(int, int),
Document.stopGuardedBlockChecking()public void stopGuardedBlockChecking()
DocumentstopGuardedBlockChecking in interface DocumentDocument.createGuardedBlock(int, int),
Document.startGuardedBlockChecking()public void setText(java.lang.CharSequence text)
public int getLineSeparatorLength(int line)
getLineSeparatorLength in interface Documentpublic <T> T getUserData(Key<T> key)
getUserData in interface UserDataHolderpublic <T> void putUserData(Key<T> key, T value)
UserDataHolderputUserData in interface UserDataHolderpublic void setStripTrailingSpacesEnabled(boolean isEnabled)
setStripTrailingSpacesEnabled in interface DocumentExpublic void removeEditReadOnlyListener(EditReadOnlyListener listener)
removeEditReadOnlyListener in interface DocumentEx