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

TypeScript declaration #132

Open
notEvil opened this issue Jan 10, 2023 · 3 comments
Open

TypeScript declaration #132

notEvil opened this issue Jan 10, 2023 · 3 comments

Comments

@notEvil
Copy link

notEvil commented Jan 10, 2023

Hi,

I've been using the web editor but find the documentation to be outdated and the lack of autocompletion makes it unnecessarily difficult to get started.

So I looked for an alternative and found TS declaration files. The following script reads the relevant Java files in this repository and creates declarations which in turn provide type inference and autocompletion.

https://gitlab.com/-/snippets/2482545

In Neovim with Ycm
Screenshot from 2023-01-10 17-37-38
Screenshot from 2023-01-10 17-38-21

This is merely a proof-of-concept, expect wrong/generic types, missing method arguments, class boundary violations (nested classes), ...
I'm not familiar with Java, so I won't go any further with this, but you should have no trouble adjusting your documentation export to produce something along these lines.

@notEvil
Copy link
Author

notEvil commented Jan 10, 2023

Nevermind, saw https://github.com/c2nes/javalang and couldn't resist: https://github.com/notEvil/PHONK/blob/ts_declarations/get_ts_declarations.py
Now I would consider this actually viable. It still assumes a lot and is far from perfect, but has a solid foundation.

For people not familiar with Python, the easiest way to run this is:
python -m pip install pipenv; python -m pipenv run pip install javalang; python -m pipenv run python ./get_ts_declarations.py .

@victordiaz
Copy link
Owner

Hi @notEvil this sounds really amazing! This for sure will help to update the old docs,
I will have to check how to integrate it in the ace editor that PHONK uses.

I'm a bit busy atm but I will try this and answer your other questions by the end of next week.
Thanks!

@notEvil
Copy link
Author

notEvil commented Jan 12, 2023

Great, no hurry! I now use sshfs and Neovim as shown above, and it works quite well.

Fyi I've changed the script a bit so it would export the documentation comments :)

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

No branches or pull requests

2 participants