11use crate :: server:: Server ;
22use fingerprint:: COMPILER_BUILT_AT ;
3+ use fluent_uri:: Uri ;
34use ipc_message:: {
45 GenericRequestId , IpcMessage , IpcMessageId , IpcNotification , IpcRequest , IpcResponse ,
56} ;
67use request:: { Cache , PfIn , Req , Rt , RtStIn , TimeoutAfterSteps , UnwrapAft , WithErrors } ;
78use smol:: {
89 io:: { self , AsyncWriteExt , BufReader , BufWriter } ,
10+ lock:: Mutex ,
911 net:: TcpStream ,
1012 stream:: StreamExt ,
1113} ;
12- use std:: { num:: NonZero , pin:: pin} ;
14+ use std:: { collections :: HashMap , num:: NonZero , pin:: pin, sync :: Arc } ;
1315use transport:: { read_message_raw_async, write_message_raw_async} ;
1416
17+ #[ derive( Default ) ]
18+ pub struct LanguageClient {
19+ pub documents : Mutex < HashMap < Uri < String > , Document > > ,
20+ }
21+
22+ #[ derive( Clone , Debug ) ]
23+ pub struct Document {
24+ pub content : String ,
25+ }
26+
1527impl Server {
1628 pub async fn serve ( & self , mut stream : TcpStream ) -> io:: Result < ( ) > {
1729 let idle_tracker = self . idle_tracker . clone ( ) ;
1830 let stream_writer = stream. clone ( ) ;
31+ let client = Arc :: new ( LanguageClient :: default ( ) ) ;
1932
2033 // Channel for sending requests off to be processed
2134 let ( tx_req, rx_req) =
@@ -52,8 +65,6 @@ impl Server {
5265 } ) ;
5366 break ;
5467 }
55- IpcRequest :: DidChange ( ipc_file, text_edits) => todo ! ( ) ,
56- IpcRequest :: DidSave ( ipc_file) => todo ! ( ) ,
5768 IpcRequest :: Completion ( text_position) => request:: ListSymbols . into ( ) ,
5869 IpcRequest :: Diagnostics ( ipc_file) => todo ! ( ) ,
5970 } ;
@@ -75,8 +86,6 @@ impl Server {
7586 match ipc_request {
7687 IpcRequest :: Initialize { .. } => unreachable ! ( ) ,
7788 IpcRequest :: Shutdown => unreachable ! ( ) ,
78- IpcRequest :: DidChange ( ipc_file, text_edits) => todo ! ( ) ,
79- IpcRequest :: DidSave ( ipc_file) => todo ! ( ) ,
8089 IpcRequest :: Completion ( _text_position) => {
8190 let WithErrors { value : names, .. } = request:: ListSymbols :: unwrap_aft ( aft) ;
8291
@@ -139,6 +148,15 @@ impl Server {
139148 let writer = pin ! ( BufWriter :: new( & mut stream) ) ;
140149 write_message_raw_async ( writer, & content) . await ?;
141150 }
151+ IpcMessage :: Notification ( _, IpcNotification :: DidChange ( ipc_file, edits) ) => {
152+ todo ! ( "daemon: notif {:?} {:?}" , ipc_file, edits)
153+ }
154+ IpcMessage :: Notification ( _, IpcNotification :: DidOpen ( ..) ) => {
155+ todo ! ( "daemon: did open" )
156+ }
157+ IpcMessage :: Notification ( _, IpcNotification :: DidSave ( ..) ) => {
158+ todo ! ( "daemon: did save" )
159+ }
142160 IpcMessage :: Notification ( _, IpcNotification :: Exit ) => {
143161 eprintln ! ( "daemon: Exit requested..." ) ;
144162 break ;
@@ -155,6 +173,7 @@ impl Server {
155173 eprintln ! ( "daemon: Closing language server connection..." ) ;
156174 tx_req. close ( ) ;
157175 thread. join ( ) . unwrap ( ) ;
176+ eprintln ! ( "daemon: Closed language server connection..." ) ;
158177 Ok ( ( ) )
159178 }
160179}
0 commit comments