This repository has been archived by the owner on Jul 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
[Scala 3] Add support for given imports #187
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
rules = [OrganizeImports] | ||
OrganizeImports { | ||
groupedImports = Keep | ||
coalesceToWildcardImportThreshold = 2 | ||
removeUnused = false | ||
} | ||
*/ | ||
package fix | ||
|
||
import fix.GivenImports.{Alpha, Beta, Zeta} | ||
import fix.GivenImports.{given Alpha, given Beta, given Zeta} | ||
|
||
object CoalesceGivenImportees |
13 changes: 13 additions & 0 deletions
13
input/src/main/scala-3/fix/DeduplicateGivenImportees.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
rules = [OrganizeImports] | ||
OrganizeImports.removeUnused = false | ||
*/ | ||
package fix | ||
|
||
import fix.GivenImports._ | ||
import fix.GivenImports.{given Beta, given Alpha} | ||
import fix.GivenImports.given Beta | ||
import fix.GivenImports.given Alpha | ||
import fix.GivenImports.given Alpha | ||
|
||
object DeduplicateGivenImportees |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
rules = [OrganizeImports] | ||
OrganizeImports.removeUnused = false | ||
*/ | ||
package fix | ||
|
||
import fix.GivenImports.Beta | ||
import fix.GivenImports.Alpha | ||
import fix.GivenImports.{given Beta, given Alpha} | ||
import scala.util.Either | ||
|
||
object ExpandGiven |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
rules = [OrganizeImports] | ||
OrganizeImports.removeUnused = false | ||
*/ | ||
package fix | ||
|
||
import fix.GivenImports.Beta | ||
import fix.GivenImports.Alpha | ||
import fix.GivenImports.{given Alpha} | ||
import fix.GivenImports.{alpha => _} | ||
import fix.GivenImports.{beta => _, given} | ||
import scala.util.Either | ||
|
||
object ExpandUnimportGiven |
19 changes: 19 additions & 0 deletions
19
input/src/main/scala-3/fix/GroupedGivenImportsMergeUnimports.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
rules = [OrganizeImports] | ||
OrganizeImports.removeUnused = false | ||
OrganizeImports.groupedImports = Merge | ||
*/ | ||
package fix | ||
|
||
import fix.GivenImports._ | ||
import fix.GivenImports.{alpha => _, given} | ||
import fix.GivenImports.{ given Beta } | ||
import fix.GivenImports.{gamma => _, given} | ||
import fix.GivenImports.{ given Zeta } | ||
|
||
import fix.GivenImports2.{alpha => _} | ||
import fix.GivenImports2.{beta => _} | ||
import fix.GivenImports2.{ given Gamma } | ||
import fix.GivenImports2.{ given Zeta } | ||
|
||
object GroupedGivenImportsMergeUnimports |
23 changes: 23 additions & 0 deletions
23
input/src/main/scala-3/fix/GroupedImportsAggressiveMergeGivenAll.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
rules = [OrganizeImports] | ||
OrganizeImports.removeUnused = false | ||
OrganizeImports.groupedImports = AggressiveMerge | ||
*/ | ||
package fix | ||
|
||
import fix.MergeImports.Wildcard1._ | ||
import fix.MergeImports.Wildcard1.{a => _, _} | ||
import fix.MergeImports.Wildcard1.{b => B} | ||
import fix.MergeImports.Wildcard1.{c => _, _} | ||
import fix.MergeImports.Wildcard1.d | ||
|
||
import fix.GivenImports._ | ||
import fix.GivenImports.{Alpha, Beta, Zeta} | ||
import fix.GivenImports.{given Alpha, given Beta, given Zeta} | ||
import fix.GivenImports.given | ||
|
||
import fix.MergeImports.Wildcard2._ | ||
import fix.MergeImports.Wildcard2.{a, b} | ||
|
||
|
||
object GroupedImportsAggressiveMergeGivenAll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
rules = [OrganizeImports] | ||
OrganizeImports.removeUnused = false | ||
OrganizeImports.groupedImports = Merge | ||
*/ | ||
package fix | ||
|
||
import fix.GivenImports.Beta | ||
import fix.GivenImports.Alpha | ||
import fix.GivenImports.{given Beta} | ||
import fix.GivenImports.{given Alpha} | ||
import scala.util.Either | ||
|
||
object MergeGiven |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package fix | ||
|
||
import fix.GivenImports._ | ||
import fix.GivenImports.given | ||
|
||
object CoalesceGivenImportees |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package fix | ||
|
||
import fix.GivenImports._ | ||
import fix.GivenImports.{ given Alpha } | ||
import fix.GivenImports.{ given Beta } | ||
|
||
object DeduplicateGivenImportees |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package fix | ||
|
||
import fix.GivenImports.Alpha | ||
import fix.GivenImports.Beta | ||
import fix.GivenImports.{ given Alpha } | ||
import fix.GivenImports.{ given Beta } | ||
|
||
import scala.util.Either | ||
|
||
object ExpandGiven |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package fix | ||
|
||
import fix.GivenImports.Alpha | ||
import fix.GivenImports.Beta | ||
import fix.GivenImports.{given Alpha} | ||
import fix.GivenImports.{alpha => _} | ||
import fix.GivenImports.{beta => _, given} | ||
|
||
import scala.util.Either | ||
|
||
object ExpandUnimportGiven |
8 changes: 8 additions & 0 deletions
8
output/src/main/scala-3/fix/GroupedGivenImportsMergeUnimports.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fix | ||
|
||
import fix.GivenImports._ | ||
import fix.GivenImports.{gamma => _, given Beta, given Zeta, given} | ||
import fix.GivenImports2.{alpha => _, beta => _} | ||
import fix.GivenImports2.{given Gamma, given Zeta} | ||
|
||
object GroupedGivenImportsMergeUnimports |
10 changes: 10 additions & 0 deletions
10
output/src/main/scala-3/fix/GroupedImportsAggressiveMergeGivenAll.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package fix | ||
|
||
import fix.GivenImports._ | ||
import fix.GivenImports.given | ||
import fix.MergeImports.Wildcard1._ | ||
import fix.MergeImports.Wildcard1.{b => B} | ||
import fix.MergeImports.Wildcard2._ | ||
|
||
|
||
object GroupedImportsAggressiveMergeGivenAll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fix | ||
|
||
import fix.GivenImports.{Alpha, Beta} | ||
import fix.GivenImports.{given Alpha, given Beta} | ||
|
||
import scala.util.Either | ||
|
||
object MergeGiven |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you can see the imports are separated into givens and normal ones aside from the situation, where the unimports were together with given imports. Not sure if we can do better. Maybe we could check if the the types of the givens are not imported in the previous imports and join them in that case?