-
Notifications
You must be signed in to change notification settings - Fork 39
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
Give access to the original ANTLR Parse Tree #15
Comments
The ANTLR plugin does something similar in ANTLRv4ExternalAnnotator. It retrieves the file contents, gives it to ANTLR, builds a list of issues and creates annotations based on a So you're right, you currently have to parse the file a second time. If you have existing walkers, I suppose the best option to reuse them is implement an I you don't have existing walkers, you can implement an |
Understand. As a feature suggestion I think it would be good to have the adaptor attach the ANTLR Parse Tree to the PsiFile. If I have time I will see if I can make the change. Thanks again. |
I'm converting this issue to an enhancement then, just to keep track of the feature :) |
Totally understand why we should use the PSI tree, for example, to get all the inbuilt features like renaming and so on. And the ANTLR like Xpath feature works well. In sum, no complaints.
However, I do have a number of ANTLR walkers (for example that do more fine grained work around identifier type safety and other analysis). I really can't be bothered to re-do for PSI trees (and also not sure how to make a walker in PSI - I guess I could learn!).
So I think I could quite easily pump the whole file through the ANTLR Lexer and Parser in an external annotator, and could get row and column numbers to sync, and hence add some warning annotations etc. Although I can't find an example of how to access the file's contents the virtual file system seems to be the answer.
So finally (!) the question is this - can I access either the actual ANTLR (not PSI) parse tree from an annotator, or perhaps the token stream? I obviously have looked but can't decide if there is a suitable extension point or not. For example somehow when the PSI tree is built.
I am thinking it is not possible at the moment and I need to reparse the file. Is this right?
The text was updated successfully, but these errors were encountered: