Skip to content
Open
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
1 change: 0 additions & 1 deletion Cargo.lock

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

7 changes: 0 additions & 7 deletions crates/pgls_catalog/src/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,6 @@ impl Snapshot {
.collect()
}

pub fn find_types(&self, name: &str, schema: Option<&str>) -> Vec<&PostgresType> {
self.types
.iter()
.filter(|t| t.name == name && schema.is_none_or(|s| s == t.schema))
.collect()
}

pub fn find_functions(&self, name: &str, schema: Option<&str>) -> Vec<&Function> {
self.functions
.iter()
Expand Down
2 changes: 0 additions & 2 deletions crates/pgls_hover/src/hovered_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ pub(crate) enum HoveredNode {
Role(String),
PostgresType((Option<String>, String)),

#[allow(unused)]
Trigger((Option<String>, String)),
#[allow(dead_code)]
Policy((Option<String>, String)),
}
Expand Down
46 changes: 13 additions & 33 deletions crates/pgls_hover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub struct OnHoverParams<'a> {
pub position: TextSize,
pub snapshot: &'a Snapshot,
pub stmt_sql: &'a str,
pub ast: Option<&'a pgls_query::NodeEnum>,
pub ts_tree: &'a tree_sitter::Tree,
/// The references of [`pgls_catalog::resolve::resolve`] whose span contains the cursor.
/// When one of them is of the hovered kind, hover shows the object it resolves to instead of
Expand Down Expand Up @@ -54,21 +53,12 @@ pub fn on_hover(params: OnHoverParams) -> Option<Vec<String>> {
}

let items: Vec<Hoverable> = match hovered_node {
HoveredNode::Table(node_identification) => match node_identification {
(None, n) => params
.snapshot
.find_tables(n.as_str(), None)
.into_iter()
.map(Hoverable::from)
.collect(),

(Some(s), n) => params
.snapshot
.find_tables(n.as_str(), Some(&s))
.into_iter()
.map(Hoverable::from)
.collect(),
},
HoveredNode::Table((schema, table_name)) => params
.snapshot
.find_tables(&table_name, schema.as_deref())
.into_iter()
.map(Hoverable::from)
.collect(),

HoveredNode::Column(node_identification) => match node_identification {
(None, None, column_name) => params
Expand Down Expand Up @@ -128,23 +118,14 @@ pub fn on_hover(params: OnHoverParams) -> Option<Vec<String>> {
.map(|s| vec![s])
.unwrap_or_default(),

HoveredNode::PostgresType(node_identification) => match node_identification {
(None, type_name) => params
.snapshot
.find_type(&type_name, None)
.map(Hoverable::from)
.map(|s| vec![s])
.unwrap_or_default(),

(Some(schema), type_name) => params
.snapshot
.find_type(&type_name, Some(schema.as_str()))
.map(Hoverable::from)
.map(|s| vec![s])
.unwrap_or_default(),
},
HoveredNode::PostgresType((schema, type_name)) => params
.snapshot
.find_type(&type_name, schema.as_deref())
.map(Hoverable::from)
.into_iter()
.collect(),

HoveredNode::Policy(_) | HoveredNode::Trigger(_) => return None,
HoveredNode::Policy(_) => return None,
};

let markdown_blocks: Vec<String> = prioritize_by_context(items, &ctx)
Expand Down Expand Up @@ -185,7 +166,6 @@ mod tests {
position: TextSize::new(position as u32),
snapshot: &snapshot,
stmt_sql: &sql,
ast: None,
ts_tree: &tree,
references: &[],
});
Expand Down
1 change: 0 additions & 1 deletion crates/pgls_hover/tests/hover_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ async fn test_hover_at_cursor(name: &str, query: String, setup: Option<&str>, te
position,
snapshot: &snapshot,
stmt_sql: &sql,
ast: ast.as_ref(),
ts_tree: &tree,
references: &references,
})
Expand Down
1 change: 0 additions & 1 deletion crates/pgls_lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ parking_lot = "0.12.3"
pgls_analyse = { workspace = true }
pgls_completions = { workspace = true }
pgls_configuration = { workspace = true }
pgls_console = { workspace = true }
pgls_diagnostics = { workspace = true }
pgls_fs = { workspace = true }
pgls_text_edit = { workspace = true }
Expand Down
6 changes: 1 addition & 5 deletions crates/pgls_lsp/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::capabilities::server_capabilities;
use crate::handlers;
use crate::session::{ClientInformation, Session, SessionHandle, SessionKey};
use crate::session::{Session, SessionHandle, SessionKey};
use crate::utils::{into_lsp_error, panic_to_lsp_error};
use futures::FutureExt;
use futures::future::ready;
Expand Down Expand Up @@ -71,10 +71,6 @@ impl LanguageServer for LSPServer {

self.session.initialize(
params.capabilities,
params.client_info.map(|client_info| ClientInformation {
name: client_info.name,
version: client_info.version,
}),
params.root_uri,
params.workspace_folders,
);
Expand Down
17 changes: 0 additions & 17 deletions crates/pgls_lsp/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@ const DIAGNOSTIC_DEBOUNCE: Duration = Duration::from_millis(300);
/// configuration, so that a burst of changes causes one reload.
const CONFIGURATION_RELOAD_DEBOUNCE: Duration = Duration::from_millis(200);

pub(crate) struct ClientInformation {
#[allow(dead_code)]
/// The name of the client
pub(crate) name: String,

#[allow(dead_code)]
/// The version of the client
pub(crate) version: Option<String>,
}

/// Key, uniquely identifying a LSP session.
#[derive(Clone, Copy, Eq, PartialEq, Hash, Debug)]
pub(crate) struct SessionKey(pub u64);
Expand Down Expand Up @@ -171,11 +161,7 @@ pub(crate) struct Session {
struct InitializeParams {
/// The capabilities provided by the client as part of [`ls_types::InitializeParams`]
client_capabilities: ls_types::ClientCapabilities,
#[allow(dead_code)]
client_information: Option<ClientInformation>,
root_uri: Option<Uri>,
#[allow(unused)]
workspace_folders: Option<Vec<WorkspaceFolder>>,
}

#[repr(u8)]
Expand Down Expand Up @@ -287,7 +273,6 @@ impl Session {
pub(crate) fn initialize(
&self,
client_capabilities: ls_types::ClientCapabilities,
client_information: Option<ClientInformation>,
root_uri: Option<Uri>,
workspace_folders: Option<Vec<WorkspaceFolder>>,
) {
Expand All @@ -308,9 +293,7 @@ impl Session {
});
let result = self.initialize_params.set(InitializeParams {
client_capabilities,
client_information,
root_uri,
workspace_folders,
});

if let Err(err) = result {
Expand Down
8 changes: 3 additions & 5 deletions crates/pgls_workspace/src/workspace/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use crate::{
semantic_tokens::{PullSemanticTokensParams, PullSemanticTokensResult, SemanticToken},
},
settings::{Settings, WorkspaceSettings, WorkspaceSettingsHandle, WorkspaceSettingsHandleMut},
workspace::{AnalyserDiagnosticsMapper, WithCSTandASTMapper},
workspace::{AnalyserDiagnosticsMapper, WithCSTMapper},
};

use super::{
Expand All @@ -79,7 +79,6 @@ use super::{
pub use statement_identifier::StatementId;

mod analyser;
mod annotation;
#[cfg(feature = "db")]
mod async_helper;
#[cfg(feature = "db")]
Expand Down Expand Up @@ -1739,8 +1738,8 @@ impl Workspace for WorkspaceServer {
};

// The innermost statement: the body of a SQL function rather than its `CREATE FUNCTION`.
match doc.iter_at(WithCSTandASTMapper, params.position).last() {
Some((stmt_id, range, ts_tree, maybe_ast)) => {
match doc.iter_at(WithCSTMapper, params.position).last() {
Some((stmt_id, range, ts_tree)) => {
let position_in_stmt = params.position - range.start();
let (references, snapshot) = self.hover_references(
settings,
Expand All @@ -1754,7 +1753,6 @@ impl Workspace for WorkspaceServer {
let markdown_blocks = pgls_hover::on_hover(pgls_hover::OnHoverParams {
ts_tree: &ts_tree,
snapshot: &snapshot,
ast: maybe_ast.as_ref(),
position: position_in_stmt,
stmt_sql: stmt_id.content(),
references: &references,
Expand Down
94 changes: 0 additions & 94 deletions crates/pgls_workspace/src/workspace/server/annotation.rs

This file was deleted.

29 changes: 0 additions & 29 deletions crates/pgls_workspace/src/workspace/server/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use pgls_text_size::{TextRange, TextSize};
use rustc_hash::FxHashSet;

use super::{
annotation::AnnotationStore,
pg_query::{PgQueryStore, convert_to_positional_params_with_metadata},
statement_identifier::StatementId,
tree_sitter::TreeSitterStore,
Expand All @@ -21,16 +20,13 @@ pub struct Document {
diagnostics: Vec<SDiagnostic>,
ast_db: PgQueryStore,
cst_db: TreeSitterStore,
#[allow(dead_code)]
annotation_db: AnnotationStore,
suppressions: Suppressions,
}

impl Document {
pub fn new(content: String, version: i32) -> Document {
let cst_db = TreeSitterStore::new();
let ast_db = PgQueryStore::new();
let annotation_db = AnnotationStore::new();
let (ranges, diagnostics) = split_with_diagnostics(&content, None);
let suppressions = Suppressions::from(content.as_str()).with_statements(ranges.clone());

Expand All @@ -41,7 +37,6 @@ impl Document {
version,
ast_db,
cst_db,
annotation_db,
suppressions,
}
}
Expand All @@ -67,7 +62,6 @@ impl Document {
|id: &StatementId| statements.contains(id.parent_content().unwrap_or(id.content()));
self.ast_db.retain(is_present);
self.cst_db.retain(is_present);
self.annotation_db.retain(is_present);
}

pub fn suppressions(&self) -> &Suppressions {
Expand Down Expand Up @@ -130,7 +124,6 @@ impl Document {
}
}

#[allow(dead_code)]
pub fn count(&self) -> usize {
self.iter(DefaultMapper).count()
}
Expand Down Expand Up @@ -346,28 +339,6 @@ impl<'a> StatementMapper<'a> for WithCSTMapper {
}
}

pub struct WithCSTandASTMapper;
impl<'a> StatementMapper<'a> for WithCSTandASTMapper {
type Output = (
StatementId,
TextRange,
Arc<tree_sitter::Tree>,
Option<pgls_query::NodeEnum>,
);

fn map(&self, parser: &'a Document, id: StatementId, range: TextRange) -> Self::Output {
let tree = parser.cst_db.get_or_cache_tree(&id);
let ast_result = parser.ast_db.get_or_cache_ast(&id);

let ast_option = match &*ast_result {
Ok(node) => Some(node.clone()),
Err(_) => None,
};

(id.clone(), range, tree, ast_option)
}
}

/*
* We allow an offset of two for the statement:
*
Expand Down
Loading