-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move and rename bsp server status
- Loading branch information
1 parent
22efc78
commit 07f75c4
Showing
6 changed files
with
60 additions
and
58 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
50 changes: 50 additions & 0 deletions
50
metals/src/main/scala/scala/meta/internal/metals/ConnectionBspStatus.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,50 @@ | ||
package scala.meta.internal.metals | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean | ||
|
||
import scala.meta.internal.metals.clients.language.MetalsLanguageClient | ||
import scala.meta.internal.metals.clients.language.MetalsStatusParams | ||
import scala.meta.internal.metals.clients.language.StatusType | ||
|
||
class ConnectionBspStatus( | ||
client: MetalsLanguageClient, | ||
serverName: String, | ||
icons: Icons, | ||
) { | ||
private val isServerResponsive = new AtomicBoolean(false) | ||
|
||
def connected(): Unit = | ||
if (isServerResponsive.compareAndSet(false, true)) | ||
client.metalsStatus(ConnectionBspStatus.connectedParams(serverName, icons)) | ||
def noResponse(): Unit = | ||
if (isServerResponsive.compareAndSet(true, false)) { | ||
scribe.debug("server liveness monitor detected no response") | ||
client.metalsStatus(ConnectionBspStatus.noResponseParams(serverName, icons)) | ||
} | ||
def disconnected(): Unit = client.metalsStatus(ConnectionBspStatus.disconnectedParams) | ||
|
||
def isBuildServerResponsive: Boolean = isServerResponsive.get() | ||
} | ||
|
||
object ConnectionBspStatus { | ||
def connectedParams(serverName: String, icons: Icons): MetalsStatusParams = | ||
MetalsStatusParams( | ||
s"$serverName ${icons.link}", | ||
"info", | ||
show = true, | ||
tooltip = s"Metals is connected to the build server ($serverName).", | ||
).withStatusType(StatusType.bsp) | ||
|
||
val disconnectedParams: MetalsStatusParams = | ||
MetalsStatusParams("", hide = true).withStatusType(StatusType.bsp) | ||
|
||
def noResponseParams(serverName: String, icons: Icons): MetalsStatusParams = | ||
MetalsStatusParams( | ||
s"$serverName ${icons.error}", | ||
"error", | ||
show = true, | ||
tooltip = s"Build sever ($serverName) is not responding.", | ||
command = ServerCommands.ConnectBuildServer.id, | ||
commandTooltip = "Reconnect.", | ||
).withStatusType(StatusType.bsp) | ||
} |
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