Skip to content

Commit

Permalink
windows
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Dec 28, 2023
1 parent 8cc8ea7 commit 31f6cfd
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions rules/src/main/scala/fix/DirectoryAndPackageName.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import scalafix.v1.Configuration
import scalafix.v1.Rule
import scalafix.v1.SyntacticDocument
import scalafix.v1.SyntacticRule
import java.io.File
import java.util.Locale
import scala.meta.Pkg
import scala.meta.Term
Expand Down Expand Up @@ -133,18 +134,25 @@ class DirectoryAndPackageName(config: DirectoryAndPackageNameConfig) extends Syn
x
}.headOption

val scalaSourceOpt = PartialFunction.condOpt(doc.input) {
case f: Input.VirtualFile =>
f.path
case f: Input.File =>
f.path.toString
}
val scalaSourceOpt = PartialFunction
.condOpt(doc.input) {
case f: Input.VirtualFile =>
f.path
case f: Input.File =>
f.path.toString
}
.map { path =>
File.separatorChar match {
case '/' =>
path
case c =>
path.replace(c, '/')
}
}

{
for {
path <- scalaSourceOpt
// TODO Windows
if !scala.util.Properties.isWin
dirOpt = config.baseDirectory.find { dir =>
path.contains(dir)
}.map { dir =>
Expand Down

0 comments on commit 31f6cfd

Please sign in to comment.