diff --git a/build.sbt b/build.sbt index 2c6fa48c881..5665c14add7 100644 --- a/build.sbt +++ b/build.sbt @@ -172,6 +172,11 @@ lazy val interfaces = project ) ) +val genyVersion = Def.setting { + if (scalaVersion.value.startsWith("2.11")) "0.1.6" + else "0.1.8" +} + lazy val mtags = project .settings( moduleName := "mtags", @@ -189,6 +194,7 @@ lazy val mtags = project "com.thoughtworks.qdox" % "qdox" % "2.0-M9", // for java mtags "org.jsoup" % "jsoup" % "1.11.3", // for extracting HTML from javadocs "org.lz4" % "lz4-java" % "1.6.0", // for streaming hashing when indexing classpaths + "com.lihaoyi" %% "geny" % genyVersion.value, "org.scalameta" % "semanticdb-scalac-core" % V.scalameta cross CrossVersion.full ), libraryDependencies ++= { diff --git a/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala b/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala index 3eaf8df20ed..4b71e7ed3f4 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala @@ -2,8 +2,8 @@ package scala.meta.internal.builds import java.nio.file.Files import java.util.Properties -import scala.meta.internal.jdk.CollectionConverters._ import scala.meta.io.AbsolutePath +import scala.meta.internal.metals.MetalsEnrichments._ /** * Detects what build tool is used in this workspace. @@ -31,18 +31,7 @@ final class BuildTools( bspGlobalDirectories.exists(hasJsonFile) } private def hasJsonFile(dir: AbsolutePath): Boolean = { - dir.isDirectory && { - val ls = Files.list(dir.toNIO) - val hasJsonFile = - try { - ls.iterator() - .asScala - .exists(_.getFileName.toString.endsWith(".json")) - } finally { - ls.close() - } - hasJsonFile - } + dir.list.exists(_.extension == "json") } // Returns true if there's a build.sbt file or project/build.properties with sbt.version def isSbt: Boolean = { diff --git a/metals/src/main/scala/scala/meta/internal/builds/Digest.scala b/metals/src/main/scala/scala/meta/internal/builds/Digest.scala index b52d3c7ca8e..542733b78e3 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/Digest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/Digest.scala @@ -11,7 +11,6 @@ import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.io.AbsolutePath import scala.util.control.NonFatal import scala.xml.Node -import scala.meta.internal.mtags.ListFiles case class Digest( md5: String, @@ -61,11 +60,9 @@ object Digest { ): Boolean = { if (!path.isDirectory) true else { - var success = true - ListFiles.foreach(path) { file => - success &= digestFile(file, digest) + path.list.forall { file => + digestFile(file, digest) } - success } } @@ -122,7 +119,7 @@ object Digest { chldrenSuccessful.forall(p => p) } try { - val xml = XML.loadFile(file.toNIO.toFile()) + val xml = XML.loadFile(file.toNIO.toFile) digestElement(xml) xml.text.split("\\s+").foreach(word => digest.update(word.getBytes)) true diff --git a/metals/src/main/scala/scala/meta/internal/builds/GradleDigest.scala b/metals/src/main/scala/scala/meta/internal/builds/GradleDigest.scala index 061c0e7434a..142703d5e6f 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/GradleDigest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/GradleDigest.scala @@ -1,9 +1,8 @@ package scala.meta.internal.builds -import scala.meta.io.AbsolutePath -import scala.meta.internal.mtags.WalkFiles import java.security.MessageDigest -import scala.meta.internal.mtags.ListFiles +import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.io.AbsolutePath object GradleDigest extends Digestable { override protected def digestWorkspace( @@ -23,33 +22,28 @@ object GradleDigest extends Digestable { } def digestBuildSrc(path: AbsolutePath, digest: MessageDigest): Boolean = { - WalkFiles.foreach(path) { file => + path.listRecursive.forall { file => Digest.digestFile(file, digest) } - true } def digestSubProjects( workspace: AbsolutePath, digest: MessageDigest ): Boolean = { - val directories = ListFiles(workspace).filter(_.isDirectory) + val directories = workspace.list.filter(_.isDirectory).toList val (subprojects, dirs) = directories.partition { file => - ListFiles - .exists(file) { path => - val stringPath = path.toString - stringPath.endsWith(".gradle") || stringPath.endsWith("gradle.kts") - } + file.list.exists { path => + val stringPath = path.toString + stringPath.endsWith(".gradle") || stringPath.endsWith("gradle.kts") + } } /* If a dir contains a gradle file we need to treat is as a workspace */ val isSuccessful = subprojects.forall { file => - digestWorkspace( - file, - digest - ) + digestWorkspace(file, digest) } /* diff --git a/metals/src/main/scala/scala/meta/internal/builds/MavenDigest.scala b/metals/src/main/scala/scala/meta/internal/builds/MavenDigest.scala index 3ab08ceb635..a9154892533 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/MavenDigest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/MavenDigest.scala @@ -2,20 +2,18 @@ package scala.meta.internal.builds import java.security.MessageDigest import scala.meta.io.AbsolutePath -import scala.meta.internal.mtags.WalkFiles -import scala.meta.internal.mtags.MtagsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments._ object MavenDigest extends Digestable { override protected def digestWorkspace( workspace: AbsolutePath, digest: MessageDigest ): Boolean = { - Digest.digestFile(workspace.resolve("pom.xml"), digest) - WalkFiles.foreach(workspace) { file => - if (file.filename == "pom.xml") { + workspace.listRecursive.forall { + case file if file.filename == "pom.xml" => Digest.digestFile(file, digest) - } + case _ => + true } - true } } diff --git a/metals/src/main/scala/scala/meta/internal/builds/SbtDigest.scala b/metals/src/main/scala/scala/meta/internal/builds/SbtDigest.scala index 67fb8c36656..783e94ff35d 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/SbtDigest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/SbtDigest.scala @@ -5,7 +5,6 @@ import java.security.MessageDigest import scala.meta.internal.builds.Digest.digestScala import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.io.AbsolutePath -import scala.meta.internal.mtags.ListFiles object SbtDigest extends Digestable { @@ -20,14 +19,11 @@ object SbtDigest extends Digestable { Digest.digestDirectory(project.resolve("project"), digest) } - def digestSbtFiles( - path: AbsolutePath, - digest: MessageDigest - ): Boolean = { - if (!path.isDirectory) { - true + def digestSbtFiles(path: AbsolutePath, digest: MessageDigest): Boolean = { + if (path.isDirectory) { + path.list.forall(file => digestSbtFile(digest)(file)) } else { - ListFiles.forall(path)(file => digestSbtFile(digest)(file)) + true } } diff --git a/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala b/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala index 4e0d0467532..f3de80ff823 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala @@ -55,8 +55,10 @@ final class BloopServers( maxRetries: Int = defaultRetries ): Future[Option[BuildServerConnection]] = { newServerUnsafe().map(Option(_)).recoverWith { - case NonFatal(_) if maxRetries > 0 => - scribe.warn(s"BSP retry ${defaultRetries - maxRetries + 1}") + case NonFatal(e) if maxRetries > 0 => + val retry = defaultRetries - maxRetries + 1 + val cause = e.getMessage + scribe.warn(s"BSP retry $retry due to: $cause", e) newServer(maxRetries - 1) } } diff --git a/metals/src/main/scala/scala/meta/internal/metals/BspServers.scala b/metals/src/main/scala/scala/meta/internal/metals/BspServers.scala index e23a723c67d..8039bac42e2 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BspServers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BspServers.scala @@ -14,7 +14,6 @@ import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.mtags.MD5 import scala.meta.io.AbsolutePath import scala.util.Try -import scala.meta.internal.mtags.ListFiles /** * Implements BSP server discovery, named "BSP Connection Protocol" in the spec. @@ -124,11 +123,9 @@ final class BspServers( private def findJsonFiles(): List[AbsolutePath] = { val buf = List.newBuilder[AbsolutePath] def visit(dir: AbsolutePath): Unit = - if (dir.isDirectory) { - ListFiles.foreach(dir) { p => - if (p.extension == "json") { - buf += p - } + dir.list.foreach { p => + if (p.extension == "json") { + buf += p } } visit(workspace.resolve(".bsp")) diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala index b157fe36f9b..dc7cf0f2d61 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala @@ -294,21 +294,13 @@ object MetalsEnrichments } } - def exists: Boolean = { - Files.exists(path.toNIO) - } - def touch(): Unit = { if (!path.exists) { - parent.createDirectories() + path.parent.createDirectories() Files.createFile(path.toNIO) } } - def parent: AbsolutePath = { - AbsolutePath(path.toNIO.getParent) - } - def createDirectories(): AbsolutePath = { AbsolutePath(Files.createDirectories(dealias.toNIO)) } @@ -318,10 +310,9 @@ object MetalsEnrichments } def writeText(text: String): Unit = { - parent.createDirectories() + path.parent.createDirectories() Files.write(path.toNIO, text.getBytes(StandardCharsets.UTF_8)) } - } implicit class XtensionString(value: String) { diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsLanguageServer.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsLanguageServer.scala index c62c20ac898..954b86bd0f1 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsLanguageServer.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsLanguageServer.scala @@ -1316,7 +1316,7 @@ class MetalsLanguageServer( private def indexWorkspaceSources(): Unit = { for { (sourceItem, targets) <- buildTargets.sourceItemsToBuildTargets - source <- WalkFiles(sourceItem) + source <- sourceItem.listRecursive if source.isScalaOrJava } { targets.asScala.foreach { target => diff --git a/metals/src/main/scala/scala/meta/internal/tvp/ClasspathSymbols.scala b/metals/src/main/scala/scala/meta/internal/tvp/ClasspathSymbols.scala index 4ed74ceadee..98747356602 100644 --- a/metals/src/main/scala/scala/meta/internal/tvp/ClasspathSymbols.scala +++ b/metals/src/main/scala/scala/meta/internal/tvp/ClasspathSymbols.scala @@ -20,7 +20,6 @@ import scala.tools.scalap.scalax.rules.scalasig.SymbolInfoSymbol import scala.meta.internal.scalacp.SymlinkChildren import scala.meta.internal.scalacp.Synthetics import scala.util.control.NonFatal -import java.util.stream.Collectors import scala.meta.internal.javacp.Javacp import scala.meta.internal.metals.Time import scala.meta.internal.metals.Timer @@ -95,17 +94,16 @@ class ClasspathSymbols(isStatisticsEnabled: Boolean = false) { def list(root: AbsolutePath): Unit = { val dir = if (symbol == Scala.Symbols.RootPackage) root - else { - root.resolve(Symbol(symbol).enclosingPackage.value) - } - listPath(dir.toNIO).foreach { path => - if (Files.isDirectory(path)) { - buf ++= dummyClassfiles(root.toNIO, path) - } else if (isClassfile(path)) { + else root.resolve(Symbol(symbol).enclosingPackage.value) + + dir.list.foreach { + case path if path.isDirectory => + buf ++= dummyClassfiles(root.toNIO, path.toNIO) + + case path if isClassfile(path.toNIO) => try { - val abspath = AbsolutePath(path) - val node = abspath.toClassNode - classfileSymbols(path, node, index, { i => + val node = path.toClassNode + classfileSymbols(path.toNIO, node, index, { i => if (isRelevant(i)) { buf += TreeViewSymbolInformation(i.symbol, i.kind, i.properties) } @@ -114,7 +112,8 @@ class ClasspathSymbols(isStatisticsEnabled: Boolean = false) { case NonFatal(ex) => scribe.warn(s"error: can't convert $path in $in", ex) } - } + + case _ => } } @@ -174,15 +173,6 @@ class ClasspathSymbols(isStatisticsEnabled: Boolean = false) { private def isClassfile(path: Path): Boolean = { PathIO.extension(path) == "class" && Files.size(path) > 0 } - private def listPath(path: Path): Seq[Path] = { - if (Files.isDirectory(path)) { - val ls = Files.list(path) - try ls.collect(Collectors.toList()).asScala - finally ls.close() - } else { - Nil - } - } private def classfileSymbols( path: Path, @@ -224,7 +214,6 @@ class ClasspathSymbols(isStatisticsEnabled: Boolean = false) { } } } - Nil } } diff --git a/mtags/src/main/scala/scala/meta/internal/metals/JdkSources.scala b/mtags/src/main/scala/scala/meta/internal/metals/JdkSources.scala index 4bee08c7b90..b4b272dcae7 100644 --- a/mtags/src/main/scala/scala/meta/internal/metals/JdkSources.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/JdkSources.scala @@ -1,16 +1,16 @@ package scala.meta.internal.metals -import java.nio.file.Files -import java.nio.file.Path import java.nio.file.Paths import scala.meta.io.AbsolutePath +import scala.meta.io.RelativePath +import scala.meta.internal.mtags.MtagsEnrichments._ /** * Locates zip file on disk that contains the source code for the JDK. */ object JdkSources { - private val sources = Paths.get("src.zip") - private val libSources = Paths.get("lib").resolve(sources) + private val sources = RelativePath(Paths.get("src.zip")) + private val libSources = RelativePath(Paths.get("lib")).resolve(sources) def apply(userJavaHome: Option[String] = None): Option[AbsolutePath] = { candidates(userJavaHome).headOption @@ -23,33 +23,32 @@ object JdkSources { } private def candidates(userJavaHome: Option[String]): List[AbsolutePath] = { - def isJdkCandidate(path: Path): Boolean = { - def containsJre = Files.exists(path.resolve("jre")) - val name = path.getFileName.toString + def isJdkCandidate(path: AbsolutePath): Boolean = { + def containsJre = path.resolve("jre").exists + val name = path.filename.toString name.contains("jdk") || containsJre //e.g. jdk-8, java-openjdk-11 } for { javaHomeString <- userJavaHome.orElse(defaultJavaHome).toList - javaHome = Paths.get(javaHomeString) + javaHome = AbsolutePath(Paths.get(javaHomeString)) jdkHome = { if (isJdkCandidate(javaHome)) { Nil } else { // In case java.home points to the JRE instead of the JDK, // try to find jdk among its siblings - Files - .list(javaHome.getParent) + javaHome.parent.list .filter(isJdkCandidate) - .toArray[Path](size => new Array(size)) - .sortBy(_.getFileName) + .toArray[AbsolutePath] + .sortBy(_.filename) .toList } } - jdk <- jdkHome ++ List(javaHome.getParent, javaHome) + jdk <- jdkHome ++ List(javaHome.parent, javaHome) src <- List(sources, libSources).map(jdk.resolve) - if Files.isRegularFile(src) - } yield AbsolutePath(src) + if src.isFile + } yield src } def getOrThrow(): AbsolutePath = { diff --git a/mtags/src/main/scala/scala/meta/internal/metals/PackageIndex.scala b/mtags/src/main/scala/scala/meta/internal/metals/PackageIndex.scala index b3fda5f4b4c..62644ab3369 100644 --- a/mtags/src/main/scala/scala/meta/internal/metals/PackageIndex.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/PackageIndex.scala @@ -20,7 +20,6 @@ import scala.util.control.NonFatal import scala.util.Properties import java.nio.file.FileSystems import java.net.URI -import scala.meta.internal.mtags.ListFiles /** * An index to lookup classfiles contained in a given classpath. @@ -137,7 +136,7 @@ class PackageIndex() { for { pkg <- Files.newDirectoryStream(dir).iterator().asScala symbol = pkg.toString.stripPrefix("/packages/").replace('.', '/') + "/" - absoluteModuleLink <- ListFiles(AbsolutePath(pkg)) + absoluteModuleLink <- AbsolutePath(pkg).list } { val moduleLink = absoluteModuleLink.toNIO val module = diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/ListFiles.scala b/mtags/src/main/scala/scala/meta/internal/mtags/ListFiles.scala deleted file mode 100644 index f2638c8bc28..00000000000 --- a/mtags/src/main/scala/scala/meta/internal/mtags/ListFiles.scala +++ /dev/null @@ -1,41 +0,0 @@ -package scala.meta.internal.mtags - -import java.nio.file.Files -import scala.meta.io.AbsolutePath -import scala.collection.mutable -import java.util.stream.{Stream => JStream} -import java.nio.file.Path - -object ListFiles { - def apply(root: AbsolutePath): mutable.ArrayBuffer[AbsolutePath] = { - val buf = mutable.ArrayBuffer.empty[AbsolutePath] - foreach(root)(file => buf += file) - buf - } - - def exists(root: AbsolutePath)(fn: AbsolutePath => Boolean) = - closing(root) { - _.anyMatch(file => fn(AbsolutePath(file))) - } - - def forall(root: AbsolutePath)(fn: AbsolutePath => Boolean) = - closing(root) { - _.allMatch(file => fn(AbsolutePath(file))) - } - - def foreach(root: AbsolutePath)(fn: AbsolutePath => Unit) = - closing(root) { - _.forEach(file => fn(AbsolutePath(file))) - } - - private def closing[T]( - root: AbsolutePath - )(fn: JStream[Path] => T): T = { - val ls = Files.list(root.toNIO) - try { - fn(ls) - } finally { - ls.close() - } - } -} diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/MtagsEnrichments.scala b/mtags/src/main/scala/scala/meta/internal/mtags/MtagsEnrichments.scala index 0e05bc2f914..c748c40ff7b 100644 --- a/mtags/src/main/scala/scala/meta/internal/mtags/MtagsEnrichments.scala +++ b/mtags/src/main/scala/scala/meta/internal/mtags/MtagsEnrichments.scala @@ -3,6 +3,7 @@ package scala.meta.internal.mtags import com.google.gson.Gson import com.google.gson.JsonElement import java.nio.charset.StandardCharsets +import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths import java.util @@ -10,6 +11,7 @@ import java.util.Optional import java.util.concurrent.CancellationException import java.util.logging.Level import java.util.logging.Logger +import geny.Generator import org.eclipse.lsp4j.CompletionItem import org.eclipse.lsp4j.MarkupContent import org.eclipse.lsp4j.jsonrpc.CancelChecker @@ -57,7 +59,9 @@ trait MtagsEnrichments { def isClassfile: Boolean = filename.endsWith(".class") def filename: String = file.getFileName().toString() def toLanguage: Language = { - filenameToLanguage(file.getFileName.toString) + val filename = file.getFileName + if (filename == null) Language.UNKNOWN_LANGUAGE + else filenameToLanguage(filename.toString) } def semanticdbRoot: Option[Path] = { val end = Paths.get("META-INF").resolve("semanticdb") @@ -359,4 +363,32 @@ trait MtagsEnrichments { def isVar: Boolean = (properties & p.VAR.value) != 0 def isVal: Boolean = (properties & p.VAL.value) != 0 } + + implicit class XtensionStream[A](stream: java.util.stream.Stream[A]) { + import scala.collection.JavaConverters._ + def asScala: Generator[A] = { + Generator.selfClosing((stream.iterator.asScala, () => stream.close())) + } + } + + implicit class XtensionAbsolutePath(path: AbsolutePath) { + def parent: AbsolutePath = { + AbsolutePath(path.toNIO.getParent) + } + + def exists: Boolean = { + Files.exists(path.toNIO) + } + + def list: Generator[AbsolutePath] = { + if (path.isDirectory) Files.list(path.toNIO).asScala.map(AbsolutePath(_)) + else Generator() + } + + def listRecursive: Generator[AbsolutePath] = { + if (path.isDirectory) Files.walk(path.toNIO).asScala.map(AbsolutePath(_)) + else if (path.isFile) Generator(path) + else Generator() + } + } } diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/OnDemandSymbolIndex.scala b/mtags/src/main/scala/scala/meta/internal/mtags/OnDemandSymbolIndex.scala index 54f68ffc785..fa7db39218a 100644 --- a/mtags/src/main/scala/scala/meta/internal/mtags/OnDemandSymbolIndex.scala +++ b/mtags/src/main/scala/scala/meta/internal/mtags/OnDemandSymbolIndex.scala @@ -53,15 +53,15 @@ final case class OnDemandSymbolIndex( override def addSourceJar(jar: AbsolutePath): Unit = tryRun { if (sourceJars.addEntry(jar)) { FileIO.withJarFileSystem(jar, create = false) { root => - WalkFiles.foreach(root) { source => - if (source.toLanguage.isScala) { + root.listRecursive.foreach { + case source if source.isScala => try { addSourceFile(source, None) } catch { case NonFatal(e) => onError.lift(IndexError(source, e)) } - } + case _ => } } } diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/WalkFiles.scala b/mtags/src/main/scala/scala/meta/internal/mtags/WalkFiles.scala deleted file mode 100644 index 56d7cb02b3f..00000000000 --- a/mtags/src/main/scala/scala/meta/internal/mtags/WalkFiles.scala +++ /dev/null @@ -1,41 +0,0 @@ -package scala.meta.internal.mtags - -import java.nio.file.FileVisitResult -import java.nio.file.Files -import java.nio.file.NoSuchFileException -import java.nio.file.Path -import java.nio.file.SimpleFileVisitor -import java.nio.file.attribute.BasicFileAttributes -import scala.meta.io.AbsolutePath -import scala.collection.mutable.ArrayBuffer - -object WalkFiles { - def foreach(root: AbsolutePath)(fn: AbsolutePath => Unit): Unit = { - if (root.isFile) fn(root) - else if (root.isDirectory) { - try { - Files.walkFileTree( - root.toNIO, - new SimpleFileVisitor[Path] { - override def visitFile( - file: Path, - attrs: BasicFileAttributes - ): FileVisitResult = { - fn(AbsolutePath(file)) - FileVisitResult.CONTINUE - } - } - ) - } catch { - case _: NoSuchFileException => - () // error is reported by the JDK - } - } - } - - def apply(root: AbsolutePath): ArrayBuffer[AbsolutePath] = { - val buf = ArrayBuffer.empty[AbsolutePath] - foreach(root)(file => buf += file) - buf - } -} diff --git a/tests/unit/src/main/scala/tests/QuickBuild.scala b/tests/unit/src/main/scala/tests/QuickBuild.scala index 97b67c47a72..0f81227c4d0 100644 --- a/tests/unit/src/main/scala/tests/QuickBuild.scala +++ b/tests/unit/src/main/scala/tests/QuickBuild.scala @@ -21,7 +21,6 @@ import scala.meta.internal.metals.{BuildInfo => V} import scala.meta.internal.mtags.MD5 import scala.meta.io.AbsolutePath import scala.util.matching.Regex -import scala.meta.internal.mtags.ListFiles /** * A basic build tool for faster testing. @@ -269,11 +268,9 @@ object QuickBuild { update(workspace.resolve("metals.json")) val bloopDirectory = workspace.resolve(".bloop").toNIO Files.createDirectories(bloopDirectory) - ListFiles.foreach(AbsolutePath(bloopDirectory)) { path => - if (path.extension == "json") { - update(path) - } - } + AbsolutePath(bloopDirectory).list + .filter(_.extension == "json") + .foreach(json => update(json)) MD5.bytesToHex(digest.digest()) } if (oldDigest == newDigest) None @@ -297,11 +294,9 @@ object QuickBuild { } val bloopDirectory = workspace.resolve(".bloop").toNIO Files.createDirectories(bloopDirectory) - ListFiles.foreach(AbsolutePath(bloopDirectory)) { path => - if (path.extension == "json") { - path.delete() - } - } + AbsolutePath(bloopDirectory).list + .filter(_.extension == "json") + .foreach(json => json.delete()) val bloopProjects = projects.map(_.toBloop(workspace)) val byName = bloopProjects.map(p => p.name -> p).toMap val fullClasspathProjects = bloopProjects.map { p =>