cairo_language_server/lsp/
ext.rs1use std::path::PathBuf;
4
5use lsp_types::notification::Notification;
6use lsp_types::request::Request;
7use lsp_types::{TextDocumentPositionParams, Url};
8use serde::{Deserialize, Serialize};
9
10pub struct ProvideVirtualFile;
12
13#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
14pub struct ProvideVirtualFileRequest {
15 pub uri: Url,
16}
17
18#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Serialize)]
19pub struct ProvideVirtualFileResponse {
20 pub content: Option<String>,
21}
22
23impl Request for ProvideVirtualFile {
24 type Params = ProvideVirtualFileRequest;
25 type Result = ProvideVirtualFileResponse;
26 const METHOD: &'static str = "vfs/provide";
27}
28
29pub struct ViewAnalyzedCrates;
31
32impl Request for ViewAnalyzedCrates {
33 type Params = ();
34 type Result = String;
35 const METHOD: &'static str = "cairo/viewAnalyzedCrates";
36}
37
38pub struct ExpandMacro;
40
41impl Request for ExpandMacro {
42 type Params = TextDocumentPositionParams;
43 type Result = Option<String>;
44 const METHOD: &'static str = "cairo/expandMacro";
45}
46
47#[derive(Debug)]
49pub struct CorelibVersionMismatch;
50
51impl Notification for CorelibVersionMismatch {
52 type Params = String;
53 const METHOD: &'static str = "cairo/corelib-version-mismatch";
54}
55
56#[derive(Debug)]
58pub struct ToolchainInfo;
59
60#[derive(Serialize, Deserialize)]
61pub struct PathAndVersion {
62 pub path: PathBuf,
63 pub version: String,
64}
65
66#[derive(Serialize, Deserialize)]
67pub struct ToolchainInfoResponse {
68 pub ls: PathAndVersion,
69 pub scarb: Option<PathAndVersion>,
70}
71
72impl Request for ToolchainInfo {
73 type Params = ();
74 type Result = ToolchainInfoResponse;
75 const METHOD: &'static str = "cairo/toolchainInfo";
76}
77
78pub struct ViewSyntaxTree;
79
80impl Request for ViewSyntaxTree {
81 type Params = TextDocumentPositionParams;
82 type Result = Option<String>;
83 const METHOD: &'static str = "cairo/viewSyntaxTree";
84}
85
86#[cfg(feature = "testing")]
87pub mod testing {
88 use lsp_types::notification::Notification;
89
90 #[derive(Debug)]
92 pub struct ProjectUpdatingFinished;
93
94 impl Notification for ProjectUpdatingFinished {
95 type Params = ();
96 const METHOD: &'static str = "cairo/projectUpdatingFinished";
97 }
98}
99
100#[derive(Debug)]
102pub struct ServerStatus;
103
104impl Notification for ServerStatus {
105 type Params = ServerStatusParams;
106 const METHOD: &'static str = "cairo/serverStatus";
107}
108
109#[derive(Serialize, Deserialize, PartialEq)]
110pub enum ServerStatusEvent {
111 AnalysisStarted,
112 AnalysisFinished,
113}
114
115#[derive(Serialize, Deserialize)]
116#[serde(rename_all = "camelCase")]
117pub struct ServerStatusParams {
118 pub event: ServerStatusEvent,
119 pub idle: bool,
120}
121
122#[derive(Debug)]
123pub struct ScarbPathMissing {}
124
125impl Notification for ScarbPathMissing {
126 type Params = ();
127 const METHOD: &'static str = "scarb/could-not-find-scarb-executable";
128}
129
130#[derive(Debug)]
131pub struct ExecuteInTerminal {}
132
133#[derive(Debug, Serialize, Deserialize, PartialEq)]
134pub struct ExecuteInTerminalParams {
135 pub command: String,
136 pub cwd: PathBuf,
137}
138
139impl Notification for ExecuteInTerminal {
140 type Params = ExecuteInTerminalParams;
141 const METHOD: &'static str = "cairo/executeInTerminal";
142}
143
144pub struct ShowMemoryUsage;
145
146impl Request for ShowMemoryUsage {
147 type Params = ();
148 type Result = serde_json::Value;
149 const METHOD: &'static str = "cairo/showMemoryUsage";
150}