Skip to content

Commit 07485dc

Browse files
authored
Reenable dead code analysis in lsp/ (#355)
It's too useful to live without!
1 parent 0730912 commit 07485dc

File tree

8 files changed

+6
-105
lines changed

8 files changed

+6
-105
lines changed

crates/lsp/src/encoding.rs

Lines changed: 0 additions & 61 deletions
This file was deleted.

crates/lsp/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
// TODO: Remove this
2-
#![allow(dead_code)]
3-
41
pub use tower_lsp::start_lsp;
52

63
pub mod capabilities;
74
pub mod documents;
8-
pub mod encoding;
95
pub mod file_patterns;
106
pub mod from_proto;
117
pub mod handlers;

crates/lsp/src/main_loop.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
//
66
//
77

8-
use std::collections::HashMap;
98
use std::future;
109
use std::pin::Pin;
1110

@@ -57,16 +56,19 @@ type TaskList<T> = futures::stream::FuturesUnordered<Pin<Box<dyn AnyhowJoinHandl
5756
#[derive(Debug)]
5857
pub(crate) enum Event {
5958
Lsp(LspMessage),
59+
#[allow(dead_code)]
6060
Kernel(KernelNotification),
6161
}
6262

6363
#[derive(Debug)]
6464
pub(crate) enum KernelNotification {
65+
#[allow(dead_code)]
6566
DidChangeConsoleInputs(ConsoleInputs),
6667
}
6768

6869
#[derive(Debug)]
6970
pub(crate) enum AuxiliaryEvent {
71+
#[allow(dead_code)]
7072
PublishDiagnostics(Url, Vec<Diagnostic>, Option<i32>),
7173
SpawnedTask(JoinHandle<anyhow::Result<Option<AuxiliaryEvent>>>),
7274
}
@@ -161,9 +163,6 @@ pub(crate) struct LspState {
161163
/// translate UTF-16 positions sent by the client to UTF-8 ones.
162164
pub(crate) position_encoding: PositionEncoding,
163165

164-
/// The set of tree-sitter document parsers managed by the `GlobalState`.
165-
pub(crate) parsers: HashMap<Url, tree_sitter::Parser>,
166-
167166
/// List of client capabilities that we care about
168167
pub(crate) capabilities: AirClientCapabilities,
169168

@@ -181,7 +180,6 @@ impl LspState {
181180
workspace_settings_resolver: Default::default(),
182181
// All servers and clients have to support UTF-16 so that's the default
183182
position_encoding: PositionEncoding::Wide(WideEncoding::Utf16),
184-
parsers: Default::default(),
185183
capabilities: Default::default(),
186184
log_state: Default::default(),
187185
settings: Default::default(),

crates/lsp/src/rust_analyzer/to_proto.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,6 @@ pub(crate) fn text_edit(
2929
Ok(lsp_types::TextEdit { range, new_text })
3030
}
3131

32-
pub(crate) fn completion_text_edit(
33-
line_index: &LineIndex,
34-
insert_replace_support: Option<lsp_types::Position>,
35-
indel: Indel,
36-
) -> anyhow::Result<lsp_types::CompletionTextEdit> {
37-
let text_edit = text_edit(line_index, indel)?;
38-
Ok(match insert_replace_support {
39-
Some(cursor_pos) => lsp_types::InsertReplaceEdit {
40-
new_text: text_edit.new_text,
41-
insert: lsp_types::Range {
42-
start: text_edit.range.start,
43-
end: cursor_pos,
44-
},
45-
replace: text_edit.range,
46-
}
47-
.into(),
48-
None => text_edit.into(),
49-
})
50-
}
51-
5232
pub(crate) fn text_edit_vec(
5333
line_index: &LineIndex,
5434
text_edit: TextEdit,

crates/lsp/src/settings_vsc.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,3 @@ pub(crate) fn indent_style_from_vsc(insert_spaces: bool) -> settings::IndentStyl
141141
settings::IndentStyle::Tab
142142
}
143143
}
144-
145-
pub(crate) fn line_width_from_vsc(rulers: &[usize]) -> Option<settings::LineWidth> {
146-
rulers.first().and_then(|w| (*w as u16).try_into().ok())
147-
}

crates/lsp/src/state.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ pub(crate) struct WorldState {
3434
/// currently pushed to the LSP), and cache the symbols with Salsa. The
3535
/// performance is not currently an issue but this could change once we do
3636
/// more analysis of symbols in the search path.
37+
#[allow(dead_code)]
3738
pub(crate) console_scopes: Vec<Vec<String>>,
3839

3940
/// Currently installed packages
41+
#[allow(dead_code)]
4042
pub(crate) installed_packages: Vec<String>,
4143
}
4244

@@ -66,11 +68,4 @@ impl WorldState {
6668
pub(crate) fn workspace_uris(&self) -> Vec<Url> {
6769
self.documents.iter().map(|elt| elt.0.clone()).collect()
6870
}
69-
70-
pub(crate) fn workspace_paths(&self) -> Vec<String> {
71-
self.workspace_uris()
72-
.into_iter()
73-
.map(|uri| uri.to_string())
74-
.collect()
75-
}
7671
}

crates/lsp/src/to_proto.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::rust_analyzer::{self, line_index::LineIndex, text_edit::TextEdit};
1616
use biome_text_size::TextRange;
1717
use tower_lsp::lsp_types;
1818

19+
#[cfg(test)]
1920
pub(crate) fn doc_edit_vec(
2021
line_index: &LineIndex,
2122
text_edit: TextEdit,

crates/lsp/src/workspaces.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ impl WorkspaceSettingsResolver {
124124
}
125125
}
126126

127-
pub(crate) fn len(&self) -> usize {
128-
self.path_to_settings_resolver.len()
129-
}
130-
131127
/// Return the appropriate [`WorkspaceSettings`] for a given document [`Url`].
132128
pub(crate) fn settings_for_url(&self, url: &Url) -> WorkspaceSettings {
133129
if let Ok(Some(path)) = Self::url_to_path(url) {

0 commit comments

Comments
 (0)