1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#![allow(unused_variables)]
use super::*;
use anyhow::Result;
use serde_json::Value;

pub trait BuildServer {
    /// Invoked when client sends server "build/initialize"
    ///
    /// The initialize request is sent as the first request from the client to the server. If the
    /// server receives a request or notification before the initialize request it should act as
    /// follows:
    ///
    /// - For a request the response should be an error with code: -32002. The message can be
    /// picked by the server.
    ///
    /// - Notifications should be dropped, except for the exit notification. This will allow the
    /// exit of a server without an initialize request.
    ///
    /// Until the server has responded to the initialize request with an [`InitializeBuildResult`],
    /// the client must not send any additional requests or notifications to the server.
    // #[rpc(name = "build/initialize")]
    fn initialize(&self, params: InitializeBuild) -> Result<InitializeBuildResult>;

    /// Invoked when client sends server "build/initialized"
    ///
    /// A notification is sent from the client to the server after the client received the result
    /// of the initialize request but before the client is sending any other request or
    /// notification to the server. The server can use the initialized notification for example to
    /// initialize intensive computation such as dependency resolution or compilation. The
    /// initialized notification may only be sent once.
    // #[rpc(name = "build/initialized")]
    fn on_initializtion(&self) {}

    /// Invoked when client sends server "build/shutdown"
    ///
    /// The shutdown build request is sent from the client to the server. It asks the server to
    /// shut down, but to not exit (otherwise the response might not be delivered correctly to the
    /// client). There is a separate exit notification that asks the server to exit.
    // #[rpc(name = "build/shutdown")]
    fn build_shutdown(&self) -> Result<Option<Value>> {
        Ok(None)
    }

    /// Invoked when client sends server "build/exit"
    ///
    /// A notification to ask the server to exit its process. The server should exit with success
    /// code 0 if the shutdown request has been received before;
    /// otherwise with error code 1.
    // #[rpc(name = "build/exit")]
    fn on_build_exit(&self) {}

    /// Invoked when client sends server "workspace/buildTargets"
    ///
    /// The workspace build targets request is sent from the client to the server to ask for the
    /// list of all available build targets in the workspace.
    // #[rpc(name = "workspace/buildTargets")]
    fn workspace_bts(&self) -> Result<WorkspaceBuildTargetsResult> {
        Ok(WorkspaceBuildTargetsResult::default())
    }

    /// Invoked when client sends server "workspace/reload"
    ///
    // The reload request is sent from the client to instruct the build server to reload the build
    // configuration. This request should be supported by build tools that keep their state in memory.
    // If the reload request returns with an error, it's expected that other requests respond with the
    // previously known "good" state.
    // #[rpc(name = "workspace/reload")]
    fn workspace_reload(&self) -> Result<Option<Value>> {
        Ok(None)
    }

    /// Invoked when client sends server "buildTarget/dependencyModules"
    ///
    /// The build target dependency modules request is sent from the client to the server to query for the
    /// libraries of build target dependencies that are external to the workspace including meta
    /// information about library and their sources. It's an extended version of buildTarget/sources.
    // #[rpc(name = "buildTarget/dependencyModules")]
    fn bt_dependency_modules(
        &self,
        params: BuildTargetDependencyModules,
    ) -> Result<BuildTargetDependencyModulesResult> {
        todo!()
        // Err(Error::method_not_found())
    }

    /// Invoked when client sends server "buildTarget/dependencyModules"
    ///
    /// The debug request is sent from the client to the server to debug build target(s). The server
    /// launches a Microsoft DAP server and returns a connection URI for the client to interact with.
    // #[rpc(name = "debugSession/start")]
    fn debug_session_start(&self, params: DebugSessionStart) -> Result<DebugSessionStartResult> {
        todo!()
        // Err(Error::method_not_found())
    }

