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

Testing OrganizeImports.targetDialect = Scala3 #1

Draft
wants to merge 1 commit into
base: OrganizeImports
Choose a base branch
from

Conversation

bjaglin
Copy link
Owner

@bjaglin bjaglin commented Jan 22, 2024

@bjaglin bjaglin changed the title Testing OrganizeImports DialectTarget=Scala3 Testing OrganizeImports DialectTarget = Scala3 Jan 22, 2024
@bjaglin bjaglin changed the title Testing OrganizeImports DialectTarget = Scala3 Testing OrganizeImports targetDialect = Scala3 Jan 22, 2024
@bjaglin bjaglin force-pushed the OrganizeImportsDialectTargetScala3 branch 2 times, most recently from 0e42fa0 to b5d4f35 Compare January 22, 2024 00:20
import dotty.tools.dotc.core.Phases.*
import dotty.tools.dotc.core.Phases.Phase
Copy link
Owner Author

@bjaglin bjaglin Jan 22, 2024

Choose a reason for hiding this comment

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

The order produced by the current public release of scalafix (.* after .Phase) comes from the fact that sorting was done using _ internally (Scala2 dialect). Indeed, .* & ._ are not on the same side of .P:

scala> Seq(".*","._",".a",".P",".{}"," ").sorted
val res4: Seq[String] = List(" ", .*, .P, ._, .a, .{})

I'd argue that it's better to keep alphanumerical tokens together (no matter their case), so that order of * is accidentally better.

Copy link
Owner Author

@bjaglin bjaglin Jan 22, 2024

Choose a reason for hiding this comment

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

The output of this PR on these specific lines is consistent with scalafmt, for all rewrite.imports.sort values, so having wildcards first seem to be the right thing to do.

version = 3.7.17
runner.dialect = Scala3

rewrite.rules = [Imports]
rewrite.imports.sort = ascii
rewrite.imports.groups = [
  [".*"]
]
version = 3.7.17
runner.dialect = Scala3

rewrite.rules = [Imports]
rewrite.imports.sort = original
rewrite.imports.groups = [
  [".*"]
]
version = 3.7.17
runner.dialect = Scala3

rewrite.rules = [Imports]
rewrite.imports.sort = scalastyle
rewrite.imports.groups = [
  [".*"]
]

@bjaglin bjaglin force-pushed the OrganizeImportsDialectTargetScala3 branch 2 times, most recently from 5aa2327 to dc15ceb Compare January 22, 2024 22:35
@bjaglin bjaglin changed the base branch from main to OrganizeImports January 22, 2024 22:37
@bjaglin bjaglin force-pushed the OrganizeImportsDialectTargetScala3 branch from dc15ceb to 563e4d2 Compare January 28, 2024 22:18
@bjaglin bjaglin force-pushed the OrganizeImportsDialectTargetScala3 branch from 563e4d2 to 0acbed9 Compare January 28, 2024 22:40
@bjaglin bjaglin changed the title Testing OrganizeImports targetDialect = Scala3 Testing OrganizeImports.targetDialect = Scala3 Jan 28, 2024
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.

1 participant