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

Added go-to-definition feature to weidu .d files #74

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

Conversation

podcherklife
Copy link

This PR adds limited go-to-defintion feature for weidu .d files.

Definitions are collected only from open files.
Go-to-definition works only for GOTO and EXTERN weidu commands.

Notes regarding implementation:

Holding clrl causes file to be re-parsed on every cursor move. I did not notice any visible impact on performance even for large files, but you mileage may vary.

I got a bit confused about how to implement a language-specific symbol lookup, and went the most direct way. Suggestions on how to properly improve that are welcome.

Files in src/dparser/* were generated from this grammar: https://gitlab.com/lapdu/lapdu-parser/-/tree/master/src/main/antlr4/imports
They can be generated by build script instead, but that would require java dependency during build which might be undesirable.

@burner1024
Copy link
Member

burner1024 commented Aug 1, 2024

That's cool.
I've been meaning to get to ANTLR4 next, in particular as the road to autoformatting.

Language-specific features I prefer to put into corresponding weidu.ts or fallout.ts files. Or, failing that, route through Galactus

// the only language with external headers dir
if (l.id == "fallout-ssl") {
language = new Language(

But there's been no need for language-specific lookup. I guess you can pass langId to symbolAtPosition and handle the switch there, in common.ts
Doesn't current symbolAtPosition return correct symbol, though?

They can be generated by build script instead, but that would require java dependency during build which might be undesirable.

Yes, will need the generation script. Not necessarily at build time, but need to have a way to regenerate this automatically.
See https://github.com/BGforgeNet/VScode-BGforge-MLS/blob/master/scripts/ie-update.sh for an example. I just checkout upstream repos into ./external and pull data. Kind of horrible, but better than nothing, upstreams don't change often.

Also seems ESlint is plenty angry.

@burner1024 burner1024 changed the title Added go-to-defintion feature to weidu .d files Added go-to-definition feature to weidu .d files Aug 1, 2024
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.

2 participants