Skip to content

Commit 853872d

Browse files
committed
Extract method
1 parent b88b97b commit 853872d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/com/goide/editor/GoFoldingBuilder.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@ public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull D
6363
}
6464

6565
for (GoFunctionOrMethodDeclaration method : ContainerUtil.concat(file.getMethods(), file.getFunctions())) {
66-
GoBlock block = method.getBlock();
67-
if (block != null && block.getTextRange().getLength() > 1) result.add(new FoldingDescriptor(block, block.getTextRange()));
66+
foldBlock(result, method.getBlock());
6867
}
6968

7069
for (GoFunctionLit function : PsiTreeUtil.findChildrenOfType(file, GoFunctionLit.class)) {
71-
GoBlock block = function.getBlock();
72-
if (block != null && block.getTextRange().getLength() > 1) result.add(new FoldingDescriptor(block, block.getTextRange()));
70+
foldBlock(result, function.getBlock());
7371
}
7472

7573
for (GoTypeSpec type : file.getTypes()) {
@@ -96,6 +94,10 @@ public boolean execute(@NotNull PsiElement element) {
9694
return result.toArray(new FoldingDescriptor[result.size()]);
9795
}
9896

97+
private static void foldBlock(@NotNull List<FoldingDescriptor> result, @Nullable GoBlock block) {
98+
if (block != null && block.getTextRange().getLength() > 1) result.add(new FoldingDescriptor(block, block.getTextRange()));
99+
}
100+
99101
private static void foldTypes(@Nullable PsiElement element, List<FoldingDescriptor> result) {
100102
if (element instanceof GoStructType) {
101103
addTypeBlock(element, ((GoStructType)element).getLbrace(), ((GoStructType)element).getRbrace(), result);

0 commit comments

Comments
 (0)