mlachkar on gh-pages
Deploy website Deploy website … (compare)
bjaglin on main
Update scalameta, semanticdb-sc… Merge pull request #1605 from s… (compare)
mlachkar on gh-pages
Deploy website Deploy website … (compare)
bjaglin on main
Update scalameta, semanticdb-sc… Merge pull request #1604 from s… (compare)
@/all Scalafix 0.9.27 is out, thanks to all contributors!
Highlights
RemoveUnused
to removes unused pattern matching variables with _
on Scala 2.12 and 2.13 scalafix commands
(scalacenter/sbt-scalafix#196) Full changelog
Hey guys! I have a question about organizing imports with scalafix OrganizeImports rules. Probably not the right place to ask (point me in the right direction please).
Is there any option to have imports organized the following way?
import org.apache.kafka.clients.consumer.{
ConsumerRebalanceListener,
OffsetCommitCallback,
Consumer => ConsumerJ,
ConsumerGroupMetadata => ConsumerGroupMetadataJ,
ConsumerRecords => ConsumerRecordsJ,
OffsetAndMetadata => OffsetAndMetadataJ,
OffsetAndTimestamp => OffsetAndTimestampJ
}
Current implementation just put them all on a single line like this
import org.apache.kafka.clients.consumer.{Consumer => ConsumerJ, ConsumerGroupMetadata => ConsumerGroupMetadataJ, ConsumerRebalanceListener, ConsumerRecords => ConsumerRecordsJ, OffsetAndMetadata => OffsetAndMetadataJ, OffsetAndTimestamp => OffsetAndTimestampJ, OffsetCommitCallback}
@Z1kkurat, thanks for reaching out. For liancheng/scala-organize-imports#43, the fix I made is to make sure that if an import statement is already organized according to the configuration, OrganizeImports
should preserve the original format (line breaks, spaces, etc.). As @olafurpg pointed out, Scalafix is not responsible (or capable in many cases) to emit well formatted code, and you'll need tools like Scalafmt for that.
The fix I made makes OrganizeImports
idempotent. For example, if you run Scalafix first to organize the imports, run Scalafmt to format the code, and then run Scalafix again, the 2nd Scalafix run should not reformat your code since your imports are already organized. Please refer to this section for more details.
In the case you reported, the original import statement is not organized yet (not sorted properly), so OrganizeImports
updated and reformatted it.
val patch = doc.tree.collect { case t: Template =>
val otherDefinition = t.stats.filterNot(_.isInstanceOf[Defn.Def])
val defDefinition = t.stats.collect({ case d: Defn.Def => d }).sortBy(_.name.value)
Patch.replaceTree(t, t.copy(stats = otherDefinition ++ defDefinition).syntax)
}
def
from the others and then sorting it.
Probably a dumb question, but how can I find type information for a reference?
E.g.
val r: zio.Runtime[Any] = ???
// Somewhere in the program
r.platform
I want to find SymbolInformation for r
but it's always None, and r could be defined anywhere so I need to somehow lookup it's type?
Hi, is there any know problem with scalafix 0.9.27 and scala 2.12.13? I'm getting a trace showing the tree, I suppose from semanticdb, when I have any compilation error:
TRANSFORM: null
TREE:
...
I've tried downgrading to scala 2.12.12 and it worked fine, and with scala 2.13.4 also works fine