Skip to content

Commit

Permalink
Fix issues handling source files with spaces in their path. (#979)
Browse files Browse the repository at this point in the history
Fix issues handling source files with spaces in their path.
  • Loading branch information
olafurpg authored Aug 16, 2019
2 parents 3353da5 + 141a340 commit 5730986
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sbt._
/* scalafmt: { maxColumn = 120 }*/

object Dependencies {
val scalametaV = "4.1.9"
val scalametaV = "4.2.1"
val metaconfigV = "0.9.1"
def dotty = "0.9.0-RC1"
def scala210 = "2.10.6"
Expand Down
10 changes: 0 additions & 10 deletions scalafix-core/src/main/scala/scalafix/internal/v1/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import scala.meta.io.RelativePath

package object v1 {

implicit class XtensionRelativePathScalafix(path: RelativePath) {
// TODO: replace with RelativePath.toURI once https://github.com/scalameta/scalameta/issues/1523 is fixed
def toRelativeURI: URI = {
val reluri = path.toNIO.asScala.iterator.map { path =>
new URI(null, null, path.getFileName.toString, null).toString
}
URI.create(reluri.mkString("/"))
}
}

implicit class XtensionTextDocumentFix(sdoc: s.TextDocument) {
def abspath(sourceroot: URI): AbsolutePath = {
val absuri = sourceroot.resolve(URI.create(sdoc.uri))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ object SemanticDocument {
classLoader: ClassLoader,
symtab: SymbolTable
): SemanticDocument = {
val semanticdbReluri = s"META-INF/semanticdb/$path.semanticdb"
Option(classLoader.getResourceAsStream(semanticdbReluri)) match {
val semanticdbRelPath = s"META-INF/semanticdb/$path.semanticdb"
Option(classLoader.getResourceAsStream(semanticdbRelPath)) match {
case Some(inputStream) =>
val sdocs =
try s.TextDocuments.parseFrom(inputStream).documents
finally inputStream.close()
val reluri = path.toRelativeURI.toString
val reluri = path.toURI(isDirectory = false).toString
val sdoc = sdocs.find(_.uri == reluri).getOrElse {
throw Error.MissingTextDocument(reluri)
}
val impl = new InternalSemanticDoc(doc, sdoc, symtab)
new SemanticDocument(impl)
case None =>
throw Error.MissingSemanticdb(semanticdbReluri)
throw Error.MissingSemanticdb(semanticdbRelPath)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class TestkitPath(
)
pprint.PPrinter.BlackWhite.tokenize(map).mkString
}
def testName: String = testPath.toRelativeURI.toString
def testName: String = testPath.toURI(isDirectory = false).toString
def toInput: Input =
Input.VirtualFile(testName, FileIO.slurp(input, StandardCharsets.UTF_8))
def resolveOutput(props: TestkitProperties): Either[String, AbsolutePath] = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
rules = []
*/
package test

object Object {
val x = 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

package test

object Object {
val x = 1
}

0 comments on commit 5730986

Please sign in to comment.