Skip to content
Snippets Groups Projects
Commit 6c605dee authored by Johannes Mey's avatar Johannes Mey
Browse files

do not fold empty blocks

parent 221e6182
No related branches found
No related tags found
1 merge request!6Resolve "Folding Empty Aspects"
Pipeline #12022 passed
...@@ -24,34 +24,44 @@ public class AspectFoldingBuilder extends FoldingBuilderEx { ...@@ -24,34 +24,44 @@ public class AspectFoldingBuilder extends FoldingBuilderEx {
List<FoldingDescriptor> descriptors = new ArrayList<>(); List<FoldingDescriptor> descriptors = new ArrayList<>();
Collection<JastAddAspectAspectDeclaration> aspectDeclarations = PsiTreeUtil.findChildrenOfType(root, JastAddAspectAspectDeclaration.class); Collection<JastAddAspectAspectDeclaration> aspectDeclarations = PsiTreeUtil.findChildrenOfType(root, JastAddAspectAspectDeclaration.class);
for (final JastAddAspectAspectDeclaration aspectDeclaration : aspectDeclarations) { for (final JastAddAspectAspectDeclaration aspectDeclaration : aspectDeclarations) {
if (aspectDeclaration.getAspectBody().getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(aspectDeclaration.getNode(), descriptors.add(new FoldingDescriptor(aspectDeclaration.getNode(),
new TextRange(aspectDeclaration.getAspectBody().getTextRange().getStartOffset() + 1, new TextRange(aspectDeclaration.getAspectBody().getTextRange().getStartOffset() + 1,
aspectDeclaration.getAspectBody().getTextRange().getEndOffset() - 1))); aspectDeclaration.getAspectBody().getTextRange().getEndOffset() - 1)));
} }
}
Collection<JastAddAspectClassDeclaration> classDeclarations = PsiTreeUtil.findChildrenOfType(root, JastAddAspectClassDeclaration.class); Collection<JastAddAspectClassDeclaration> classDeclarations = PsiTreeUtil.findChildrenOfType(root, JastAddAspectClassDeclaration.class);
for (final JastAddAspectClassDeclaration classDeclaration : classDeclarations) { for (final JastAddAspectClassDeclaration classDeclaration : classDeclarations) {
if (classDeclaration.getClassBody().getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(classDeclaration.getNode(), descriptors.add(new FoldingDescriptor(classDeclaration.getNode(),
new TextRange(classDeclaration.getClassBody().getTextRange().getStartOffset() + 1, new TextRange(classDeclaration.getClassBody().getTextRange().getStartOffset() + 1,
classDeclaration.getClassBody().getTextRange().getEndOffset() - 1))); classDeclaration.getClassBody().getTextRange().getEndOffset() - 1)));
} }
}
Collection<JastAddAspectEnumBody> enumBodies = PsiTreeUtil.findChildrenOfType(root, JastAddAspectEnumBody.class); Collection<JastAddAspectEnumBody> enumBodies = PsiTreeUtil.findChildrenOfType(root, JastAddAspectEnumBody.class);
for (final JastAddAspectEnumBody enumBody : enumBodies) { for (final JastAddAspectEnumBody enumBody : enumBodies) {
if (enumBody.getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(enumBody.getNode(), descriptors.add(new FoldingDescriptor(enumBody.getNode(),
new TextRange(enumBody.getTextRange().getStartOffset() + 1, new TextRange(enumBody.getTextRange().getStartOffset() + 1,
enumBody.getTextRange().getEndOffset() - 1))); enumBody.getTextRange().getEndOffset() - 1)));
} }
}
Collection<JastAddAspectAnnotationTypeBody> annotationTypeBodies = PsiTreeUtil.findChildrenOfType(root, JastAddAspectAnnotationTypeBody.class); Collection<JastAddAspectAnnotationTypeBody> annotationTypeBodies = PsiTreeUtil.findChildrenOfType(root, JastAddAspectAnnotationTypeBody.class);
for (final JastAddAspectAnnotationTypeBody annotationTypeBody : annotationTypeBodies) { for (final JastAddAspectAnnotationTypeBody annotationTypeBody : annotationTypeBodies) {
if (annotationTypeBody.getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(annotationTypeBody.getNode(), descriptors.add(new FoldingDescriptor(annotationTypeBody.getNode(),
new TextRange(annotationTypeBody.getTextRange().getStartOffset() + 1, new TextRange(annotationTypeBody.getTextRange().getStartOffset() + 1,
annotationTypeBody.getTextRange().getEndOffset() - 1))); annotationTypeBody.getTextRange().getEndOffset() - 1)));
} }
}
Collection<JastAddAspectBlock> aspectBlocks = PsiTreeUtil.findChildrenOfType(root, JastAddAspectBlock.class); Collection<JastAddAspectBlock> aspectBlocks = PsiTreeUtil.findChildrenOfType(root, JastAddAspectBlock.class);
for (final JastAddAspectBlock block : aspectBlocks) { for (final JastAddAspectBlock block : aspectBlocks) {
if (block.getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(block.getNode(), descriptors.add(new FoldingDescriptor(block.getNode(),
new TextRange(block.getTextRange().getStartOffset() + 1, new TextRange(block.getTextRange().getStartOffset() + 1,
block.getTextRange().getEndOffset() - 1))); block.getTextRange().getEndOffset() - 1)));
} }
}
return descriptors.toArray(new FoldingDescriptor[0]); return descriptors.toArray(new FoldingDescriptor[0]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment