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

Pick Kotlin stdlib based on compiled Kotlin version #398

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

Conversation

omar25h
Copy link

@omar25h omar25h commented Oct 1, 2022

  • Ignore path when comparing versions
  • Pick the local Kotlin stdlib version based on the compiled version. This prevents potential issues in case there are multiple Kotlin versions used on the same machine.

- Ignore path when comparing versions
- Pick the local Kotlin stdlib version based on the compiled version.
  This prevents potential issues in case there are multiple Kotlin
  versions used on the same machine.
@omar25h omar25h force-pushed the omar25h/enhance-stdlib-detection branch from abca91b to 46f0db4 Compare October 1, 2022 11:49
@@ -116,6 +106,6 @@ private fun compareVersions(left: Path, right: Path): Int {
return -leftVersion.size.compareTo(rightVersion.size)
}
private fun extractVersion(artifactVersionDir: Path): List<String> {
return artifactVersionDir.toString().split(".")
return artifactVersionDir.toString().split("/").last().split(".")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return artifactVersionDir.toString().split("/").last().split(".")
return artifactVersionDir.fileName.toString().split(".")

}
else -> name.startsWith(artifact) && name.endsWith(".jar")
}
name == "$artifact-${KotlinVersion.CURRENT}.jar"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses the language server's version of Kotlin, right? This might go wrong if the user has a different version of Kotlin installed than what the language server uses.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. However, I think we need a better way to figure out the Kotlin version in the project on which the LSP runs, maybe via extracting the version from the Gradle configuration, if possible.
The current implementation uses the first version it finds, which also doesn't necessarily match the Kotlin version used in the project.

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.

None yet

2 participants