Skip to content

Commit

Permalink
Absolute: use .path instead of .jfile.toPath
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 7, 2021
1 parent 309e9c4 commit ba58012
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ object InputMethod {
file.writeFile(text)(options.encoding)

override protected def list(options: CliOptions): Unit = {
val cwd = options.common.workingDirectory.jfile
options.common.out.println(cwd.toURI().relativize(file.jfile.toURI()))
val cwd = options.common.workingDirectory.path
options.common.out.println(cwd.relativize(file.path))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object ScalafmtDynamicRunner extends ScalafmtRunner {
}

def sessionMatcher(x: AbsoluteFile): Boolean =
session.matchesProjectFilters(x.jfile.toPath)
session.matchesProjectFilters(x.path)
val filterMatcher: AbsoluteFile => Boolean =
options.customFilesOpt.fold(sessionMatcher _) { customFiles =>
val customMatcher = getFileMatcher(customFiles)
Expand Down Expand Up @@ -85,8 +85,7 @@ object ScalafmtDynamicRunner extends ScalafmtRunner {
if (opts.respectProjectFilters) Seq.empty
else
opts.customFilesOpt.getOrElse(Seq.empty).flatMap { x =>
val file = x.jfile
if (file.isFile) Some(file.toPath) else None
if (x.isRegularFile) Some(x.path) else None
}
override def format(file: Path, code: String): String = {
// DESNOTE(2017-05-19, pjrt): A plain, fully passed file will (try to) be
Expand Down Expand Up @@ -119,7 +118,7 @@ object ScalafmtDynamicRunner extends ScalafmtRunner {
paths: Seq[AbsoluteFile]
): AbsoluteFile => Boolean = {
require(paths.nonEmpty)
val (files, dirs) = paths.partition(_.jfile.isFile)
val (files, dirs) = paths.partition(_.isRegularFile)
(x: AbsoluteFile) =>
files.contains(x) || {
val filename = x.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ object ProjectFiles {
def matches(filename: String): Boolean =
matchesPath(fs.getPath(filename))
def matchesFile(file: AbsoluteFile): Boolean =
matchesPath(file.jfile.toPath)
matchesPath(file.path)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ class GitOpsTest extends FunSuite {
File.createTempFile(name, ".ext", dir.orElse(ops.rootDir).get.jfile)
linkFile.delete()
val link = AbsoluteFile.fromPath(linkFile.toString).get
Files.createSymbolicLink(linkFile.toPath, file.jfile.toPath)
Files.createSymbolicLink(link.path, file.path)
link
}

def mv(f: AbsoluteFile, dir: Option[AbsoluteFile] = None): AbsoluteFile = {
val destDir = Files.createTempDirectory(
dir.orElse(ops.rootDir).get.jfile.toPath,
dir.orElse(ops.rootDir).get.path,
"dir_"
)
val dest = Files.move(
f.jfile.toPath,
f.path,
destDir,
java.nio.file.StandardCopyOption.REPLACE_EXISTING
)
Expand Down

0 comments on commit ba58012

Please sign in to comment.