Working goto request
This commit is contained in:
@@ -217,52 +217,26 @@ impl LanguageServer for Backend {
|
|||||||
|
|
||||||
source = insert_at_position(
|
source = insert_at_position(
|
||||||
&source,
|
&source,
|
||||||
params.text_document_position_params.position.line as usize,
|
params.text_document_position_params.position.line as usize + 1,
|
||||||
params.text_document_position_params.position.character as usize,
|
params.text_document_position_params.position.character as usize,
|
||||||
&inject,
|
&inject,
|
||||||
);
|
);
|
||||||
|
|
||||||
let output = transpiler::transpile_text(&source).expect("Failed to transpile");
|
let output = transpiler::transpile_text(&source).expect("Failed to transpile");
|
||||||
|
|
||||||
let position = output
|
|
||||||
.find(inject)
|
|
||||||
.expect("Didn't find injection")
|
|
||||||
.saturating_sub(1);
|
|
||||||
|
|
||||||
let (line, character) = find_row_col(&output, inject).unwrap();
|
let (line, character) = find_row_col(&output, inject).unwrap();
|
||||||
|
|
||||||
self.client
|
|
||||||
.log_message(MessageType::INFO, format!("Found at {position}"))
|
|
||||||
.await;
|
|
||||||
|
|
||||||
let uri =
|
let uri =
|
||||||
Url::from_file_path(from_mist_to_rust(file_path)).expect("failed to generate rs url");
|
Url::from_file_path(from_mist_to_rust(file_path)).expect("failed to generate rs url");
|
||||||
|
|
||||||
self.rust_analyzer
|
let rs_res = self
|
||||||
.lock()
|
|
||||||
.await
|
|
||||||
.notify(
|
|
||||||
"textDocument/didOpen",
|
|
||||||
DidOpenTextDocumentParams {
|
|
||||||
text_document: TextDocumentItem {
|
|
||||||
uri: uri.clone(),
|
|
||||||
language_id: "rust".into(),
|
|
||||||
version: 1,
|
|
||||||
text: output,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.expect("Failed to init req");
|
|
||||||
|
|
||||||
let res = self
|
|
||||||
.rust_analyzer
|
.rust_analyzer
|
||||||
.lock()
|
.lock()
|
||||||
.await
|
.await
|
||||||
.request::<request::GotoDefinition>(lsp_types::GotoDefinitionParams {
|
.request::<request::GotoDefinition>(lsp_types::GotoDefinitionParams {
|
||||||
text_document_position_params: lsp_types::TextDocumentPositionParams {
|
text_document_position_params: lsp_types::TextDocumentPositionParams {
|
||||||
position: lsp_types::Position {
|
position: lsp_types::Position {
|
||||||
line: line as u32,
|
line: line as u32 - 1,
|
||||||
character: character as u32,
|
character: character as u32,
|
||||||
},
|
},
|
||||||
text_document: lsp_types::TextDocumentIdentifier { uri },
|
text_document: lsp_types::TextDocumentIdentifier { uri },
|
||||||
@@ -273,9 +247,7 @@ impl LanguageServer for Backend {
|
|||||||
.await
|
.await
|
||||||
.expect("Failed to send to rust");
|
.expect("Failed to send to rust");
|
||||||
|
|
||||||
self.client
|
eprintln!("{:?}", rs_res);
|
||||||
.log_message(MessageType::INFO, format!("OUTPUT: {:?}", res))
|
|
||||||
.await;
|
|
||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use tower_lsp::lsp_types::{
|
|||||||
request::{self, Request},
|
request::{self, Request},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct JsonRpcResponse<T> {
|
pub struct JsonRpcResponse<T> {
|
||||||
pub jsonrpc: String,
|
pub jsonrpc: String,
|
||||||
pub id: Option<usize>,
|
pub id: Option<usize>,
|
||||||
|
|||||||
Reference in New Issue
Block a user