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 {
List<FoldingDescriptor> descriptors = new ArrayList<>();
Collection<JastAddAspectAspectDeclaration> aspectDeclarations = PsiTreeUtil.findChildrenOfType(root, JastAddAspectAspectDeclaration.class);
for (final JastAddAspectAspectDeclaration aspectDeclaration : aspectDeclarations) {
if (aspectDeclaration.getAspectBody().getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(aspectDeclaration.getNode(),
new TextRange(aspectDeclaration.getAspectBody().getTextRange().getStartOffset() + 1,
aspectDeclaration.getAspectBody().getTextRange().getEndOffset() - 1)));
}
}
Collection<JastAddAspectClassDeclaration> classDeclarations = PsiTreeUtil.findChildrenOfType(root, JastAddAspectClassDeclaration.class);
for (final JastAddAspectClassDeclaration classDeclaration : classDeclarations) {
if (classDeclaration.getClassBody().getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(classDeclaration.getNode(),
new TextRange(classDeclaration.getClassBody().getTextRange().getStartOffset() + 1,
classDeclaration.getClassBody().getTextRange().getEndOffset() - 1)));
}
}
Collection<JastAddAspectEnumBody> enumBodies = PsiTreeUtil.findChildrenOfType(root, JastAddAspectEnumBody.class);
for (final JastAddAspectEnumBody enumBody : enumBodies) {
if (enumBody.getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(enumBody.getNode(),
new TextRange(enumBody.getTextRange().getStartOffset() + 1,
enumBody.getTextRange().getEndOffset() - 1)));
}
}
Collection<JastAddAspectAnnotationTypeBody> annotationTypeBodies = PsiTreeUtil.findChildrenOfType(root, JastAddAspectAnnotationTypeBody.class);
for (final JastAddAspectAnnotationTypeBody annotationTypeBody : annotationTypeBodies) {
if (annotationTypeBody.getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(annotationTypeBody.getNode(),
new TextRange(annotationTypeBody.getTextRange().getStartOffset() + 1,
annotationTypeBody.getTextRange().getEndOffset() - 1)));
}
}
Collection<JastAddAspectBlock> aspectBlocks = PsiTreeUtil.findChildrenOfType(root, JastAddAspectBlock.class);
for (final JastAddAspectBlock block : aspectBlocks) {
if (block.getTextRange().getLength() > 2) {
descriptors.add(new FoldingDescriptor(block.getNode(),
new TextRange(block.getTextRange().getStartOffset() + 1,
block.getTextRange().getEndOffset() - 1)));
}
}
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