Created
November 13, 2019 19:12
-
-
Save abeln/dc90d8a1aeeceb5638adbf5207e2c024 to your computer and use it in GitHub Desktop.
Migrate semanticdb to explicit nulls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/scala/dotty/semanticdb/SourceFile.scala b/src/main/scala/dotty/semanticdb/SourceFile.scala | |
index c53579b..34560bc 100644 | |
--- a/src/main/scala/dotty/semanticdb/SourceFile.scala | |
+++ b/src/main/scala/dotty/semanticdb/SourceFile.scala | |
@@ -68,4 +68,4 @@ class SourceFile(path: java.nio.file.Path) { | |
} | |
return previous | |
} | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/src/main/scala/dotty/semanticdb/Utils.scala b/src/main/scala/dotty/semanticdb/Utils.scala | |
index 0bb6fda..ba9e431 100644 | |
--- a/src/main/scala/dotty/semanticdb/Utils.scala | |
+++ b/src/main/scala/dotty/semanticdb/Utils.scala | |
@@ -28,7 +28,7 @@ object Utils { | |
/** List all tasty files occuring in the folder f or one of its subfolders */ | |
def recursiveListFiles(f: File, prefix : String = ""): Array[File] = { | |
val pattern = (".*" + prefix + ".*\\.tasty").r | |
- val files = f.listFiles | |
+ val files = f.listFiles.map(_.nn) | |
val folders = files.filter(_.isDirectory) | |
val tastyfiles = files.filter(_.toPath.toString match { | |
case pattern(x: _*) => true | |
@@ -78,4 +78,4 @@ object Utils { | |
val (_, classnames) = tastyClasses.unzip | |
return classnames | |
} | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/src/test/scala/dotty/semanticdb/MD5.scala b/src/test/scala/dotty/semanticdb/MD5.scala | |
index 4cd0f50..4b14a2e 100644 | |
--- a/src/test/scala/dotty/semanticdb/MD5.scala | |
+++ b/src/test/scala/dotty/semanticdb/MD5.scala | |
@@ -26,4 +26,4 @@ object MD5 { | |
} | |
new String(hexChars) | |
} | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/src/test/scala/dotty/semanticdb/Semanticdbs.scala b/src/test/scala/dotty/semanticdb/Semanticdbs.scala | |
index 7626732..3995d13 100644 | |
--- a/src/test/scala/dotty/semanticdb/Semanticdbs.scala | |
+++ b/src/test/scala/dotty/semanticdb/Semanticdbs.scala | |
@@ -18,7 +18,7 @@ object Semanticdbs { | |
*/ | |
class Loader(sourceroot: Path, classpath: List[Path]) { | |
private val META_INF = Paths.get("META-INF", "semanticdb").resolve(buildSubFolder) | |
- private val classLoader = new java.net.URLClassLoader(classpath.map(_.toUri.toURL).toArray) | |
+ private val classLoader = new java.net.URLClassLoader(classpath.map(_.toUri.toURL).toArray[java.net.URL | JavaNull]) | |
/** Returns a SemanticDB for a single Scala source file, if any. The path must be absolute. */ | |
def resolve(scalaAbsolutePath: Path): Option[s.TextDocument] = { | |
val scalaRelativePath = sourceroot.relativize(scalaAbsolutePath) | |
diff --git a/src/test/scala/dotty/semanticdb/Tests.scala b/src/test/scala/dotty/semanticdb/Tests.scala | |
index 3ccafea..651147f 100644 | |
--- a/src/test/scala/dotty/semanticdb/Tests.scala | |
+++ b/src/test/scala/dotty/semanticdb/Tests.scala | |
@@ -111,8 +111,8 @@ class Tests { | |
val scalaFolderReg = """scala-(\d+)\.(\d+)""".r | |
val (_, _, path) = files | |
.collect(file => | |
- file.getName match { | |
- case scalaFolderReg(major, minor) => (major, minor, file.getName) | |
+ file.nn.getName match { | |
+ case scalaFolderReg(major, minor) => (major, minor, file.nn.getName) | |
}) | |
.max | |
Paths.get(root, path, "test-classes") | |
@@ -156,7 +156,7 @@ class Tests { | |
def assertNoDiff(obtained: String, expected: String): Unit = { | |
if (obtained.isEmpty && !expected.isEmpty) fail("obtained empty output") | |
def splitLines(string: String): java.util.List[String] = | |
- string.trim.replace("\r\n", "\n").split("\n").toSeq.asJava | |
+ string.trim.replace("\r\n", "\n").split("\n").map(_.nn).toSeq.asJava | |
val obtainedLines = splitLines(obtained) | |
val b = splitLines(expected) | |
val patch = difflib.DiffUtils.diff(obtainedLines, b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment