Skip to content

Commit

Permalink
merge: #17 from astrodevs-labs/hotfix/slither-server-crash
Browse files Browse the repository at this point in the history
Slither Crash Hotfix
  • Loading branch information
0xSwapFeeder authored Apr 27, 2024
2 parents ac717c5 + 80451f0 commit b450c46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions servers/slither-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ struct Backend {
impl LanguageServer for Backend {
async fn initialize(&self, params: InitializeParams) -> Result<InitializeResult> {
if !is_slither_installed() {
error!("Slither is not installed!");
self.client
.show_message(
MessageType::ERROR,
"Slither is not installed! Please install it and restart the extension",
)
.await;
return Err(tower_lsp::jsonrpc::Error::internal_error());
error!("Slither is not installed!");
self.data.lock().await.has_to_shutdown = true;
}
if !is_solc_installed() {
self.client
Expand All @@ -46,7 +46,7 @@ impl LanguageServer for Backend {
)
.await;
error!("Solc is not installed!");
return Err(tower_lsp::jsonrpc::Error::internal_error());
self.data.lock().await.has_to_shutdown = true;
}

info!("Initializing diagnostic receiver ...");
Expand Down Expand Up @@ -94,7 +94,13 @@ impl LanguageServer for Backend {
}

async fn initialized(&self, _: InitializedParams) {
info!("Osmium-slither initialized!");
if self.data.lock().await.has_to_shutdown {
error!("Osmium-Solidity-Slither shuting down ...");
info!("This may occur because of missing dependencies or errors. Please check the logs for more information.");
let _ = self.shutdown().await;
} else {
info!("Osmium-Solidity-Slither initialized!");
}
}

async fn did_change_workspace_folders(&self, params: DidChangeWorkspaceFoldersParams) {
Expand Down
2 changes: 2 additions & 0 deletions servers/slither-server/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct SlitherData {
pub sender: Sender<SlitherDiag>,
pub src_paths: Vec<String>,
pub workspace: String,
pub has_to_shutdown: bool,
}

impl SlitherData {
Expand All @@ -35,6 +36,7 @@ impl SlitherData {
receiver: Some(receiver),
sender,
workspace: String::new(),
has_to_shutdown: false,
}
}
}
Expand Down

0 comments on commit b450c46

Please sign in to comment.