1#![forbid(unsafe_code)]
9
10pub use shipwright_host::{
11 resolve, DeferredCheck, DotnetToolConfig, EnvConfig, ErrorCode, ErrorDetails, PkgmgrConfig,
12 Platform, ProbedVersion, PromptAction, Resolution, ResolveInput, Source, Status, WarningCode,
13};
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub struct LspServerInfo<'a> {
18 pub name: &'a str,
20 pub version: &'a str,
22}
23
24#[must_use]
26pub fn deferred_lsp_resolution(source: Source, command_path: impl Into<String>) -> Resolution {
27 Resolution::deferred(source, command_path.into(), DeferredCheck::LspInitialize)
28}
29
30#[must_use]
32pub fn verify_lsp_server_info(
33 component_id: &str,
34 expected_version: &str,
35 server_info: Option<LspServerInfo<'_>>,
36) -> Resolution {
37 match server_info {
38 Some(info) if info.name != component_id => {
39 Resolution::error(ErrorCode::BinaryNameMismatch, None)
40 }
41 Some(info) if info.version == expected_version => Resolution::ok(
42 Source::LspInitialize,
43 component_id.to_string(),
44 info.version.to_string(),
45 ),
46 Some(info) => Resolution::error(
47 ErrorCode::NoSourceResolved,
48 Some(ErrorDetails {
49 expected: expected_version.to_string(),
50 found: info.version.to_string(),
51 at: component_id.to_string(),
52 }),
53 ),
54 None => Resolution::error(
55 ErrorCode::NoSourceResolved,
56 Some(ErrorDetails {
57 expected: expected_version.to_string(),
58 found: String::new(),
59 at: component_id.to_string(),
60 }),
61 ),
62 }
63}