Introduce a LanguageServerId wrapper type
Clarify the meaning of all the usizes in use in all of these struct fields an method signatures.
This commit is contained in:
parent
c5f86bc6af
commit
4dd917c123
16 changed files with 166 additions and 117 deletions
|
@ -4,7 +4,7 @@ use crate::{
|
|||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use clock::ReplicaId;
|
||||
use lsp::DiagnosticSeverity;
|
||||
use lsp::{DiagnosticSeverity, LanguageServerId};
|
||||
use rpc::proto;
|
||||
use std::{ops::Range, sync::Arc};
|
||||
use text::*;
|
||||
|
@ -80,7 +80,7 @@ pub fn serialize_operation(operation: &crate::Operation) -> proto::Operation {
|
|||
} => proto::operation::Variant::UpdateDiagnostics(proto::UpdateDiagnostics {
|
||||
replica_id: lamport_timestamp.replica_id as u32,
|
||||
lamport_timestamp: lamport_timestamp.value,
|
||||
server_id: *server_id as u64,
|
||||
server_id: server_id.0 as u64,
|
||||
diagnostics: serialize_diagnostics(diagnostics.iter()),
|
||||
}),
|
||||
|
||||
|
@ -277,7 +277,7 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<crate::Operati
|
|||
replica_id: message.replica_id as ReplicaId,
|
||||
value: message.lamport_timestamp,
|
||||
},
|
||||
server_id: message.server_id as usize,
|
||||
server_id: LanguageServerId(message.server_id as usize),
|
||||
diagnostics: deserialize_diagnostics(message.diagnostics),
|
||||
}
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ pub async fn deserialize_completion(
|
|||
|
||||
pub fn serialize_code_action(action: &CodeAction) -> proto::CodeAction {
|
||||
proto::CodeAction {
|
||||
server_id: action.server_id as u64,
|
||||
server_id: action.server_id.0 as u64,
|
||||
start: Some(serialize_anchor(&action.range.start)),
|
||||
end: Some(serialize_anchor(&action.range.end)),
|
||||
lsp_action: serde_json::to_vec(&action.lsp_action).unwrap(),
|
||||
|
@ -487,7 +487,7 @@ pub fn deserialize_code_action(action: proto::CodeAction) -> Result<CodeAction>
|
|||
.ok_or_else(|| anyhow!("invalid end"))?;
|
||||
let lsp_action = serde_json::from_slice(&action.lsp_action)?;
|
||||
Ok(CodeAction {
|
||||
server_id: action.server_id as usize,
|
||||
server_id: LanguageServerId(action.server_id as usize),
|
||||
range: start..end,
|
||||
lsp_action,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue