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

Snippets should handle importing classes they reference #339

Open
datho7561 opened this issue Jan 10, 2023 · 2 comments
Open

Snippets should handle importing classes they reference #339

datho7561 opened this issue Jan 10, 2023 · 2 comments
Labels
enhancement New feature or request java-files Features supported in Java files snippets

Comments

@datho7561
Copy link
Contributor

It would be nice if applying a Java snippet imports all the classes that it references without requiring the user to organize imports.

Angelo discussed one method of doing this here: #338 (comment).

The idea is that once we implement handling cursor context, we could get the location of the end of the import list in the same request. Then, we could add an additional text edit in the language server that adds the necessary class import(s) to the Java file.

One limitation of this approach is that it doesn't handle the case where the classes are already imported. Also, the imports will not be ordered alphabetically. However, there might be ways to overcome some of these limitations.

@manan1979
Copy link

can i work on this issue?

@datho7561 datho7561 added enhancement New feature or request snippets java-files Features supported in Java files labels Mar 23, 2023
@datho7561
Copy link
Contributor Author

datho7561 commented Mar 23, 2023

If you are interested in working on this issue, go right ahead! Just as a fair warning, it might get complex. Feel free to ask questions, I will do my best to answer. I also have a work in progress branch for this that I can share. I'll link to it when I finish rebasing it. never mind, it didn't contain anything useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request java-files Features supported in Java files snippets
Projects
None yet
Development

No branches or pull requests

2 participants