forked from scalameta/metals
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no workspace support (scalameta#6289)
* improvement: support multiple scala-cli servers * improvement: support single files * single file test * cap number of scala-cli servers * small adjustments * for single files use temp workspace * test adjustments * review changes * fix gradle test * make `fallbackService` lazy * Don't look for semanticdb on path for scala-cli single files. * add doc comment and change type * post rebase fixes
- Loading branch information
1 parent
cdc11c6
commit ff9d08a
Showing
19 changed files
with
567 additions
and
164 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
88 changes: 88 additions & 0 deletions
88
metals/src/main/scala/scala/meta/internal/metals/FallbackMetalsLspService.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package scala.meta.internal.metals | ||
|
||
import java.nio.file.Files | ||
import java.util.concurrent.ScheduledExecutorService | ||
import java.util.concurrent.atomic.AtomicReference | ||
|
||
import scala.concurrent.ExecutionContextExecutorService | ||
import scala.concurrent.Future | ||
|
||
import scala.meta.internal.builds.ShellRunner | ||
import scala.meta.internal.metals.MetalsEnrichments._ | ||
import scala.meta.internal.metals.clients.language.ConfiguredLanguageClient | ||
import scala.meta.internal.metals.doctor.HeadDoctor | ||
import scala.meta.io.AbsolutePath | ||
|
||
import org.eclipse.lsp4j.DidCloseTextDocumentParams | ||
import org.eclipse.lsp4j.InitializeParams | ||
|
||
class FallbackMetalsLspService( | ||
ec: ExecutionContextExecutorService, | ||
sh: ScheduledExecutorService, | ||
serverInputs: MetalsServerInputs, | ||
languageClient: ConfiguredLanguageClient, | ||
initializeParams: InitializeParams, | ||
clientConfig: ClientConfiguration, | ||
statusBar: StatusBar, | ||
focusedDocument: () => Option[AbsolutePath], | ||
shellRunner: ShellRunner, | ||
timerProvider: TimerProvider, | ||
initTreeView: () => Unit, | ||
folder: AbsolutePath, | ||
folderVisibleName: Option[String], | ||
headDoctor: HeadDoctor, | ||
workDoneProgress: WorkDoneProgress, | ||
bspStatus: BspStatus, | ||
) extends MetalsLspService( | ||
ec, | ||
sh, | ||
serverInputs, | ||
languageClient, | ||
initializeParams, | ||
clientConfig, | ||
statusBar, | ||
focusedDocument, | ||
shellRunner, | ||
timerProvider, | ||
initTreeView, | ||
folder, | ||
folderVisibleName, | ||
headDoctor, | ||
bspStatus, | ||
workDoneProgress, | ||
maxScalaCliServers = 10, | ||
) { | ||
|
||
buildServerPromise.success(()) | ||
indexingPromise.success(()) | ||
|
||
private val files: AtomicReference[Set[AbsolutePath]] = new AtomicReference( | ||
Set.empty | ||
) | ||
|
||
override def maybeImportScript(path: AbsolutePath): Option[Future[Unit]] = { | ||
if (!path.isScala) None | ||
else { | ||
val prev = files.getAndUpdate(_ + path) | ||
if (prev.contains(path)) None | ||
else Some(scalaCli.start(path)) | ||
} | ||
} | ||
|
||
override def didClose(params: DidCloseTextDocumentParams): Unit = { | ||
val path = params.getTextDocument.getUri.toAbsolutePath | ||
files.getAndUpdate(_ - path) | ||
super.didClose(params) | ||
scalaCli.stop(path) | ||
} | ||
|
||
} | ||
|
||
object FallbackMetalsLspService { | ||
def path(): AbsolutePath = { | ||
val uri = Files.createTempDirectory(s"fallback-service") | ||
scribe.debug(s"creating tmp directory $uri for fallback service in") | ||
uri.toFile.deleteOnExit() | ||
AbsolutePath(uri) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.