Skip to content
Snippets Groups Projects

Resolve "Folding Empty Aspects"

Merged Johannes Mey requested to merge bugfix/folding-empty-aspects into develop
1 file
+ 25
15
Compare changes
  • Side-by-side
  • Inline
@@ -24,33 +24,43 @@ public class AspectFoldingBuilder extends FoldingBuilderEx {
List<FoldingDescriptor> descriptors = new ArrayList<>();
Collection<JastAddAspectAspectDeclaration> aspectDeclarations = PsiTreeUtil.findChildrenOfType(root, JastAddAspectAspectDeclaration.class);
for (final JastAddAspectAspectDeclaration aspectDeclaration : aspectDeclarations) {
descriptors.add(new FoldingDescriptor(aspectDeclaration.getNode(),
new TextRange(aspectDeclaration.getAspectBody().getTextRange().getStartOffset() + 1,
aspectDeclaration.getAspectBody().getTextRange().getEndOffset() - 1)));
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) {
descriptors.add(new FoldingDescriptor(classDeclaration.getNode(),
new TextRange(classDeclaration.getClassBody().getTextRange().getStartOffset() + 1,
classDeclaration.getClassBody().getTextRange().getEndOffset() - 1)));
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) {
descriptors.add(new FoldingDescriptor(enumBody.getNode(),
new TextRange(enumBody.getTextRange().getStartOffset() + 1,
enumBody.getTextRange().getEndOffset() - 1)));
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) {
descriptors.add(new FoldingDescriptor(annotationTypeBody.getNode(),
new TextRange(annotationTypeBody.getTextRange().getStartOffset() + 1,
annotationTypeBody.getTextRange().getEndOffset() - 1)));
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) {
descriptors.add(new FoldingDescriptor(block.getNode(),
new TextRange(block.getTextRange().getStartOffset() + 1,
block.getTextRange().getEndOffset() - 1)));
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]);
}
Loading