Skip to content

Commit 0830922

Browse files
committed
rename
1 parent 40db744 commit 0830922

File tree

11 files changed

+32
-41
lines changed

11 files changed

+32
-41
lines changed

engine/language_server/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::num::NonZeroUsize;
44

55
use anyhow::Context;
66
pub use edit::{DocumentKey, PositionEncoding, TextDocument};
7-
use playground_server::{LangServerToWasmMessage, PreSendToWasmMessage};
7+
use playground_server::{LangServerToWasmMessage, PreLangServerToWasmMessage};
88
pub use session::{ClientSettings, DocumentQuery, DocumentSnapshot, Session};
99
use tokio::sync::broadcast;
1010

engine/language_server/src/server.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use self::{
2727
connection::{Connection, ConnectionInitializer},
2828
schedule::event_loop_thread,
2929
};
30-
use playground_server::{FrontendMessage, LangServerToWasmMessage, PreSendToWasmMessage};
30+
use playground_server::{FrontendMessage, LangServerToWasmMessage, PreLangServerToWasmMessage};
3131

3232
use crate::{
3333
baml_project::file_utils::{find_baml_src, find_top_level_parent},
@@ -56,8 +56,8 @@ pub type Result<T> = std::result::Result<T, api::Error>;
5656
pub(crate) struct ServerArgs {
5757
pub tokio_handle: tokio::runtime::Handle,
5858
pub broadcast_tx: broadcast::Sender<LangServerToWasmMessage>,
59-
pub playground_rx: broadcast::Receiver<PreSendToWasmMessage>,
60-
pub playground_tx: broadcast::Sender<PreSendToWasmMessage>,
59+
pub playground_rx: broadcast::Receiver<PreLangServerToWasmMessage>,
60+
pub playground_tx: broadcast::Sender<PreLangServerToWasmMessage>,
6161
pub playground_port: u16,
6262
pub proxy_port: u16,
6363
}
@@ -190,25 +190,15 @@ impl Server {
190190
let client = client::Client::new(connection.make_sender());
191191
let notifier = client.notifier();
192192

193-
// Playground state is initialized here, but server startup is now external
194-
// #[cfg(feature = "playground-server")]
195-
// {
196-
// let playground_state = Arc::new(RwLock::new(PlaygroundState::new()));
197-
// session.playground_state = Some(playground_state.clone());
198-
// // Store the runtime in the session
199-
// session.playground_runtime = Some(rt);
200-
// }
201193
session.reload(Some(notifier))?;
202194

203-
let mut server = Self {
195+
let server = Self {
204196
connection,
205197
worker_threads,
206198
session,
207199
client_capabilities,
208200
args,
209201
};
210-
// #[cfg(feature = "playground-server")]
211-
// server.start_playground_server();
212202

213203
{
214204
let lsp_sender = server.connection.make_sender();
@@ -235,7 +225,7 @@ impl Server {
235225
while let Ok(msg) = playground_rx.recv().await {
236226
tracing::info!("playground rx loop: {:?}", msg);
237227
match msg {
238-
PreSendToWasmMessage::Initialized => {
228+
PreLangServerToWasmMessage::WasmIsInitialized => {
239229
tracing::info!("Received playground INITIALIZED request");
240230
let projects = session.baml_src_projects.lock();
241231
for (_, project) in projects.iter() {
@@ -269,7 +259,7 @@ impl Server {
269259
.unwrap();
270260
}
271261
}
272-
PreSendToWasmMessage::FrontendMessage(msg) => {
262+
PreLangServerToWasmMessage::FrontendMessage(msg) => {
273263
broadcast_tx
274264
.send(LangServerToWasmMessage::PlaygroundMessage(msg))
275265
.unwrap();

engine/language_server/src/server/api/notifications/did_change.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{collections::HashMap, time::Instant};
33
use lsp_types::{
44
notification::DidChangeTextDocument, DidChangeTextDocumentParams, PublishDiagnosticsParams,
55
};
6-
use playground_server::{FrontendMessage, PreSendToWasmMessage};
6+
use playground_server::{FrontendMessage, PreLangServerToWasmMessage};
77

88
use crate::{
99
server::{
@@ -85,7 +85,7 @@ impl SyncNotificationHandler for DidChangeTextDocumentHandler {
8585
.collect();
8686
session
8787
.playground_tx
88-
.send(PreSendToWasmMessage::FrontendMessage(
88+
.send(PreLangServerToWasmMessage::FrontendMessage(
8989
FrontendMessage::add_project {
9090
root_path: project.root_path().to_string_lossy().to_string(),
9191
files: files_map,

engine/language_server/src/server/api/requests/execute_command.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::time::Duration;
22

33
use lsp_server::ErrorCode;
44
use lsp_types::{request, ExecuteCommandParams, MessageType};
5-
use playground_server::{FrontendMessage, PreSendToWasmMessage};
5+
use playground_server::{FrontendMessage, PreLangServerToWasmMessage};
66
use tokio::time::sleep;
77
use webbrowser;
88

@@ -37,7 +37,7 @@ impl SyncRequestHandler for ExecuteCommand {
3737
// Get the actual playground port from session (determined by server after availability check)
3838
// Fall back to configured port if actual port not set yet
3939

40-
use playground_server::{FrontendMessage, PreSendToWasmMessage};
40+
use playground_server::{FrontendMessage, PreLangServerToWasmMessage};
4141

4242
// Construct the URL
4343
let url = format!("http://localhost:{}", session.playground_port);
@@ -63,7 +63,7 @@ impl SyncRequestHandler for ExecuteCommand {
6363
{
6464
session
6565
.playground_tx
66-
.send(PreSendToWasmMessage::FrontendMessage(
66+
.send(PreLangServerToWasmMessage::FrontendMessage(
6767
FrontendMessage::select_function {
6868
// TODO: this can't be correct... but it looks like it is
6969
root_path: function_name.to_string(),
@@ -85,7 +85,7 @@ impl SyncRequestHandler for ExecuteCommand {
8585
Ok(RegisteredCommands::OpenBamlPanel(args)) => {
8686
session
8787
.playground_tx
88-
.send(PreSendToWasmMessage::FrontendMessage(
88+
.send(PreLangServerToWasmMessage::FrontendMessage(
8989
FrontendMessage::select_function {
9090
// TODO: this can't be correct... but it looks like it is
9191
root_path: args.project_id,
@@ -97,7 +97,7 @@ impl SyncRequestHandler for ExecuteCommand {
9797
Ok(RegisteredCommands::RunTest(args)) => {
9898
session
9999
.playground_tx
100-
.send(PreSendToWasmMessage::FrontendMessage(
100+
.send(PreLangServerToWasmMessage::FrontendMessage(
101101
FrontendMessage::run_test {
102102
function_name: args.function_name,
103103
test_name: args.test_case_name,

engine/language_server/src/server/api/requests/go_to_definition.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use lsp_types::{
44
self, request as req, GotoDefinitionParams, GotoDefinitionResponse, Location, Position, Range,
55
Url,
66
};
7-
use playground_server::{FrontendMessage, PreSendToWasmMessage};
7+
use playground_server::{FrontendMessage, PreLangServerToWasmMessage};
88

99
use crate::{
1010
baml_project::{position_utils::get_word_at_position, trim_line, BamlRuntimeExt},
@@ -116,7 +116,7 @@ impl SyncRequestHandler for GotoDefinition {
116116
if let Err(e) =
117117
session
118118
.playground_tx
119-
.send(PreSendToWasmMessage::FrontendMessage(
119+
.send(PreLangServerToWasmMessage::FrontendMessage(
120120
FrontendMessage::select_function {
121121
root_path: guard.root_path().to_string_lossy().to_string(),
122122
function_name: function.name.clone(),

engine/language_server/src/session.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use index::DocumentController;
1313
use itertools::any;
1414
use lsp_types::{ClientCapabilities, TextDocumentContentChangeEvent, Url};
1515
use parking_lot::Mutex;
16-
use playground_server::{FrontendMessage, PreSendToWasmMessage};
16+
use playground_server::{FrontendMessage, PreLangServerToWasmMessage};
1717
use serde_json::Value;
1818

1919
pub(crate) use self::{capabilities::ResolvedClientCapabilities, settings::AllSettings};
@@ -57,7 +57,7 @@ pub struct Session {
5757
pub baml_settings: BamlSettings,
5858

5959
pub playground_port: u16,
60-
pub playground_tx: broadcast::Sender<PreSendToWasmMessage>,
60+
pub playground_tx: broadcast::Sender<PreLangServerToWasmMessage>,
6161
}
6262

6363
impl Clone for Session {
@@ -82,7 +82,7 @@ impl Session {
8282
workspace_folders: &[(Url, ClientSettings)],
8383
runtime_handle: tokio::runtime::Handle,
8484
playground_port: u16,
85-
playground_tx: broadcast::Sender<PreSendToWasmMessage>,
85+
playground_tx: broadcast::Sender<PreLangServerToWasmMessage>,
8686
client_version: Option<String>,
8787
) -> anyhow::Result<Self> {
8888
let mut projects = HashMap::new();

engine/playground-server/src/bin/playground_barebones.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use playground_server::{
22
pick_ports, PortConfiguration, PlaygroundServer, AppState,
3-
LangServerToWasmMessage, FrontendMessage, PreSendToWasmMessage,
3+
LangServerToWasmMessage, FrontendMessage, PreLangServerToWasmMessage,
44
};
55
use std::collections::HashMap;
66
use tokio::io::AsyncBufReadExt;
@@ -66,7 +66,7 @@ pub async fn run_server() -> anyhow::Result<()> {
6666
while let Ok(msg) = playground_rx.recv().await {
6767
tracing::info!("Received message from playground: {:?}", msg);
6868
match msg {
69-
PreSendToWasmMessage::Initialized => {
69+
PreLangServerToWasmMessage::WasmIsInitialized => {
7070
tracing::info!("Playground initialized");
7171
let _ = broadcast_tx.send(LangServerToWasmMessage::PlaygroundMessage(
7272
FrontendMessage::add_project {
@@ -84,7 +84,7 @@ pub async fn run_server() -> anyhow::Result<()> {
8484
tracing::info!("Sending playground message: {:?}", playground_message);
8585
let _ = broadcast_tx.send(playground_message);
8686
}
87-
PreSendToWasmMessage::FrontendMessage(msg) => {
87+
PreLangServerToWasmMessage::FrontendMessage(msg) => {
8888
tracing::info!("Received frontend message: {:?}", msg);
8989
}
9090
}

engine/playground-server/src/definitions.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::collections::HashMap;
2+
23
use serde::{Deserialize, Serialize};
34

45
// Note: the name add_project should match exactly to the
@@ -29,8 +30,8 @@ pub enum FrontendMessage {
2930

3031
#[derive(Debug, Clone)]
3132
/// for lang-server internal comms, before sending out to the playground
32-
pub enum PreSendToWasmMessage {
33-
Initialized,
33+
pub enum PreLangServerToWasmMessage {
34+
WasmIsInitialized,
3435
FrontendMessage(FrontendMessage),
3536
}
3637

@@ -41,4 +42,4 @@ pub enum LangServerToWasmMessage {
4142
PlaygroundMessage(FrontendMessage),
4243
}
4344

44-
// Default type for backward compatibility - removed since we no longer use generics
45+
// Default type for backward compatibility - removed since we no longer use generics

engine/playground-server/src/handlers/websocket_rpc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use futures::{SinkExt, StreamExt};
66

77
use serde_json::Value;
88

9-
use crate::{definitions::PreSendToWasmMessage, server::AppState};
9+
use crate::{definitions::PreLangServerToWasmMessage, server::AppState};
1010

1111
pub async fn ws_rpc_handler(
1212
ws: WebSocketUpgrade,
@@ -34,7 +34,7 @@ pub async fn handle_rpc_websocket(ws: axum::extract::ws::WebSocket, state: AppSt
3434
"rpcId": rpc_id,
3535
"data": { "ok": true }
3636
});
37-
if let Err(e) = state.playground_tx.send(PreSendToWasmMessage::Initialized)
37+
if let Err(e) = state.playground_tx.send(PreLangServerToWasmMessage::WasmIsInitialized)
3838
{
3939
tracing::error!("Failed to send INITIALIZED message to language-server: {e}");
4040
}

engine/playground-server/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ pub mod handlers;
33
pub mod port_picker;
44
pub mod server;
55

6-
pub use definitions::{FrontendMessage, PreSendToWasmMessage, LangServerToWasmMessage};
6+
pub use definitions::{FrontendMessage, LangServerToWasmMessage, PreLangServerToWasmMessage};
7+
pub use port_picker::{pick_ports, PortConfiguration, PortPicks};
78
pub use server::{AppState, PlaygroundServer};
8-
pub use port_picker::{PortPicks, PortConfiguration, pick_ports};

0 commit comments

Comments
 (0)