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

Feature - disable extension on per-file basis to mitigate Unresolved reference: errors #567

Open
spaceunifyfifty opened this issue Mar 13, 2024 · 3 comments

Comments

@spaceunifyfifty
Copy link

spaceunifyfifty commented Mar 13, 2024

From my research it looks that the extension still does not support code from third party dependencies like JUnit or KMP. Examples #487, #101 The code successfully compiles and executes, but I have VSCode visually alerting me with red errors everywhere. I want to tell the extension to ignore certain files or sets of files where libraries are imported and used. I can tolerate not having autocompletion and hints in a few minority sections of my codebase while getting to benefit from the extension in the vanilla kotlin majority of cases. But currently it looks like my only options are to totally remove your extension and have no ide support for the language or use your extension but be limited from using any libraries if I don't want red squiggles everywhere.

@fwcd
Copy link
Owner

fwcd commented Mar 13, 2024

From my research it looks that the extension still does not support code from third party dependencies like JUnit or KMP.

It should support that, but only if your project follows a standard Maven/Gradle layout. If it does not, you could create a kls-classpath script to tell it where to find the corresponding JARs.

But currently it looks like my only options are to totally remove your extension and have no ide support for the language or use your extension but be limited from using any libraries if I don't want red squiggles everywhere.

If you "just" want to disable errors (and still get code completion etc.), you can also set "kotlin.diagnostics.enabled": false, but that will disable them everywhere. This is a more of a feature of last resort to make the language support somewhat usable even if the language server cannot resolve all dependencies correctly.

Ignoring specific files is still to be implemented, it has come up every now and then (see e.g. the discussion in #560).

@spaceunifyfifty
Copy link
Author

I looked at the classpath example, and I'm not really sure what it would look like for example, a project that uses the ktor library? Where is that located?

@josephquesnel
Copy link

I just finally fixed my issue with the language server and it turned out the problem was resolved when i uninstalled java 23 and all my old unused jdk versions, installed 21 and 17. I had some bad path env and bad registry files because i was impatient. Once cleaned (read the logs to know what), it just worked with jvm21.

I also killed all java processes with the working reload.

I was using latest kotlin 2.0.21 and ktor 3.0.0 and latest java 23 with Gradle and just could not get auto completion for files beyond the main directory including all external libraries. Gradle was getting an error when syncing the config due to jvm 23 having an unsupported operation. I am sure i can redownload java 23 without worrying but not bothering till i really need it.

I used ktor to create the base package not gradle build init. Hope this helps someone. I was pulling hair for a day before figuring it out. It did not help that im new to java ecosystem.

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

3 participants