本文整理汇总了Java中com.intellij.openapi.editor.FoldRegion类的典型用法代码示例。如果您正苦于以下问题:Java FoldRegion类的具体用法?Java FoldRegion怎么用?Java FoldRegion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FoldRegion类属于com.intellij.openapi.editor包,在下文中一共展示了FoldRegion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: fold
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
/**
* Runs a batch folding operation that folds the given text range
*
* @param editor the editor to get the folding model
* @param textRange the text range to fold
* @param placeholderText the fold region placeholder text
*/
private void fold(@NotNull final Editor editor, @NotNull final TextRange textRange, @NotNull final String placeholderText) {
editor.getFoldingModel().runBatchFoldingOperation(() -> {
FoldRegion foldRegion = editor.getFoldingModel()
.getFoldRegion(textRange.getStartOffset(), textRange.getEndOffset());
if (foldRegion == null) {
foldRegion = editor.getFoldingModel()
.addFoldRegion(textRange.getStartOffset(), textRange.getEndOffset(),
placeholderText);
}
if (foldRegion != null) {
foldRegion.setExpanded(false);
}
});
}
开发者ID:healarconr,项目名称:logger-folding,代码行数:24,代码来源:FoldLoggerMethodCallsAction.java
示例2: testFoldingIsNotBlinkingOnNavigationToSingleLineMethod
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
public void testFoldingIsNotBlinkingOnNavigationToSingleLineMethod() {
VirtualFile file = getFile("/src/Bar.java");
PsiJavaFile psiFile = (PsiJavaFile)getPsiManager().findFile(file);
assertNotNull(psiFile);
PsiMethod method = psiFile.getClasses()[0].getMethods()[0];
method.navigate(true);
FileEditor[] editors = myManager.getEditors(file);
assertEquals(1, editors.length);
Editor editor = ((TextEditor)editors[0]).getEditor();
FoldRegion[] regions = editor.getFoldingModel().getAllFoldRegions();
assertEquals(2, regions.length);
assertTrue(regions[0].isExpanded());
assertTrue(regions[1].isExpanded());
CodeInsightTestFixtureImpl.instantiateAndRun(psiFile, editor, new int[]{Pass.UPDATE_ALL, Pass.LOCAL_INSPECTIONS}, false);
regions = editor.getFoldingModel().getAllFoldRegions();
assertEquals(2, regions.length);
assertTrue(regions[0].isExpanded());
assertTrue(regions[1].isExpanded());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JavaFileEditorManagerTest.java
示例3: testUnexpectedClassLevelJavadocExpandingOnClassSignatureChange
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
public void testUnexpectedClassLevelJavadocExpandingOnClassSignatureChange() throws IOException {
// Inspired by IDEA-61275
String text =
"/**\n" +
" * This is a test comment\n" +
" */\n" +
"public <caret>class Test {\n" +
"}";
init(text, TestFileType.JAVA);
CaretModel caretModel = myEditor.getCaretModel();
int caretOffset = caretModel.getOffset();
assertEquals(caretOffset, caretModel.getOffset());
updateFoldRegions();
toggleFoldRegionState(getFoldRegion(0), false);
type('a');
updateFoldRegions();
assertEquals(caretOffset + 1, caretModel.getOffset());
assertEquals(1, myEditor.getFoldingModel().getAllFoldRegions().length);
FoldRegion foldRegion = getFoldRegion(0);
assertFalse(foldRegion.isExpanded());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:FoldingProcessingOnDocumentModificationTest.java
示例4: createRange
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
@Nullable
private FoldedBlock createRange(int[] starts, int[] ends, boolean expanded) {
boolean hasFolding = false;
FoldRegion[] regions = new FoldRegion[myCount];
boolean hasExpanded = false; // do not desync on runBatchFoldingOperationDoNotCollapseCaret
for (int i = 0; i < myCount; i++) {
if (ends[i] - starts[i] < 2) continue;
regions[i] = addFolding(myEditors[i], starts[i], ends[i], expanded);
hasFolding |= regions[i] != null;
hasExpanded |= regions[i] != null && regions[i].isExpanded();
}
if (hasExpanded && !expanded) {
for (FoldRegion region : regions) {
if (region != null) region.setExpanded(true);
}
}
return hasFolding ? new FoldedBlock(regions) : null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:FoldingModelSupport.java
示例5: getLineConvertor
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
@NotNull
protected TIntFunction getLineConvertor(final int index) {
return new TIntFunction() {
@Override
public int execute(int value) {
updateLineNumbers(false);
for (FoldedBlock folding : getFoldedBlocks()) { // TODO: avoid full scan - it could slowdown painting
int line = folding.getLine(index);
if (line == -1) continue;
if (line > value) break;
FoldRegion region = folding.getRegion(index);
if (line == value && region != null && !region.isExpanded()) return -1;
}
return value;
}
};
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:FoldingModelSupport.java
示例6: expandAll
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
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(new Runnable() {
@Override
public void run() {
for (FoldedBlock folding : getFoldedBlocks()) {
FoldRegion region = folding.getRegion(index);
if (region != null) region.setExpanded(expanded);
}
}
});
}
}
finally {
myDuringSynchronize = false;
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:FoldingModelSupport.java
示例7: getHighlighterCondition
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
@NotNull
private BooleanGetter getHighlighterCondition(@NotNull final FoldedBlock[] block, final int index) {
return new BooleanGetter() {
@Override
public boolean get() {
if (!myEditors[index].getFoldingModel().isFoldingEnabled()) return false;
for (FoldedBlock folding : block) {
FoldRegion region = folding.getRegion(index);
boolean visible = region != null && region.isValid() && !region.isExpanded();
if (folding == FoldedBlock.this) return visible;
if (visible) return false; // do not paint separator, if 'parent' folding is collapsed
}
return false;
}
};
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:FoldingModelSupport.java
示例8: advancePositionOnFolding
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
protected void advancePositionOnFolding(@NotNull EditorPosition position, @NotNull FoldRegion foldRegion) {
Document document = myEditor.getDocument();
int endOffsetLogicalLine = document.getLineNumber(foldRegion.getEndOffset());
if (position.logicalLine != endOffsetLogicalLine) {
// Multi-line fold region.
position.softWrapColumnDiff = 0;
position.softWrapLinesBefore += position.softWrapLinesCurrent;
position.softWrapLinesCurrent = 0;
}
int collapsedSymbolsWidthInColumns = -1;
FoldingData foldingData = getFoldRegionData(foldRegion);
if (foldingData != null) {
collapsedSymbolsWidthInColumns = foldingData.getCollapsedSymbolsWidthInColumns();
}
position.advance(foldRegion, collapsedSymbolsWidthInColumns);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AbstractMappingStrategy.java
示例9: getFoldingData
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
@Nullable
public FoldingData getFoldingData(@NotNull final FoldRegion region) {
FoldingData candidate = myFoldingData.get(region.getStartOffset());
if (candidate != null) {
return candidate;
}
// Folding implementation is known to postpone actual fold region offsets update on document change, i.e. it performs
// fold data caching with its further replace by up-to-date info. Hence, there is a possible case that soft wraps processing
// advances fold region offset but folding model still provides old cached values. Hence, we're trying to match exact given
// fold region against the cached data here.
final Ref<FoldingData> result = new Ref<FoldingData>();
myFoldingData.forEachValue(new TObjectProcedure<FoldingData>() {
@Override
public boolean execute(FoldingData data) {
if (data.getFoldRegion().equals(region)) {
result.set(data);
return false;
}
return true;
}
});
return result.get();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CacheEntry.java
示例10: advance
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
@Override
public void advance(int sortingKey) {
// We inline binary search here because profiling indicates that as a performance boost.
int start = myIndex;
int end = myFoldRegions.length - 1;
// We inline binary search here because profiling indicates that it becomes bottleneck to use Collections.binarySearch().
while (start <= end) {
int i = (end + start) >>> 1;
FoldRegion foldRegion = myFoldRegions[i];
if (foldRegion.getStartOffset() < sortingKey) {
start = i + 1;
continue;
}
if (foldRegion.getStartOffset() > sortingKey) {
end = i - 1;
continue;
}
myIndex = i;
scrollToInterested();
return;
}
myIndex = start;
scrollToInterested();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:FoldingDataProvider.java
示例11: processFoldRegion
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
@Override
public Integer processFoldRegion(@NotNull EditorPosition position, @NotNull FoldRegion foldRegion) {
int startLine = position.logicalLine;
int startColumn = position.logicalColumn;
int startX = position.x;
advancePositionOnFolding(position, foldRegion);
if (position.logicalLine < targetPosition.line
|| position.logicalLine == targetPosition.line && position.logicalColumn <= targetPosition.column) {
return null;
}
Document document = myEditor.getDocument();
int lineEndOffset = document.getLineEndOffset(targetPosition.line);
int result = SoftWrapModelImpl.getEditorTextRepresentationHelper(myEditor)
.calcSoftWrapUnawareOffset(targetPosition.line == startLine ? foldRegion.getStartOffset()
: document.getLineStartOffset(targetPosition.line),
lineEndOffset,
targetPosition.line == startLine ? startColumn : 0,
targetPosition.column,
targetPosition.line == startLine ? startX : 0);
return result < 0 ? lineEndOffset : result;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:LogicalToOffsetCalculationStrategy.java
示例12: tryAdding
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
private static void tryAdding(Map<Integer, DisplayedFoldingAnchor> resultsMap,
FoldRegion region,
int visualLine,
int visualHeight,
DisplayedFoldingAnchor.Type type,
FoldRegion activeRegion) {
DisplayedFoldingAnchor prev = resultsMap.get(visualLine);
if (prev != null) {
if (prev.foldRegion == activeRegion) {
return;
}
if (region != activeRegion && prev.foldRegionVisualLines < visualHeight) {
return;
}
}
resultsMap.put(visualLine, new DisplayedFoldingAnchor(region, visualLine, visualHeight, type));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:FoldingAnchorsOverlayStrategy.java
示例13: testOccurrenceInCollapsedRegion
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
public void testOccurrenceInCollapsedRegion() throws Exception {
init("normal <selection><caret>line</selection>\n" +
"collapsed line");
final FoldingModel foldingModel = myFixture.getEditor().getFoldingModel();
final Document document = myFixture.getEditor().getDocument();
foldingModel.runBatchFoldingOperation(new Runnable() {
@Override
public void run() {
FoldRegion foldRegion = foldingModel.addFoldRegion(document.getLineStartOffset(1), document.getLineEndOffset(1), "...");
assertNotNull(foldRegion);
foldRegion.setExpanded(false);
}
});
executeAction();
checkResult("normal <selection><caret>line</selection>\n" +
"collapsed <selection><caret>line</selection>");
FoldRegion[] foldRegions = foldingModel.getAllFoldRegions();
assertEquals(1, foldRegions.length);
assertTrue(foldRegions[0].isExpanded());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:SelectUnselectOccurrenceActionsTest.java
示例14: testPrevNextWordWithFolding
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
public void testPrevNextWordWithFolding() {
myFixture.configureByText("a.txt", "<caret>brown fox");
EditorTestUtil.addFoldRegion(myFixture.getEditor(), 4, 7, "...", true);
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD);
myFixture.checkResult("brow<caret>n fox");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD);
myFixture.checkResult("brown f<caret>ox");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD);
myFixture.checkResult("brown fox<caret>");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD);
myFixture.checkResult("brown f<caret>ox");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD);
myFixture.checkResult("brow<caret>n fox");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD);
myFixture.checkResult("<caret>brown fox");
FoldRegion[] foldRegions = myFixture.getEditor().getFoldingModel().getAllFoldRegions();
assertEquals(1, foldRegions.length);
assertFalse(foldRegions[0].isExpanded());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:NextPrevWordTest.java
示例15: testPrevNextWordWithSelectionAndFolding
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
public void testPrevNextWordWithSelectionAndFolding() {
myFixture.configureByText("a.txt", "<caret>brown fox");
EditorTestUtil.addFoldRegion(myFixture.getEditor(), 4, 7, "...", true);
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD_WITH_SELECTION);
myFixture.checkResult("<selection>brow<caret></selection>n fox");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD_WITH_SELECTION);
myFixture.checkResult("<selection>brown f<caret></selection>ox");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD_WITH_SELECTION);
myFixture.checkResult("<selection>brown fox<caret></selection>");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION);
myFixture.checkResult("<selection>brown f<caret></selection>ox");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION);
myFixture.checkResult("<selection>brow<caret></selection>n fox");
myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION);
myFixture.checkResult("<caret>brown fox");
FoldRegion[] foldRegions = myFixture.getEditor().getFoldingModel().getAllFoldRegions();
assertEquals(1, foldRegions.length);
assertFalse(foldRegions[0].isExpanded());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:NextPrevWordTest.java
示例16: verifyAnchors
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
private void verifyAnchors(FoldRegion activeFoldRegion, Object... expectedAnchorParameters) {
Collection<DisplayedFoldingAnchor> actualAnchors = new FoldingAnchorsOverlayStrategy((EditorImpl)myFixture.getEditor())
.getAnchorsToDisplay(0, myFixture.getEditor().getDocument().getTextLength(), activeFoldRegion);
List<DisplayedFoldingAnchor> sortedActualAnchors = new ArrayList<DisplayedFoldingAnchor>(actualAnchors);
Collections.sort(sortedActualAnchors, new Comparator<DisplayedFoldingAnchor>() {
@Override
public int compare(DisplayedFoldingAnchor o1, DisplayedFoldingAnchor o2) {
return o1.visualLine - o2.visualLine;
}
});
assertEquals("Wrong number of anchors", expectedAnchorParameters.length / 2, sortedActualAnchors.size());
int i = 0;
for (DisplayedFoldingAnchor anchor : sortedActualAnchors) {
int expectedVisualLine = (Integer) expectedAnchorParameters[i++];
assertEquals("Folding anchor at wrong line found", expectedVisualLine, anchor.visualLine);
Type expectedType = (Type)expectedAnchorParameters[i++];
assertEquals("Folding anchor of wrong type found at line " + expectedVisualLine, expectedType, anchor.type);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:FoldingAnchorsOverlayStrategyTest.java
示例17: doTest
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
protected void doTest(@NotNull String text, @NotNull String ext) {
myFixture.configureByText("test." + ext, text);
CodeFoldingManager.getInstance(getProject()).buildInitialFoldings(myFixture.getEditor());
EditorFoldingInfo info = EditorFoldingInfo.get(myFixture.getEditor());
FoldRegion[] foldRegions = myFixture.getEditor().getFoldingModel().getAllFoldRegions();
assertTrue(foldRegions.length > 0);
for (FoldRegion region : foldRegions) {
PsiElement element = info.getPsiElement(region);
if (element == null) {
continue;
}
String signature = FoldingPolicy.getSignature(element);
assertNotNull(signature);
assertEquals(element, FoldingPolicy.restoreBySignature(element.getContainingFile(), signature));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AbstractFoldingPolicyTest.java
示例18: testFoldTreeIterator
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
public void testFoldTreeIterator() {
configureFromFileText(getTestName(false) + ".txt",
"abcdefghijklmnopqrstuvwxyz");
EditorTestUtil.addFoldRegion(myEditor, 0, 10, ".", true);
EditorTestUtil.addFoldRegion(myEditor, 0, 5, ".", false);
EditorTestUtil.addFoldRegion(myEditor, 1, 2, ".", true);
EditorTestUtil.addFoldRegion(myEditor, 7, 10, ".", false);
EditorTestUtil.addFoldRegion(myEditor, 10, 11, ".", true);
StringBuilder b = new StringBuilder();
Iterator<FoldRegion> it = FoldingUtil.createFoldTreeIterator(myEditor);
while (it.hasNext()) {
FoldRegion region = it.next();
if (b.length() > 0) {
b.append('|');
}
b.append(region.getStartOffset()).append(',').append(region.getEndOffset());
}
assertEquals("0,10|0,5|1,2|7,10|10,11", b.toString());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FoldingUtilTest.java
示例19: collectTransferableData
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
@NotNull
@Override
public List<FoldingTransferableData> collectTransferableData(final PsiFile file, final Editor editor, final int[] startOffsets, final int[] endOffsets) {
// might be slow
//CodeFoldingManager.getInstance(file.getManager().getProject()).updateFoldRegions(editor);
final ArrayList<FoldingData> list = new ArrayList<FoldingData>();
final FoldRegion[] regions = editor.getFoldingModel().getAllFoldRegions();
for (final FoldRegion region : regions) {
if (!region.isValid()) continue;
for (int j = 0; j < startOffsets.length; j++) {
if (startOffsets[j] <= region.getStartOffset() && region.getEndOffset() <= endOffsets[j]) {
list.add(
new FoldingData(
region.getStartOffset() - startOffsets[j],
region.getEndOffset() - startOffsets[j],
region.isExpanded()
)
);
}
}
}
return Collections.singletonList(new FoldingTransferableData(list.toArray(new FoldingData[list.size()])));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:CopyPasteFoldingProcessor.java
示例20: run
import com.intellij.openapi.editor.FoldRegion; //导入依赖的package包/类
@Override
public void run() {
EditorFoldingInfo info = EditorFoldingInfo.get(myEditor);
FoldingModelEx foldingModel = (FoldingModelEx)myEditor.getFoldingModel();
Map<TextRange,Boolean> rangeToExpandStatusMap = newTroveMap();
// FoldingUpdate caches instances of our object, so they must be immutable.
FoldingUpdate.FoldingMap elementsToFold = new FoldingUpdate.FoldingMap(myElementsToFoldMap);
removeInvalidRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap);
Map<FoldRegion, Boolean> shouldExpand = newTroveMap();
Map<FoldingGroup, Boolean> groupExpand = newTroveMap();
List<FoldRegion> newRegions = addNewRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap, shouldExpand, groupExpand);
applyExpandStatus(newRegions, shouldExpand, groupExpand);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:UpdateFoldRegionsOperation.java
注:本文中的com.intellij.openapi.editor.FoldRegion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论