diff --git a/rules/src/main/scala/fix/DirectoryAndPackageName.scala b/rules/src/main/scala/fix/DirectoryAndPackageName.scala index 11981e3..70b6c62 100644 --- a/rules/src/main/scala/fix/DirectoryAndPackageName.scala +++ b/rules/src/main/scala/fix/DirectoryAndPackageName.scala @@ -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 @@ -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 =>