bsp_types/
server.rs

1#![allow(unused_variables)]
2use super::*;
3use anyhow::Result;
4use serde_json::Value;
5
6pub trait BuildServer {
7    /// Invoked when client sends server "build/initialize"
8    ///
9    /// The initialize request is sent as the first request from the client to the server. If the
10    /// server receives a request or notification before the initialize request it should act as
11    /// follows:
12    ///
13    /// - For a request the response should be an error with code: -32002. The message can be
14    /// picked by the server.
15    ///
16    /// - Notifications should be dropped, except for the exit notification. This will allow the
17    /// exit of a server without an initialize request.
18    ///
19    /// Until the server has responded to the initialize request with an [`InitializeBuildResult`],
20    /// the client must not send any additional requests or notifications to the server.
21    // #[rpc(name = "build/initialize")]
22    fn initialize(&self, params: InitializeBuild) -> Result<InitializeBuildResult>;
23
24    /// Invoked when client sends server "build/initialized"
25    ///
26    /// A notification is sent from the client to the server after the client received the result
27    /// of the initialize request but before the client is sending any other request or
28    /// notification to the server. The server can use the initialized notification for example to
29    /// initialize intensive computation such as dependency resolution or compilation. The
30    /// initialized notification may only be sent once.
31    // #[rpc(name = "build/initialized")]
32    fn on_initializtion(&self) {}
33
34    /// Invoked when client sends server "build/shutdown"
35    ///
36    /// The shutdown build request is sent from the client to the server. It asks the server to
37    /// shut down, but to not exit (otherwise the response might not be delivered correctly to the
38    /// client). There is a separate exit notification that asks the server to exit.
39    // #[rpc(name = "build/shutdown")]
40    fn build_shutdown(&self) -> Result<Option<Value>> {
41        Ok(None)
42    }
43
44    /// Invoked when client sends server "build/exit"
45    ///
46    /// A notification to ask the server to exit its process. The server should exit with success
47    /// code 0 if the shutdown request has been received before;
48    /// otherwise with error code 1.
49    // #[rpc(name = "build/exit")]
50    fn on_build_exit(&self) {}
51
52    /// Invoked when client sends server "workspace/buildTargets"
53    ///
54    /// The workspace build targets request is sent from the client to the server to ask for the
55    /// list of all available build targets in the workspace.
56    // #[rpc(name = "workspace/buildTargets")]
57    fn workspace_bts(&self) -> Result<WorkspaceBuildTargetsResult> {
58        Ok(WorkspaceBuildTargetsResult::default())
59    }
60
61    /// Invoked when client sends server "workspace/reload"
62    ///
63    // The reload request is sent from the client to instruct the build server to reload the build
64    // configuration. This request should be supported by build tools that keep their state in memory.
65    // If the reload request returns with an error, it's expected that other requests respond with the
66    // previously known "good" state.
67    // #[rpc(name = "workspace/reload")]
68    fn workspace_reload(&self) -> Result<Option<Value>> {
69        Ok(None)
70    }
71
72    /// Invoked when client sends server "buildTarget/dependencyModules"
73    ///
74    /// The build target dependency modules request is sent from the client to the server to query for the
75    /// libraries of build target dependencies that are external to the workspace including meta
76    /// information about library and their sources. It's an extended version of buildTarget/sources.
77    // #[rpc(name = "buildTarget/dependencyModules")]
78    fn bt_dependency_modules(
79        &self,
80        params: BuildTargetDependencyModules,
81    ) -> Result<BuildTargetDependencyModulesResult> {
82        todo!()
83        // Err(Error::method_not_found())
84    }
85
86    /// Invoked when client sends server "buildTarget/dependencyModules"
87    ///
88    /// The debug request is sent from the client to the server to debug build target(s). The server
89    /// launches a Microsoft DAP server and returns a connection URI for the client to interact with.
90    // #[rpc(name = "debugSession/start")]
91    fn debug_session_start(&self, params: DebugSessionStart) -> Result<DebugSessionStartResult> {
92        todo!()
93        // Err(Error::method_not_found())
94    }
95
96    /// Invoked when client sends server "buildTarget/sources"
97    ///
98    /// The build target sources request is sent from the client to the server to
99    /// query for the list of text documents and directories that are belong to a
100    /// build target. The sources response must not include sources that are
101    /// external to the workspace.
102    // #[rpc(name = "buildTarget/sources")]
103    fn bt_sources(&self, params: BuildTargetSources) -> Result<BuildTargetSourcesResult> {
104        Ok(BuildTargetSourcesResult::default())
105    }
106
107    /// Invoked when client sends server "buildTarget/inverseSources"
108    // #[rpc(name = "buildTarget/sources")]
109    fn bt_inverse_sources(
110        &self,
111        params: TextDocumentInverseSources,
112    ) -> Result<BuildTargetInverseSourcesResult> {
113        Ok(BuildTargetInverseSourcesResult::default())
114    }
115
116    /// Invoked when client sends server "buildTarget/dependencySources"
117    ///
118    /// The inverse sources request is sent from the client to the server to query for the list of
119    /// build targets containing a text document. The server communicates during the initialize
120    /// handshake whether this method is supported or not. This request can be viewed as the inverse of
121    /// buildTarget/sources, except it only works for text documents and not directories.
122    // #[rpc(name = "buildTarget/dependencySources")]
123    fn bt_dependency_sources(
124        &self,
125        params: BuildTargetDependencySources,
126    ) -> Result<BuildTargetDependencySourcesResult> {
127        Ok(BuildTargetDependencySourcesResult::default())
128    }
129
130    /// Invoked when client sends server "buildTarget/resources"
131    ///
132    /// The build target resources request is sent from the client to the server to query for the list
133    /// of resources of a given list of build targets.
134    ///
135    /// A resource is a data dependency required to be present in the runtime classpath when a build
136    /// target is run or executed. The server communicates during the initialize handshake whether this
137    /// method is supported or not.
138    ///
139    /// This request can be used by a client to highlight the resources in a project view, for example.
140    // #[rpc(name = "buildTarget/resources")]
141    fn bt_resources(&self, params: BuildTargetResources) -> Result<BuildTargetResourcesResult> {
142        Ok(BuildTargetResourcesResult::default())
143    }
144
145    /// Invoked when client sends server "buildTarget/run"
146    ///
147    /// The run request is sent from the client to the server to run a build target. The server
148    /// communicates during the initialize handshake whether this method is supported or not.
149    // #[rpc(name = "buildTarget/run")]
150    fn bt_run(&self, params: BuildTargetRun) -> Result<BuildTargetRunResult> {
151        todo!()
152        // Err(Error::method_not_found())
153    }
154
155    /// Invoked when client sends server "buildTarget/compile"
156    ///
157    /// The run request is sent from the client to the server to run a build target. The server
158    /// communicates during the initialize handshake whether this method is supported or not.
159    // #[rpc(name = "buildTarget/compile")]
160    fn bt_compile(&self, params: BuildTargetCompile) -> Result<BuildTargetCompileResult> {
161        todo!()
162        // Err(Error::method_not_found())
163    }
164
165    /// Invoked when client sends server "buildTarget/test"
166    ///
167    /// The test build target request is sent from the client to the server to test the given list of
168    /// build targets. The server communicates during the initialize handshake whether this method is
169    /// supported or not.
170    // #[rpc(name = "buildTarget/test")]
171    fn bt_test(&self, params: BuildTargetTest) -> Result<BuildTargetTestResult> {
172        todo!()
173        // Err(Error::method_not_found())
174    }
175
176    /// Invoked when client sends server "buildTarget/cleanCache"
177    ///
178    /// The clean cache request is sent from the client to the server to reset any state associated with
179    /// a given build target. The state can live either in the build tool or in the file system.
180    ///
181    /// The build tool defines the exact semantics of the clean cache request:
182    ///
183    /// Stateless build tools are free to ignore the request and respond with a successful response.
184    /// Stateful build tools must ensure that invoking compilation on a target that has been cleaned
185    /// results in a full compilation.
186    // #[rpc(name = "buildTarget/cleanCache")]
187    fn bt_clean_cache(&self, params: BuildTargetCleanCache) -> Result<BuildTargetCleanCacheResult> {
188        todo!()
189        // Err(Error::method_not_found())
190    }
191}