Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 23 additions & 71 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/clarinet-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ nix = "0.29.0"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
clap = { version = "4.4.8", features = ["derive"] }
clap_complete = { version = "4.4.4" }
tower-lsp = { version = "0.19.0" }
tower-lsp-server = { version = "0.22.0" }
segment = { version = "0.2.4", optional = true }
mac_address = { version = "1.1.2", optional = true }

Expand Down
8 changes: 4 additions & 4 deletions components/clarinet-cli/src/lsp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use clarity_repl::clarity::vm::diagnostic::{
Diagnostic as ClarityDiagnostic, Level as ClarityLevel,
};
use crossbeam_channel::unbounded;
use tower_lsp::lsp_types::{Diagnostic, DiagnosticSeverity, Position, Range};
use tower_lsp::{LspService, Server};
use tower_lsp_server::lsp_types::{Diagnostic, DiagnosticSeverity, Position, Range};
use tower_lsp_server::{LspService, Server};

use self::native_bridge::LspNativeBridge;

Expand Down Expand Up @@ -50,7 +50,7 @@ async fn do_run_lsp() -> Result<(), String> {

pub fn clarity_diagnostics_to_tower_lsp_type(
diagnostics: &[ClarityDiagnostic],
) -> Vec<tower_lsp::lsp_types::Diagnostic> {
) -> Vec<tower_lsp_server::lsp_types::Diagnostic> {
diagnostics
.iter()
.map(clarity_diagnostic_to_tower_lsp_type)
Expand All @@ -59,7 +59,7 @@ pub fn clarity_diagnostics_to_tower_lsp_type(

pub fn clarity_diagnostic_to_tower_lsp_type(
diagnostic: &ClarityDiagnostic,
) -> tower_lsp::lsp_types::Diagnostic {
) -> tower_lsp_server::lsp_types::Diagnostic {
let range = match diagnostic.spans.len() {
0 => Range::default(),
_ => Range {
Expand Down
11 changes: 5 additions & 6 deletions components/clarinet-cli/src/lsp/native_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use clarity_lsp::lsp_types::{
use clarity_lsp::state::EditorState;
use crossbeam_channel::{Receiver as MultiplexableReceiver, Select, Sender as MultiplexableSender};
use serde_json::Value;
use tower_lsp::jsonrpc::{Error, ErrorCode, Result};
use tower_lsp::lsp_types::{
use tower_lsp_server::jsonrpc::{Error, ErrorCode, Result};
use tower_lsp_server::lsp_types::{
CompletionParams, CompletionResponse, DidChangeTextDocumentParams, DidCloseTextDocumentParams,
DidOpenTextDocumentParams, DidSaveTextDocumentParams, DocumentFormattingParams,
DocumentRangeFormattingParams, ExecuteCommandParams, Hover, HoverParams, InitializeParams,
InitializeResult, InitializedParams, MessageType, TextEdit, Url,
InitializeResult, InitializedParams, MessageType, TextEdit,
};
use tower_lsp::{async_trait, Client, LanguageServer};
use tower_lsp_server::{Client, LanguageServer};

use super::utils;
use crate::lsp::clarity_diagnostics_to_tower_lsp_type;
Expand Down Expand Up @@ -114,7 +114,7 @@ impl LspNativeBridge {
if let Ok(url) = location.to_url_string() {
self.client
.publish_diagnostics(
Url::parse(&url).unwrap(),
url.parse().expect("Failed to parse URL"),
clarity_diagnostics_to_tower_lsp_type(&diags),
None,
)
Expand All @@ -128,7 +128,6 @@ impl LspNativeBridge {
}
}

#[async_trait]
impl LanguageServer for LspNativeBridge {
async fn initialize(&self, params: InitializeParams) -> Result<InitializeResult> {
let _ = match self.request_tx.lock() {
Expand Down
2 changes: 1 addition & 1 deletion components/clarinet-files/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ serde = "1"
serde_derive = "1"
serde_json = "1.0.114"
toml = { workspace = true }
url = { version = "2.2.2", features = ["serde"] }
url = { version = "2.5.4", features = ["serde"] }

clarity = { workspace = true }
clarinet-utils = { version = "1", path = "../clarinet-utils" }
Expand Down
33 changes: 7 additions & 26 deletions components/clarinet-files/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,6 @@ impl fmt::Display for FileLocation {
}
}

impl TryInto<Url> for &FileLocation {
type Error = &'static str;

fn try_into(self) -> Result<Url, Self::Error> {
match self {
#[cfg(target_arch = "wasm32")]
FileLocation::FileSystem { .. } => {
Err("Url::from_file_path() not available on target architecture")
}
#[cfg(not(target_arch = "wasm32"))]
FileLocation::FileSystem { path } => {
Url::from_file_path(path).map_err(|()| "Url::from_file_path() failed")
}
FileLocation::Url { url } => Ok(url.clone()),
}
}
}

impl FileLocation {
pub fn try_parse(
location_string: &str,
Expand Down Expand Up @@ -367,16 +349,15 @@ impl FileLocation {

pub fn to_url_string(&self) -> Result<String, String> {
match self {
#[cfg(not(target_arch = "wasm32"))]
FileLocation::FileSystem { path } => {
let file_path = self.to_string();
let url = Url::from_file_path(file_path)
.map_err(|_| format!("unable to conver path {} to url", path.display()))?;
Ok(url.to_string())
#[cfg(target_arch = "wasm32")]
FileLocation::FileSystem { .. } => {
Err("Url::from_file_path is not supported in wasm32".to_string())
}
#[cfg(not(target_arch = "wasm32"))]
FileLocation::FileSystem { path } => Url::from_file_path(path)
.map_err(|_| format!("unable to convert path {} to url", path.display()))
.map(String::from),
FileLocation::Url { url } => Ok(url.to_string()),
#[allow(unreachable_patterns)]
_ => unreachable!(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/clarity-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version.workspace = true
edition = "2021"

[dependencies]
lsp-types = "0.94.0"
lsp-types = "0.97.0"
regex = "1.7"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
Expand Down
Loading
Loading