diff --git a/metals/src/main/scala/scala/meta/internal/metals/FallbackMetalsLspService.scala b/metals/src/main/scala/scala/meta/internal/metals/FallbackMetalsLspService.scala index c660c955565..3c83ff01005 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/FallbackMetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/FallbackMetalsLspService.scala @@ -55,7 +55,7 @@ class FallbackMetalsLspService( maxScalaCliServers = 10, ) { - override protected def doctor: Doctor = + override protected val doctor: Doctor = new Doctor( path, buildTargets, @@ -72,11 +72,11 @@ class FallbackMetalsLspService( buildTools = None, bspStatus = None, ) - override protected def bspSession: Option[BspSession] = None - override protected def buildServerPromise: Promise[Unit] = + override protected val bspSession: Option[BspSession] = None + override protected val buildServerPromise: Promise[Unit] = Promise().success(()) - override protected def bspErrorHandler: BspErrorHandler = LogBspErrorHandler - override protected def optBuildTools: Option[BuildTools] = None + override protected val bspErrorHandler: BspErrorHandler = LogBspErrorHandler + override protected val optBuildTools: Option[BuildTools] = None private val files: AtomicReference[Set[AbsolutePath]] = new AtomicReference( Set.empty diff --git a/metals/src/main/scala/scala/meta/internal/metals/ForwardingMetalsBuildClient.scala b/metals/src/main/scala/scala/meta/internal/metals/ForwardingMetalsBuildClient.scala index 59a9da7cf27..417f7cd2d05 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ForwardingMetalsBuildClient.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ForwardingMetalsBuildClient.scala @@ -42,7 +42,7 @@ final class ForwardingMetalsBuildClient( didCompile: CompileReport => Unit, onBuildTargetDidCompile: BuildTargetIdentifier => Unit, onBuildTargetDidChangeFunc: b.DidChangeBuildTarget => Unit, - bspErrorHandler: BspErrorHandler, + bspErrorHandler: => BspErrorHandler, ) extends MetalsBuildClient with Cancelable { 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 b31969117b4..b0d807e2f5d 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala @@ -353,13 +353,20 @@ object MetalsEnrichments def isScalaDir( file: File, dirFilter: File => Boolean = _ => true, + isRoot: Boolean = false, ): Boolean = { file.listFiles().exists { file => - if (file.isDirectory()) dirFilter(file) && isScalaDir(file) - else fileNamePredicate(file.getName()) + if (file.isDirectory()) { + if (dirFilter(file)) isScalaDir(file) + else + isRoot && !file.getName().startsWith(".") && isScalaDir( + file, + dirFilter, + ) + } else fileNamePredicate(file.getName()) } } - path.isDirectory && isScalaDir(path.toFile, dirFilter) + path.isDirectory && isScalaDir(path.toFile, dirFilter, isRoot = true) } def scalaSourcerootOption: String = s""""-P:semanticdb:sourceroot:$path"""" diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala index 18c33800268..748327af585 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala @@ -630,14 +630,6 @@ abstract class MetalsLspService( languageClient, ) - // val gitHubIssueFolderInfo = new GitHubIssueFolderInfo( - // () => tables.buildTool.selectedBuildTool(), - // buildTargets, - // () => bspSession, - // () => bspConnector.resolve(), - // buildTools, - // ) - protected val fileDecoderProvider: FileDecoderProvider = new FileDecoderProvider( folder, diff --git a/metals/src/main/scala/scala/meta/internal/metals/Warnings.scala b/metals/src/main/scala/scala/meta/internal/metals/Warnings.scala index d86ba70b7ac..ce8c5be0c3e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Warnings.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Warnings.scala @@ -18,7 +18,7 @@ final class Warnings( buildTargets: BuildTargets, statusBar: StatusBar, icons: Icons, - buildTools: Option[BuildTools], + buildTools: => Option[BuildTools], isCompiling: BuildTargetIdentifier => Boolean, ) { def noSemanticdb(path: AbsolutePath): Unit = { diff --git a/metals/src/main/scala/scala/meta/metals/MetalsLanguageServer.scala b/metals/src/main/scala/scala/meta/metals/MetalsLanguageServer.scala index e919fa2238a..f17efc1ae48 100644 --- a/metals/src/main/scala/scala/meta/metals/MetalsLanguageServer.scala +++ b/metals/src/main/scala/scala/meta/metals/MetalsLanguageServer.scala @@ -141,11 +141,10 @@ class MetalsLanguageServer( new Folder( root.toAbsolutePath, Some("root"), - isKnownMetalsProject = true, + isKnownMetalsProject = false, ) ) .toList - case head :: Nil => List(Folder(head, isKnownMetalsProject = true)) case many => many.map(Folder(_, isKnownMetalsProject = false)) } } @@ -159,7 +158,6 @@ class MetalsLanguageServer( } else { lazy val fallbackServicePath = FallbackMetalsLspService.path() val service = createService(folders, params, fallbackServicePath) - val folderPaths = folders.map(_.path) setupJna() @@ -186,7 +184,7 @@ class MetalsLanguageServer( s"for client ${info.getName()} ${Option(info.getVersion).getOrElse("")}" } scribe.info( - s"Started: Metals version ${BuildInfo.metalsVersion} in folders '${folderPaths + s"Started: Metals version ${BuildInfo.metalsVersion} in folders '${folderPathsWithScala .mkString(", ")}' $clientInfo." ) diff --git a/tests/slow/src/test/scala/tests/gradle/GradleLspSuite.scala b/tests/slow/src/test/scala/tests/gradle/GradleLspSuite.scala index 0b0bddf9160..246ada74cab 100644 --- a/tests/slow/src/test/scala/tests/gradle/GradleLspSuite.scala +++ b/tests/slow/src/test/scala/tests/gradle/GradleLspSuite.scala @@ -37,6 +37,8 @@ class GradleLspSuite extends BaseImportSuite("gradle-import") { |dependencies { | implementation 'org.scala-lang:scala-library:${V.scala213}' |} + |/src/main/scala/A.scala + | |""".stripMargin ) _ = assertNoDiff( @@ -141,6 +143,8 @@ class GradleLspSuite extends BaseImportSuite("gradle-import") { |dependencies { | implementation 'org.scala-lang:scala-library:${V.scala213}' |} + |/src/main/scala/A.scala + | |""".stripMargin ) _ = assertNoDiff( @@ -238,6 +242,8 @@ class GradleLspSuite extends BaseImportSuite("gradle-import") { |dependencies { | implementation 'org.scala-lang:scala-reflect:${V.scala213}' |} + |/src/main/scala/A.scala + | |""".stripMargin ) _ = assertNoDiff( @@ -267,6 +273,8 @@ class GradleLspSuite extends BaseImportSuite("gradle-import") { |dependencies { | implementation 'org.scala-lang:scala-library:${V.scala213}' |} + |/src/main/scala/A.scala + | |""".stripMargin ) _ = assertNoDiff( @@ -336,6 +344,8 @@ class GradleLspSuite extends BaseImportSuite("gradle-import") { _ <- initialize( """|/build.gradle |, syntax error + |/src/main/scala/A.scala + | |""".stripMargin, expectError = true, ) diff --git a/tests/slow/src/test/scala/tests/maven/MavenLspSuite.scala b/tests/slow/src/test/scala/tests/maven/MavenLspSuite.scala index 80f025c01f7..81d891726fb 100644 --- a/tests/slow/src/test/scala/tests/maven/MavenLspSuite.scala +++ b/tests/slow/src/test/scala/tests/maven/MavenLspSuite.scala @@ -36,6 +36,8 @@ class MavenLspSuite extends BaseImportSuite("maven-import") { _ <- initialize( s"""|/pom.xml |$defaultPom + |/src/main/scala/A.scala + | |""".stripMargin ) _ = assertNoDiff( @@ -79,6 +81,8 @@ class MavenLspSuite extends BaseImportSuite("maven-import") { _ <- initialize( s"""|/pom.xml |$defaultPom + |/src/main/scala/A.scala + | |""".stripMargin ) _ <- server.server.buildServerPromise.future