-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add folding builder #92
base: master
Are you sure you want to change the base?
Conversation
this adds folding. makes it much easier to read large blocks of nix code. todo: * use customfoldingbuilder maybe?
# Conflicts: # src/main/resources/META-INF/plugin.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. Here is my review so far. I haven't tried whether it actually works, but it looks simple enough. Of course, tests would always be nice, but doesn't seem necessary in this case. Not sure if there is anything which could be tested reasonably, besides verifying that we don't throw any runtime exception.
} | ||
|
||
override fun visitFile(file: PsiFile) { | ||
super.visitFile(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question (non-blocking): Why are you calling the super-method here, and only here? The super method doesn't seem to do anything important.
} | ||
|
||
override fun visitExprIf(o: NixExprIf) { | ||
o.acceptChildren(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: You could override visitElement(PsiElement)
with o.acceptChildren(this)
. Then you can remove all the other methods that do nothing but delegating to the children.
There are also various method which only delegate to children using element-specific code. Like visitExprWith
, which just calls o.exprList.forEach { it.accept(this) }
. Is there a good reason for that? Otherwise, you could just remove them after overriding visitElement
.
return descriptors.toArray(FoldingDescriptor.EMPTY_ARRAY) | ||
} | ||
|
||
override fun getPlaceholderText(node: ASTNode): String? = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: Looks like you could provide the placeholder text and whether the region is collapsed by default to the constructor of FoldingDescriptor
. It looks like in this case, getPlaceholderText
and isCollapsedByDefault
could just throw an UnsupportedOperationException
or trigger an assertion.
What is the advantage? |
this adds folding. makes it much easier to read large blocks of nix code.
todo: