Skip to content
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

Range Plugin: Add support for comments #3054

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sloorush
Copy link
Contributor

@sloorush sloorush commented Jul 22, 2022

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

@sloorush sloorush changed the title save some progress: add basic setup for comments in range plugin Range Plugin: Add support for comments Jul 22, 2022
@kokobd
Copy link
Collaborator

kokobd commented Jul 22, 2022

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.

@santiweight
Copy link
Collaborator

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

@July541
Copy link
Collaborator

July541 commented Oct 11, 2022

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.

@santiweight
Copy link
Collaborator

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

@July541
Copy link
Collaborator

July541 commented Oct 16, 2022

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make code range work on comments
4 participants