use of com.intellij.openapi.editor.FoldRegion in project intellij-community by JetBrains.
the class FoldingModelWindow method getGroupedRegions.
@NotNull
@Override
public List<FoldRegion> getGroupedRegions(FoldingGroup group) {
List<FoldRegion> hostRegions = myDelegate.getGroupedRegions(group);
List<FoldRegion> result = new ArrayList<>();
for (FoldRegion hostRegion : hostRegions) {
FoldingRegionWindow window = getWindowRegion(hostRegion);
if (window != null)
result.add(window);
}
return result;
}
use of com.intellij.openapi.editor.FoldRegion in project intellij-community by JetBrains.
the class CopyPasteFoldingProcessor method processTransferableData.
@Override
public void processTransferableData(final Project project, final Editor editor, final RangeMarker bounds, int caretOffset, Ref<Boolean> indented, final List<FoldingTransferableData> values) {
assert values.size() == 1;
final FoldingTransferableData value = values.get(0);
if (value.getData().length == 0)
return;
final CodeFoldingManagerImpl foldingManager = (CodeFoldingManagerImpl) CodeFoldingManager.getInstance(project);
foldingManager.updateFoldRegions(editor, true);
Runnable operation = () -> {
for (FoldingData data : value.getData()) {
FoldRegion region = foldingManager.findFoldRegion(editor, data.startOffset + bounds.getStartOffset(), data.endOffset + bounds.getStartOffset());
if (region != null) {
region.setExpanded(data.isExpanded);
}
}
};
editor.getFoldingModel().runBatchFoldingOperation(operation);
}
use of com.intellij.openapi.editor.FoldRegion in project intellij-community by JetBrains.
the class FoldingModelSupport method expandAll.
//
// Synchronized toggling of ranges
//
public void expandAll(final boolean expanded) {
if (myDuringSynchronize)
return;
myDuringSynchronize = true;
try {
for (int i = 0; i < myCount; i++) {
final int index = i;
final FoldingModelEx model = myEditors[index].getFoldingModel();
model.runBatchFoldingOperation(() -> {
for (FoldedBlock folding : getFoldedBlocks()) {
FoldRegion region = folding.getRegion(index);
if (region != null)
region.setExpanded(expanded);
}
});
}
} finally {
myDuringSynchronize = false;
}
}
use of com.intellij.openapi.editor.FoldRegion in project intellij-community by JetBrains.
the class FoldingModelSupport method getFoldedRanges.
@NotNull
private List<FoldedRangeState> getFoldedRanges(int index, @NotNull Settings settings) {
ApplicationManager.getApplication().assertReadAccessAllowed();
List<FoldedRangeState> ranges = new ArrayList<>();
DocumentEx document = myEditors[index].getDocument();
for (FoldedBlock[] blocks : myFoldings) {
LineRange expanded = null;
LineRange collapsed = null;
for (FoldedBlock folding : blocks) {
FoldRegion region = folding.getRegion(index);
if (region == null || !region.isValid())
continue;
if (region.isExpanded()) {
if (expanded == null) {
int line1 = document.getLineNumber(region.getStartOffset());
int line2 = document.getLineNumber(region.getEndOffset()) + 1;
expanded = new LineRange(line1, line2);
}
} else {
int line1 = document.getLineNumber(region.getStartOffset());
int line2 = document.getLineNumber(region.getEndOffset()) + 1;
collapsed = new LineRange(line1, line2);
break;
}
}
if (expanded != null || collapsed != null) {
ranges.add(new FoldedRangeState(expanded, collapsed));
}
}
return ranges;
}
use of com.intellij.openapi.editor.FoldRegion in project intellij-community by JetBrains.
the class FoldingAnchorsOverlayStrategyTest method collapseFoldingRegion.
private void collapseFoldingRegion(int n) {
FoldingModel foldingModel = myFixture.getEditor().getFoldingModel();
final FoldRegion foldRegion = foldingModel.getAllFoldRegions()[n];
foldingModel.runBatchFoldingOperation(() -> foldRegion.setExpanded(false));
}
Aggregations