Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better initial load logging #484

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions modules/lsp/src/main/scala/playground/lsp/LanguageServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import playground.language.CommandResultReporter
import playground.language.CompletionProvider
import playground.language.DiagnosticProvider
import playground.language.DocumentSymbolProvider
import playground.language.Feedback
import playground.language.FormattingProvider
import playground.language.TextDocumentProvider
import playground.language.Uri
Expand Down Expand Up @@ -173,13 +174,15 @@ object LanguageServer {
.toList
.map(_.toUri)

LanguageClient[F]
.showInfoMessage(s"Hello from Smithy Playground v${BuildInfo.version}") *>
Feedback[F]
.showInfoMessage(
s"Hello from Smithy Playground v${BuildInfo.version}! Loading project..."
) *>
ServerLoader[F]
.prepare(wsf.some)
.flatMap { prepped =>
ServerLoader[F].perform(prepped.params).flatTap { stats =>
LanguageClient[F]
Feedback[F]
.showInfoMessage(
s"Loaded Smithy Playground server with ${stats.render}"
)
Expand Down Expand Up @@ -307,11 +310,11 @@ object LanguageServer {
.prepare(workspaceFolders = None)
.flatMap {
case prepared if !prepared.isChanged =>
LanguageClient[F].showInfoMessage(
Feedback[F].showInfoMessage(
LanguageClient.NoChangeDetected
)
case prepared =>
LanguageClient[F].showInfoMessage("Detected changes, will try to rebuild server...") *>
Feedback[F].showInfoMessage("Detected changes, will try to rebuild server...") *>
ServerLoader[F]
.perform(prepared.params)
.onError { case e =>
Expand All @@ -322,7 +325,7 @@ object LanguageServer {
.flatMap { stats =>
LanguageClient[F].refreshDiagnostics *>
LanguageClient[F].refreshCodeLenses *>
LanguageClient[F].showInfoMessage(
Feedback[F].showInfoMessage(
s"Reloaded Smithy Playground server with ${stats.render}"
)
}
Expand Down
6 changes: 3 additions & 3 deletions modules/lsp/src/main/scala/playground/lsp/ServerLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ object ServerLoader {
) {

def render: String =
s"$sourceCount sources, $importCount imports, $dependencyCount dependencies and $pluginCount plugins"
s"$sourceCount source entries, $importCount imports, $dependencyCount dependencies and $pluginCount plugins"

}

object WorkspaceStats {

def fromBuildConfig(
def fromPlaygroundConfig(
bc: PlaygroundConfig
): WorkspaceStats = WorkspaceStats(
sourceCount = bc.sources.size,
Expand Down Expand Up @@ -109,7 +109,7 @@ object ServerLoader {
.build(params, this)
.map(server => State(server, Some(params)))
.flatMap(stateRef.set)
.as(WorkspaceStats.fromBuildConfig(params.config))
.as(WorkspaceStats.fromPlaygroundConfig(params.config))

val server: LanguageServer[F] = LanguageServer.defer(stateRef.get.map(_.currentServer))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ trait LanguageServerIntegrationTests {
TestClient
.MessageLog(
MessageType.Info,
s"Hello from Smithy Playground v${BuildInfo.version}",
s"Hello from Smithy Playground v${BuildInfo.version}! Loading project...",
),
TestClient.MessageLog(
MessageType.Info,
"Loaded Smithy Playground server with 2 sources, 0 imports, 2 dependencies and 0 plugins",
"Loaded Smithy Playground server with 2 source entries, 0 imports, 2 dependencies and 0 plugins",
),
)
IO {
require(
events.size == 2,
"Events emitted at startup should've had size 2, it was " + events.size + " instead",
events.size == initLogs.size,
s"Events emitted at startup should've had size ${initLogs.size}, it was " + events.size + " instead",
)
require(
events == initLogs,
Expand Down
Loading