Range Plugin: Add support for comments
- closes #3005
This PR is supposed to add support for comments in the range plugin as they are not supported in HieAST, which the plugin is based upon. It uses Annotated ParsedSource to fetch comments and add them to the code range.
Status
I am currently trying to figure out how to get the comments out of the Annotated ParsedSource. I am currently trying to figure this out through Exact Print, but I am still not sure, Can someone please help?
cc: @kokobd @michaelpj
How can I help? Feel free to contact me on IRC or Matrix if you have any questions. Meanwhile, I recommend adding folding range firstly, as it might be significantly easier than this.
If you want help with the 9.2.1+ exactprint API, I can help. I haven't used the comments part of the AST yet myself, but the type of interest is https://hackage.haskell.org/package/ghc-9.4.2/docs/GHC-Parser-Annotation.html#t:EpaComment
I tried to reserve comments while implementing hls-gadt-plugin, but it failed in some way I don't know. The comments seems can be attached to any semantic tokens.
I just complain it here, please let me know if you found a way to tidy comments, it will be a big improvement for hls-gadt-plugin.
if you found a way to tidy comments, it will be a big improvement for hls-gadt-plugin.
Have you tried using the balanceComments operation from ghc-exactprint? It can balance comments between two declarations. See the following talk:
https://youtu.be/GkoQbJofm1A?t=767
Have you tried using the balanceComments operation from ghc-exactprint? It can balance comments between two declarations. See the following talk:
Don't remember the detail clearly, but it is worth trying next time :)