#![forbid(unsafe_code)]
pub use shipwright_host::{
resolve, DeferredCheck, DotnetToolConfig, EnvConfig, ErrorCode, ErrorDetails, PkgmgrConfig,
Platform, ProbedVersion, PromptAction, Resolution, ResolveInput, Source, Status, WarningCode,
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LspServerInfo<'a> {
pub name: &'a str,
pub version: &'a str,
}
#[must_use]
pub fn deferred_lsp_resolution(source: Source, command_path: impl Into<String>) -> Resolution {
Resolution::deferred(source, command_path.into(), DeferredCheck::LspInitialize)
}
#[must_use]
pub fn verify_lsp_server_info(
component_id: &str,
expected_version: &str,
server_info: Option<LspServerInfo<'_>>,
) -> Resolution {
match server_info {
Some(info) if info.name != component_id => {
Resolution::error(ErrorCode::BinaryNameMismatch, None)
}
Some(info) if info.version == expected_version => Resolution::ok(
Source::LspInitialize,
component_id.to_string(),
info.version.to_string(),
),
Some(info) => Resolution::error(
ErrorCode::NoSourceResolved,
Some(ErrorDetails {
expected: expected_version.to_string(),
found: info.version.to_string(),
at: component_id.to_string(),
}),
),
None => Resolution::error(
ErrorCode::NoSourceResolved,
Some(ErrorDetails {
expected: expected_version.to_string(),
found: String::new(),
at: component_id.to_string(),
}),
),
}
}