    /// Invoked when client sends server "buildTarget/sources"
    ///
    /// The build target sources request is sent from the client to the server to
    /// query for the list of text documents and directories that are belong to a
    /// build target. The sources response must not include sources that are
    /// external to the workspace.
    // #[rpc(name = "buildTarget/sources")]
    fn bt_sources(&self, params: BuildTargetSources) -> Result<BuildTargetSourcesResult> {
        Ok(BuildTargetSourcesResult::default())
    }

    /// Invoked when client sends server "buildTarget/inverseSources"
    // #[rpc(name = "buildTarget/sources")]
    fn bt_inverse_sources(
        &self,
        params: TextDocumentInverseSources,
    ) -> Result<BuildTargetInverseSourcesResult> {
        Ok(BuildTargetInverseSourcesResult::default())
    }

    /// Invoked when client sends server "buildTarget/dependencySources"
    ///
    /// The inverse sources request is sent from the client to the server to query for the list of
    /// build targets containing a text document. The server communicates during the initialize
    /// handshake whether this method is supported or not. This request can be viewed as the inverse of
    /// buildTarget/sources, except it only works for text documents and not directories.
    // #[rpc(name = "buildTarget/dependencySources")]
    fn bt_dependency_sources(
        &self,
        params: BuildTargetDependencySources,
    ) -> Result<BuildTargetDependencySourcesResult> {
        Ok(BuildTargetDependencySourcesResult::default())
    }

    /// Invoked when client sends server "buildTarget/resources"
    ///
    /// The build target resources request is sent from the client to the server to query for the list
    /// of resources of a given list of build targets.
    ///
    /// A resource is a data dependency required to be present in the runtime classpath when a build
    /// target is run or executed. The server communicates during the initialize handshake whether this
    /// method is supported or not.
    ///
    /// This request can be used by a client to highlight the resources in a project view, for example.
    // #[rpc(name = "buildTarget/resources")]
    fn bt_resources(&self, params: BuildTargetResources) -> Result<BuildTargetResourcesResult> {
        Ok(BuildTargetResourcesResult::default())
    }

    /// Invoked when client sends server "buildTarget/run"
    ///
    /// The run request is sent from the client to the server to run a build target. The server
    /// communicates during the initialize handshake whether this method is supported or not.
    // #[rpc(name = "buildTarget/run")]
    fn bt_run(&self, params: BuildTargetRun) -> Result<BuildTargetRunResult> {
        todo!()
        // Err(Error::method_not_found())
    }

    /// Invoked when client sends server "buildTarget/compile"
    ///
    /// The run request is sent from the client to the server to run a build target. The server
    /// communicates during the initialize handshake whether this method is supported or not.
    // #[rpc(name = "buildTarget/compile")]
    fn bt_compile(&self, params: BuildTargetCompile) -> Result<BuildTargetCompileResult> {
        todo!()
        // Err(Error::method_not_found())
    }

    /// Invoked when client sends server "buildTarget/test"
    ///
    /// The test build target request is sent from the client to the server to test the given list of
    /// build targets. The server communicates during the initialize handshake whether this method is
    /// supported or not.
    // #[rpc(name = "buildTarget/test")]
    fn bt_test(&self, params: BuildTargetTest) -> Result<BuildTargetTestResult> {
        todo!()
        // Err(Error::method_not_found())
    }

    /// Invoked when client sends server "buildTarget/cleanCache"
    ///
    /// The clean cache request is sent from the client to the server to reset any state associated with
    /// a given build target. The state can live either in the build tool or in the file system.
    ///
    /// The build tool defines the exact semantics of the clean cache request:
    ///
    /// Stateless build tools are free to ignore the request and respond with a successful response.
    /// Stateful build tools must ensure that invoking compilation on a target that has been cleaned
    /// results in a full compilation.
    // #[rpc(name = "buildTarget/cleanCache")]
    fn bt_clean_cache(&self, params: BuildTargetCleanCache) -> Result<BuildTargetCleanCacheResult> {
        todo!()
        // Err(Error::method_not_found())
    }
}