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

fix: Fix reversed version order in dep completions in scala 2 #5206

Merged
merged 4 commits into from Jun 16, 2023

Conversation

jkciesluk
Copy link
Member

In Scala 2 completions for dependencies where sorted in wrong order

@@ -34,6 +34,16 @@ trait ScalaCliCompletions {
dependency: String
) extends CompletionPosition {

override def compare(o1: Member, o2: Member): Int =
(o1, o2) match {
case (c1: TextEditMember, c2: TextEditMember) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to create DependencyMember and use SemVer class we have to compare?

Copy link
Contributor

Choose a reason for hiding this comment

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

What abou this? Did you manage to get this working?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added DependencyMember and reused it also in completions for sbt and mill (I've completely forgotten about them before).

Some libraries have versions in format like `2.5-<commit_hash>`. Now we can create Version for them.
This allows us to eg. sort them corretly in completions
@@ -132,6 +132,18 @@ class CompletionScalaCliSuite extends BaseCompletionSuite {
"circe-core_native0.4",
)

check(
"version-sort",
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember you talking about some problematic cases, maybe add those as a test too.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is alternative-sorting test, it will fail with exception if if can't create Version because of non-standard version syntax

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw. you could add unit tests isntead to cover a wider amount of cases and it will be easy to add tests there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we add unit tests after solving #5300? Right now we would have to change from double colon to single colon in tests, and I'm not sure if thats fine

@@ -132,6 +132,18 @@ class CompletionScalaCliSuite extends BaseCompletionSuite {
"circe-core_native0.4",
)

check(
"version-sort",
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw. you could add unit tests isntead to cover a wider amount of cases and it will be easy to add tests there.

@@ -34,6 +34,16 @@ trait ScalaCliCompletions {
dependency: String
) extends CompletionPosition {

override def compare(o1: Member, o2: Member): Int =
(o1, o2) match {
case (c1: TextEditMember, c2: TextEditMember) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

What abou this? Did you manage to get this working?

@jkciesluk jkciesluk requested a review from tgodzik June 16, 2023 10:43
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Some last changes!

Adds common class for all dependency completions
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM!

@jkciesluk jkciesluk merged commit e55d4df into scalameta:main Jun 16, 2023
22 of 23 checks passed
@jkciesluk jkciesluk deleted the dep-version-sort branch June 16, 2023 12:35
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

3 participants