Skip to content

Commit

Permalink
scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jchyb committed May 8, 2024
1 parent ac5e6ad commit 99ea04b
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,25 @@ class CompilerConfiguration(
protected def newCompiler(classpath: Seq[Path]): PresentationCompiler = {
val name = scalaTarget.scalac.getTarget().getUri
val options = enrichWithReleaseOption(scalaTarget)
fromMtags(mtags, options, classpath ++ additionalClasspath, name, search)
// val filteredOptions = plugins.filterSupportedOptions(options)
val nonBestEffortOptions =
options.filter(_ != "-Ybest-effort") :+ "-Ywith-best-effort-tasty"
val bestEffortDirs = scalaTarget.info
.getDependencies()
.asScala
.flatMap { buildId =>
buildTargets.scalaTarget(buildId).flatMap(_.bestEffortPath)
}
.toSeq
val selfBestEffortDir = scalaTarget.bestEffortPath.toSeq

fromMtags(
mtags,
options,
classpath ++ additionalClasspath ++ bestEffortDirs ++ selfBestEffortDir,
name,
search,
)
.withBuildTargetName(scalaTarget.displayName)
}

Expand Down
162 changes: 81 additions & 81 deletions metals/src/main/scala/scala/meta/internal/metals/Compilers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1166,94 +1166,94 @@ class Compilers(
}

// REBASE confusion - was this deleted?
private def configure(
pc: PresentationCompiler,
search: SymbolSearch,
): PresentationCompiler =
pc.withSearch(search)
.withExecutorService(ec)
.withWorkspace(workspace.toNIO)
.withScheduledExecutorService(sh)
.withReportsLoggerLevel(MetalsServerConfig.default.loglevel)
.withConfiguration {
val options =
InitializationOptions.from(initializeParams).compilerOptions
config.initialConfig.compilers
.update(options)
.copy(
_symbolPrefixes = userConfig().symbolPrefixes,
isCompletionSnippetsEnabled =
initializeParams.supportsCompletionSnippets,
_isStripMarginOnTypeFormattingEnabled =
() => userConfig().enableStripMarginOnTypeFormatting,
)
}
// private def configure(
// pc: PresentationCompiler,
// search: SymbolSearch,
// ): PresentationCompiler =
// pc.withSearch(search)
// .withExecutorService(ec)
// .withWorkspace(workspace.toNIO)
// .withScheduledExecutorService(sh)
// .withReportsLoggerLevel(MetalsServerConfig.default.loglevel)
// .withConfiguration {
// val options =
// InitializationOptions.from(initializeParams).compilerOptions
// config.initialConfig.compilers
// .update(options)
// .copy(
// _symbolPrefixes = userConfig().symbolPrefixes,
// isCompletionSnippetsEnabled =
// initializeParams.supportsCompletionSnippets,
// _isStripMarginOnTypeFormattingEnabled =
// () => userConfig().enableStripMarginOnTypeFormatting,
// )
// }

def newCompiler(
target: ScalaTarget,
mtags: MtagsBinaries,
search: SymbolSearch,
): PresentationCompiler = {
val classpath =
target.scalac.classpath.toAbsoluteClasspath.map(_.toNIO).toSeq

val bestEffortDirs = target.info
.getDependencies()
.asScala
.flatMap { buildId =>
buildTargets.scalaTarget(buildId).flatMap(_.bestEffortPath)
}
.toSeq
// def newCompiler(
// target: ScalaTarget,
// mtags: MtagsBinaries,
// search: SymbolSearch,
// ): PresentationCompiler = {
// val classpath =
// target.scalac.getClasspath.toAbsoluteClasspath.map(_.toNIO).toSeq

// val bestEffortDirs = target.info
// .getDependencies()
// .asScala
// .flatMap { buildId =>
// buildTargets.scalaTarget(buildId).flatMap(_.bestEffortPath)
// }
// .toSeq

val selfBestEffortDir = target.bestEffortPath.toSeq
// val selfBestEffortDir = target.bestEffortPath.toSeq

newCompiler(
target,
mtags,
classpath ++ bestEffortDirs ++ selfBestEffortDir,
search,
)
}
// newCompiler(
// target,
// mtags,
// classpath ++ bestEffortDirs ++ selfBestEffortDir,
// search,
// )
// }

def newCompiler(
target: ScalaTarget,
mtags: MtagsBinaries,
classpath: Seq[Path],
search: SymbolSearch,
): PresentationCompiler = {
newCompiler(
mtags,
target.scalac.getOptions().asScala.toSeq,
classpath,
search,
target.scalac.getTarget.getUri,
)
}
// def newCompiler(
// target: ScalaTarget,
// mtags: MtagsBinaries,
// classpath: Seq[Path],
// search: SymbolSearch,
// ): PresentationCompiler = {
// newCompiler(
// mtags,
// target.scalac.getOptions().asScala.toSeq,
// classpath,
// search,
// target.scalac.getTarget.getUri,
// )
// }

def newCompiler(
mtags: MtagsBinaries,
options: Seq[String],
classpath: Seq[Path],
search: SymbolSearch,
name: String,
): PresentationCompiler = {
val pc: PresentationCompiler =
mtags match {
case MtagsBinaries.BuildIn => new ScalaPresentationCompiler()
case artifacts: MtagsBinaries.Artifacts =>
embedded.presentationCompiler(artifacts, classpath)
// def newCompiler(
// mtags: MtagsBinaries,
// options: Seq[String],
// classpath: Seq[Path],
// search: SymbolSearch,
// name: String,
// ): PresentationCompiler = {
// val pc: PresentationCompiler =
// mtags match {
// case MtagsBinaries.BuildIn => new ScalaPresentationCompiler()
// case artifacts: MtagsBinaries.Artifacts =>
// embedded.presentationCompiler(artifacts, classpath)

}
// }

val filteredOptions = plugins.filterSupportedOptions(options)
val nonBestEffortOptions =
filteredOptions.filter(_ != "-Ybest-effort") :+ "-Ywith-best-effort-tasty"
configure(pc, search).newInstance(
name,
classpath.asJava,
(log ++ nonBestEffortOptions).asJava,
)
}
// val filteredOptions = plugins.filterSupportedOptions(options)
// val nonBestEffortOptions =
// filteredOptions.filter(_ != "-Ybest-effort") :+ "-Ywith-best-effort-tasty"
// configure(pc, search).newInstance(
// name,
// classpath.asJava,
// (log ++ nonBestEffortOptions).asJava,
// )
// }

// // Best Effort option `-Ybest-effort-dir` is useless for PC,
// // as it may unnecesarily dump semanticdb and tasty files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ case class ScalaTarget(
else
Some(scalac.getClasspath().asScala.toList)

def bestEffortPath: Option[Path] = {
def bestEffortPath: Option[java.nio.file.Path] = {
val bestEffortDir = targetroot.resolve(Directories.bestEffort)
if (bestEffortDir.exists) {
Some(bestEffortDir.toNIO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ final class RunTestCodeLens(
buildTargetId: BuildTargetIdentifier
): Boolean = {
import scala.jdk.FunctionConverters._
buildTargetClasses.jvmRunEnvironment
.get(buildTargetId)
scala.concurrent.Await
.result(
buildTargetClasses.jvmRunEnvironment(buildTargetId),
scala.concurrent.duration.Duration.Inf,
) // TODO remove later
.map(_.getClasspath().asScala.map(_.toAbsolutePath.toString).toList)
.map { classpath =>
classpath.exists { dir =>
Expand Down
5 changes: 3 additions & 2 deletions project/V.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ object V {

val ammonite = "3.0.0-M1-19-a7973e17"
val betterMonadicFor = "0.3.1"
val bloop = "1.5.6-193-9efb13ad-20240506-1759-SNAPSHOT" // "1.5.17" // TODO change after release
val bloop =
"1.5.6-193-9efb13ad-20240506-1759-SNAPSHOT" // "1.5.17" // TODO change after release
val bloopConfig = "1.5.5"
val bsp = "2.1.0-M5"
val bsp = "2.2.0-M2"
val coursier = "2.1.5"
val coursierInterfaces =
"1.0.19" // changing coursier interfaces version may be not binary compatible.
Expand Down

0 comments on commit 99ea04b

Please sign in to comment.