Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Nov 30, 2023
1 parent f91be9b commit 43c690c
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FallbackMetalsLspService(
maxScalaCliServers = 10,
) {

override protected def doctor: Doctor =
override protected val doctor: Doctor =
new Doctor(
path,
buildTargets,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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""""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand All @@ -159,7 +158,6 @@ class MetalsLanguageServer(
} else {
lazy val fallbackServicePath = FallbackMetalsLspService.path()
val service = createService(folders, params, fallbackServicePath)
val folderPaths = folders.map(_.path)

setupJna()

Expand All @@ -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."
)

Expand Down
10 changes: 10 additions & 0 deletions tests/slow/src/test/scala/tests/gradle/GradleLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -336,6 +344,8 @@ class GradleLspSuite extends BaseImportSuite("gradle-import") {
_ <- initialize(
"""|/build.gradle
|, syntax error
|/src/main/scala/A.scala
|
|""".stripMargin,
expectError = true,
)
Expand Down
4 changes: 4 additions & 0 deletions tests/slow/src/test/scala/tests/maven/MavenLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class MavenLspSuite extends BaseImportSuite("maven-import") {
_ <- initialize(
s"""|/pom.xml
|$defaultPom
|/src/main/scala/A.scala
|
|""".stripMargin
)
_ = assertNoDiff(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 43c690c

Please sign in to comment.