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 |
COMPARATOR
ARRAY_FACTORY, EMPTY_ARRAY
EVER_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, onRemoved
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFoldRegion, runBatchFoldingOperation, runBatchFoldingOperationDoNotCollapseCaret
bulkUpdateFinished, bulkUpdateStarting
onBatchModeFinish, onBatchModeStart, onUpdated
public static final Key<java.lang.Boolean> SELECT_REGION_ON_CARET_NEARBY
public java.util.List<FoldRegion> getGroupedRegions(FoldingGroup group)
getGroupedRegions
in interface FoldingModelEx
public void clearDocumentRangesModificationStatus()
clearDocumentRangesModificationStatus
in interface FoldingModelEx
public boolean hasDocumentRegionChangedFor(FoldRegion region)
hasDocumentRegionChangedFor
in interface FoldingModelEx
public int getEndOffset(FoldingGroup group)
public boolean isFoldingEnabled()
isFoldingEnabled
in interface FoldingModelEx
public boolean isOffsetCollapsed(int offset)
FoldingModel
FoldingModel.runBatchFoldingOperation(Runnable)
invocation.isOffsetCollapsed
in interface FoldingModel
offset
- the offset to check.FoldingModel.getCollapsedRegionAtOffset(int)
public void setFoldingEnabled(boolean isEnabled)
setFoldingEnabled
in interface FoldingModelEx
public FoldRegion addFoldRegion(int startOffset, int endOffset, java.lang.String placeholderText)
FoldingModel
Runnable
passed to FoldingModel.runBatchFoldingOperation(Runnable)
.
The region is initially not folded.addFoldRegion
in interface FoldingModel
startOffset
- 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)
FoldingModel
runBatchFoldingOperation
in interface FoldingModel
allowMovingCaret
- 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 FoldingModel
public FoldRegion [] getAllFoldRegions()
FoldingModel
RangeMarker.BY_START_OFFSET
comparator, i.e. first by start offset, then by end offset.getAllFoldRegions
in interface FoldingModel
public FoldRegion getCollapsedRegionAtOffset(int offset)
FoldingModel
null
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 FoldingModel
FoldingModel.isOffsetCollapsed(int)
public FoldRegion getFoldRegion(int startOffset, int endOffset)
FoldingModel
null
otherwise.getFoldRegion
in interface FoldingModel
public FoldRegion getFoldingPlaceholderAt(java.awt.Point p)
getFoldingPlaceholderAt
in interface FoldingModelEx
public void removeFoldRegion(FoldRegion region)
FoldingModel
Runnable
passed to FoldingModel.runBatchFoldingOperation(Runnable)
.removeFoldRegion
in interface FoldingModel
region
- the region to remove.public void clearFoldRegions()
clearFoldRegions
in interface FoldingModelEx
public void rebuild()
rebuild
in interface FoldingModelEx
public boolean isInBatchFoldingOperation()
public int getFoldedLinesCountBefore(int offset)
public FoldRegion [] fetchTopLevel()
fetchTopLevel
in interface FoldingModelEx
public boolean intersectsRegion(int startOffset, int endOffset)
intersectsRegion
in interface FoldingModelEx
public int getLastCollapsedRegionBefore(int offset)
FoldingModelEx
FoldingModelEx.fetchTopLevel()
method, for the last folding region lying entirely before given
offset (region can touch given offset at its right edge).getLastCollapsedRegionBefore
in interface FoldingModelEx
public TextAttributes getPlaceholderAttributes()
getPlaceholderAttributes
in interface FoldingModelEx
public void beforeDocumentChange(DocumentEvent event)
DocumentListener
beforeDocumentChange
in interface DocumentListener
event
- the event containing the information about the change.public void documentChanged(DocumentEvent event)
DocumentListener
documentChanged
in interface DocumentListener
event
- the event containing the information about the change.public int getPriority()
getPriority
in interface PrioritizedDocumentListener
public void onUpdated(Inlay inlay, int changeFlags)
onUpdated
in interface InlayModel.Listener
changeFlags
- see InlayModel.ChangeFlags
public FoldRegion createFoldRegion(int startOffset, int endOffset, java.lang.String placeholder, FoldingGroup group, boolean neverExpands)
createFoldRegion
in interface FoldingModelEx
neverExpands
- 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 FoldingModelEx
public java.lang.String toString()
toString
in class java.lang.Object
public long getModificationCount()
getModificationCount
in interface ModificationTracker