|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Document
Represents the contents of a text file loaded into memory, and possibly opened in an IDEA text editor. Line breaks in the document text are always normalized as single \n characters, and are converted to proper format when the document is saved.
Editor.getDocument(),
PsiDocumentManager,
FileDocumentManager,
EditorFactory.createDocument(CharSequence)| Field Summary | |
|---|---|
static java.lang.String |
PROP_WRITABLE
|
| Method Summary | |
|---|---|
void |
addDocumentListener(DocumentListener listener)
Adds a listener for receiving notifications about changes in the document content. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener for receiving notifications about changes in the properties of the document (for example, its read-only state). |
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). |
RangeMarker |
createRangeMarker(int startOffset,
int endOffset)
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. |
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. |
void |
fireReadOnlyModificationAttempt()
Fires a notification that the user would like to remove the read-only state from the document (the read-only state can be removed by checking the file out from the version control system, or by clearing the read-only attribute on the file). |
char[] |
getChars()
Deprecated. Use getCharsSequence() or getText() instead. |
java.lang.CharSequence |
getCharsSequence()
Use this method instead of getText() if you do not need to create a copy of the content. |
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 |
getLineStartOffset(int line)
Returns the start offset for the line with the specified number. |
MarkupModel |
getMarkupModel()
Deprecated. use getMarkupModel(com.intellij.openapi.project.Project) instead. |
MarkupModel |
getMarkupModel(Project project)
Returns the markup model for the specified project. |
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()
Retreives a copy of the document content. |
int |
getTextLength()
Returns the length of the document text. |
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. |
void |
removeDocumentListener(DocumentListener listener)
Removes a listener for receiving notifications about changes in the document content. |
void |
removeGuardedBlock(RangeMarker block)
Removes a marker marking a range of text in the document as read-only. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener for receiving notifications about changes in the properties of the document (for example, its read-only state). |
void |
replaceString(int startOffset,
int endOffset,
java.lang.CharSequence s)
Replaces the specified range of text in the document with the specified string. |
void |
setCyclicBufferSize(int bufferSize)
Sets the maximum size of the cyclic buffer used for the document. |
void |
setReadOnly(boolean isReadOnly)
Marks the document as read-only or read/write. |
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. |
| Methods inherited from interface com.intellij.openapi.util.UserDataHolder |
|---|
getUserData, putUserData |
| Field Detail |
|---|
@NonNls static final java.lang.String PROP_WRITABLE
| Method Detail |
|---|
java.lang.String getText()
getCharsSequence() whenever it's possible.
java.lang.CharSequence getCharsSequence()
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.
getTextLength()char[] getChars()
getCharsSequence() or getText() instead.
int getTextLength()
getCharsSequence()int getLineCount()
int getLineNumber(int offset)
offset - the offset to get the line number for (must be in the range from 0 to
getTextLength()-1)
int getLineStartOffset(int line)
line - the line number (from 0 to getLineCount()-1)
int getLineEndOffset(int line)
line - the line number (from 0 to getLineCount()-1)
void insertString(int offset,
java.lang.CharSequence s)
offset - the offset to insert the text at.s - the text to insert.
ReadOnlyModificationException - if the document is read-only.
ReadOnlyFragmentModificationException - if the fragment to be modified is covered by a guarded block.
void deleteString(int startOffset,
int endOffset)
startOffset - the start offset of the range to delete.endOffset - the end offset of the range to delete.
ReadOnlyModificationException - if the document is read-only.
ReadOnlyFragmentModificationException - if the fragment to be modified is covered by a guarded block.
void replaceString(int startOffset,
int endOffset,
java.lang.CharSequence s)
startOffset - the start offset of the range to replace.endOffset - the end offset of the range to replace.s - the text to replace with.
ReadOnlyModificationException - if the document is read-only.
ReadOnlyFragmentModificationException - if the fragment to be modified is covered by a guarded block.boolean isWritable()
fireReadOnlyModificationAttempt()long getModificationStamp()
PsiFile.getModificationStamp(),
VirtualFile.getModificationStamp()void fireReadOnlyModificationAttempt()
void addDocumentListener(DocumentListener listener)
listener - the listener instance.void removeDocumentListener(DocumentListener listener)
listener - the listener instance.
RangeMarker createRangeMarker(int startOffset,
int endOffset)
startOffset - 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.
RangeMarker createRangeMarker(int startOffset,
int endOffset,
boolean surviveOnExternalChange)
startOffset - 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.
MarkupModel getMarkupModel()
getMarkupModel(com.intellij.openapi.project.Project) instead.
@NotNull
MarkupModel getMarkupModel(@Nullable
Project project)
project - the project for which the markup model is requested, or null if the default markup
model is requested.
Editor.getMarkupModel()void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - the listener instance.void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - the listener instance.void setReadOnly(boolean isReadOnly)
isReadOnly - the new value of the read-only flag.isWritable(),
fireReadOnlyModificationAttempt()
RangeMarker createGuardedBlock(int startOffset,
int endOffset)
ReadOnlyFragmentModificationException to be thrown).
startOffset - the start offset of the text range to mark as read-only.startOffset - the end offset of the text range to mark as read-only.
removeGuardedBlock(RangeMarker),
startGuardedBlockChecking(),
EditorActionManager.setReadonlyFragmentModificationHandler(com.intellij.openapi.editor.actionSystem.ReadonlyFragmentModificationHandler)void removeGuardedBlock(RangeMarker block)
block - the marker to remove.createGuardedBlock(int, int)@Nullable RangeMarker getOffsetGuard(int offset)
offset - the offset for which the marker is requested.
@Nullable
RangeMarker getRangeGuard(int start,
int end)
start - 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.
void startGuardedBlockChecking()
createGuardedBlock(int, int),
stopGuardedBlockChecking()void stopGuardedBlockChecking()
createGuardedBlock(int, int),
startGuardedBlockChecking()void setCyclicBufferSize(int bufferSize)
bufferSize - the cyclic buffer size, or 0 if the document should not use a cyclic buffer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||