public class FoldingModelImpl extends InlayModel.SimpleAdapter implements FoldingModelEx, PrioritizedDocumentListener, Dumpable, ModificationTracker
| Modifier and Type | Field and Description |
|---|---|
static Key<java.lang.Boolean> |
SELECT_REGION_ON_CARET_NEARBY |
COMPARATORARRAY_FACTORY, EMPTY_ARRAYEVER_CHANGED, NEVER_CHANGED| Modifier and Type | Method and Description |
|---|---|
FoldRegion |
addFoldRegion(int startOffset,
int endOffset,
java.lang.String placeholderText)
Adds a fold region for the specified range of the document.
|
void |
addListener(FoldingListener listener,
Disposable parentDisposable) |
void |
beforeDocumentChange(DocumentEvent event)
Called before the text of the document is changed.
|
void |
clearDocumentRangesModificationStatus() |
void |
clearFoldRegions() |
FoldRegion |
createFoldRegion(int startOffset,
int endOffset,
java.lang.String placeholder,
FoldingGroup group,
boolean neverExpands) |
void |
documentChanged(DocumentEvent event)
Called after the text of the document has been changed.
|
java.lang.String |
dumpState() |
FoldRegion [] |
fetchTopLevel() |
FoldRegion [] |
getAllFoldRegions()
Gets the list of all fold regions in the specified editor.
|
FoldRegion |
getCollapsedRegionAtOffset(int offset)
Returns collapsed folded region at a given offset or
null if there's no such region. |
int |
getEndOffset(FoldingGroup group) |
int |
getFoldedLinesCountBefore(int offset) |
FoldRegion |
getFoldingPlaceholderAt(java.awt.Point p) |
FoldRegion |
getFoldRegion(int startOffset,
int endOffset)
Returns fold region with given boundaries, if it exists, or
null otherwise. |
java.util.List<FoldRegion> |
getGroupedRegions(FoldingGroup group) |
int |
getLastCollapsedRegionBefore(int offset)
Returns an index in an array returned by
FoldingModelEx.fetchTopLevel() method, for the last folding region lying entirely before given
offset (region can touch given offset at its right edge). |
long |
getModificationCount() |
TextAttributes |
getPlaceholderAttributes() |
int |
getPriority() |
boolean |
hasDocumentRegionChangedFor(FoldRegion region) |
boolean |
intersectsRegion(int startOffset,
int endOffset) |
boolean |
isFoldingEnabled() |
boolean |
isInBatchFoldingOperation() |
boolean |
isOffsetCollapsed(int offset)
Checks if the specified offset in the document belongs to a folded region.
|
void |
onUpdated(Inlay inlay,
int changeFlags) |
void |
rebuild() |
void |
removeFoldRegion(FoldRegion region)
Removes the specified fold region.
|
void |
runBatchFoldingOperation(java.lang.Runnable operation,
boolean moveCaret) |
void |
runBatchFoldingOperation(java.lang.Runnable operation,
boolean allowMovingCaret,
boolean keepRelativeCaretPosition)
Performs folding model changes (creation/deletion/expanding/collapsing of fold regions).
|
void |
setFoldingEnabled(boolean isEnabled) |
java.lang.String |
toString() |
onAdded, onRemovedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddFoldRegion, runBatchFoldingOperation, runBatchFoldingOperationDoNotCollapseCaretbulkUpdateFinished, bulkUpdateStartingonBatchModeFinish, onBatchModeStart, onUpdatedpublic static final Key<java.lang.Boolean> SELECT_REGION_ON_CARET_NEARBY
public java.util.List<FoldRegion> getGroupedRegions(FoldingGroup group)
getGroupedRegions in interface FoldingModelExpublic void clearDocumentRangesModificationStatus()
clearDocumentRangesModificationStatus in interface FoldingModelExpublic boolean hasDocumentRegionChangedFor(FoldRegion region)
hasDocumentRegionChangedFor in interface FoldingModelExpublic int getEndOffset(FoldingGroup group)
public boolean isFoldingEnabled()
isFoldingEnabled in interface FoldingModelExpublic boolean isOffsetCollapsed(int offset)
FoldingModelFoldingModel.runBatchFoldingOperation(Runnable) invocation.isOffsetCollapsed in interface FoldingModeloffset - the offset to check.FoldingModel.getCollapsedRegionAtOffset(int)public void setFoldingEnabled(boolean isEnabled)
setFoldingEnabled in interface FoldingModelExpublic FoldRegion addFoldRegion(int startOffset, int endOffset, java.lang.String placeholderText)
FoldingModelRunnable passed to FoldingModel.runBatchFoldingOperation(Runnable).
The region is initially not folded.addFoldRegion in interface FoldingModelstartOffset - the start offset of the region to fold.endOffset - the end offset of the region to fold.placeholderText - the text to display instead of the region contents when the region is folded.null if folding is currently disabled or corresponding region cannot be added (e.g. if it
intersects with another existing region)public void runBatchFoldingOperation(java.lang.Runnable operation,
boolean allowMovingCaret,
boolean keepRelativeCaretPosition)
FoldingModelrunBatchFoldingOperation in interface FoldingModelallowMovingCaret - If false, requests to collapse a region containing caret won't be processed. If true -
corresponding operation will be performed with caret automatically moved to the region's start offset
(original caret position is remembered and is restored on region expansion).keepRelativeCaretPosition - If true, editor scrolling position will be adjusted after the operation, so that vertical
caret position will remain unchanged (if caret is not visible at operation start, top left corner
of editor will be used as an anchor instead). If false, no scrolling adjustment will be done.public void runBatchFoldingOperation(java.lang.Runnable operation,
boolean moveCaret)
runBatchFoldingOperation in interface FoldingModelpublic FoldRegion [] getAllFoldRegions()
FoldingModelRangeMarker.BY_START_OFFSET comparator, i.e. first by start offset, then by end offset.getAllFoldRegions in interface FoldingModelpublic FoldRegion getCollapsedRegionAtOffset(int offset)
FoldingModelnull if there's no such region. Returned region will satisfy the
following condition: region.getStartOffset() <= offset < region.getEndOffset()
FoldingModel.runBatchFoldingOperation(Runnable) invocation.getCollapsedRegionAtOffset in interface FoldingModelFoldingModel.isOffsetCollapsed(int)public FoldRegion getFoldRegion(int startOffset, int endOffset)
FoldingModelnull otherwise.getFoldRegion in interface FoldingModelpublic FoldRegion getFoldingPlaceholderAt(java.awt.Point p)
getFoldingPlaceholderAt in interface FoldingModelExpublic void removeFoldRegion(FoldRegion region)
FoldingModelRunnable passed to FoldingModel.runBatchFoldingOperation(Runnable).removeFoldRegion in interface FoldingModelregion - the region to remove.public void clearFoldRegions()
clearFoldRegions in interface FoldingModelExpublic void rebuild()
rebuild in interface FoldingModelExpublic boolean isInBatchFoldingOperation()
public int getFoldedLinesCountBefore(int offset)
public FoldRegion [] fetchTopLevel()
fetchTopLevel in interface FoldingModelExpublic boolean intersectsRegion(int startOffset,
int endOffset)
intersectsRegion in interface FoldingModelExpublic int getLastCollapsedRegionBefore(int offset)
FoldingModelExFoldingModelEx.fetchTopLevel() method, for the last folding region lying entirely before given
offset (region can touch given offset at its right edge).getLastCollapsedRegionBefore in interface FoldingModelExpublic TextAttributes getPlaceholderAttributes()
getPlaceholderAttributes in interface FoldingModelExpublic void beforeDocumentChange(DocumentEvent event)
DocumentListenerbeforeDocumentChange in interface DocumentListenerevent - the event containing the information about the change.public void documentChanged(DocumentEvent event)
DocumentListenerdocumentChanged in interface DocumentListenerevent - the event containing the information about the change.public int getPriority()
getPriority in interface PrioritizedDocumentListenerpublic void onUpdated(Inlay inlay, int changeFlags)
onUpdated in interface InlayModel.ListenerchangeFlags - see InlayModel.ChangeFlagspublic FoldRegion createFoldRegion(int startOffset, int endOffset, java.lang.String placeholder, FoldingGroup group, boolean neverExpands)
createFoldRegion in interface FoldingModelExneverExpands - If true, the created region is created in the collapsed state, and cannot be expanded
(FoldRegion.setExpanded(boolean) does nothing for it). No marker will be displayed in gutter for such a
region. 'Never-expanding' fold region cannot be part of a FoldingGroup.public void addListener(FoldingListener listener, Disposable parentDisposable)
addListener in interface FoldingModelExpublic java.lang.String toString()
toString in class java.lang.Objectpublic long getModificationCount()
getModificationCount in interface ModificationTracker