Skip to content
Closed
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.

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

pub fn find_types(&self, name: &str, schema: Option<&str>) -> Vec<&PostgresType> {
let sanitized_name = Self::sanitize_identifier(name);
self.types
.iter()
.filter(|t| {
t.name == sanitized_name
&& schema
.map(Self::sanitize_identifier)
.as_deref()
.is_none_or(|s| s == t.schema.as_str())
})
.collect()
}

pub fn find_functions(&self, name: &str, schema: Option<&str>) -> Vec<&Function> {
let sanitized_name = Self::sanitize_identifier(name);
self.functions
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 @@ -9,8 +9,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 @@ -18,7 +18,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 All @@ -45,21 +44,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 @@ -119,23 +109,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 @@ -172,7 +153,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 @@ -17,7 +17,6 @@ futures = "0.3.31"
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
8 changes: 1 addition & 7 deletions crates/pgls_lsp/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::capabilities::server_capabilities;
use crate::handlers;
use crate::session::{
CapabilitySet, CapabilityStatus, ClientInformation, Session, SessionHandle, SessionKey,
};
use crate::session::{CapabilitySet, CapabilityStatus, Session, SessionHandle, SessionKey};
use crate::utils::{into_lsp_error, panic_to_lsp_error};
use futures::FutureExt;
use futures::future::ready;
Expand Down Expand Up @@ -115,10 +113,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
15 changes: 0 additions & 15 deletions crates/pgls_lsp/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ use tracing::{debug, error, info};
/// and the timer resets, so only one analysis run fires per burst.
const DIAGNOSTIC_DEBOUNCE: Duration = Duration::from_millis(300);

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 @@ -131,10 +121,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>>,
}

Expand Down Expand Up @@ -240,13 +227,11 @@ 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>>,
) {
let result = self.initialize_params.set(InitializeParams {
client_capabilities,
client_information,
root_uri,
workspace_folders,
});
Expand Down
16 changes: 0 additions & 16 deletions crates/pgls_lsp/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ use crate::adapters::from_lsp::text_range;
use crate::adapters::line_index::LineIndex;
use crate::adapters::{PositionEncoding, to_lsp};
use anyhow::{Context, Result, ensure};
use pgls_console::MarkupBuf;
use pgls_console::fmt::Termcolor;
use pgls_console::fmt::{self, Formatter};
use pgls_diagnostics::termcolor::NoColor;
use pgls_diagnostics::{Diagnostic, DiagnosticTags, Location, PrintDescription, Severity, Visit};
use pgls_text_size::{TextRange, TextSize};
use std::any::Any;
Expand Down Expand Up @@ -141,18 +137,6 @@ impl Visit for RelatedInformationVisitor<'_> {
}
}

/// Convert a piece of markup into a String
#[allow(unused)]
fn print_markup(markup: &MarkupBuf) -> String {
let mut message = Termcolor(NoColor::new(Vec::new()));
fmt::Display::fmt(markup, &mut Formatter::new(&mut message))
// SAFETY: Writing to a memory buffer should never fail
.unwrap();

// SAFETY: Printing uncolored markup never generates non UTF-8 byte sequences
String::from_utf8(message.0.into_inner()).unwrap()
}

/// Helper to create a [tower_lsp_server::jsonrpc::Error] from a message
pub(crate) fn into_lsp_error(msg: impl Display + Debug) -> LspError {
let mut error = LspError::internal_error();
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 @@ -74,7 +74,7 @@ use crate::{
on_hover::{OnHoverParams, OnHoverResult},
},
settings::{Settings, WorkspaceSettings, WorkspaceSettingsHandle, WorkspaceSettingsHandleMut},
workspace::{AnalyserDiagnosticsMapper, WithCSTandASTMapper},
workspace::{AnalyserDiagnosticsMapper, WithCSTMapper},
};

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

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

// The innermost statement: the body of a SQL function rather than its `CREATE FUNCTION`.
let result = match doc.iter_at(WithCSTandASTMapper, params.position).last() {
Some((stmt_id, range, ts_tree, maybe_ast)) => {
let result = 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(doc, &stmt_id, range, params.position, snapshot);

let markdown_blocks = pgls_hover::on_hover(pgls_hover::OnHoverParams {
ts_tree: &ts_tree,
snapshot: &snapshot,
ast: maybe_ast.as_deref(),
position: position_in_stmt,
stmt_sql: stmt_id.content(),
references: &references,
Expand Down
99 changes: 0 additions & 99 deletions crates/pgls_workspace/src/workspace/server/annotation.rs

This file was deleted.

Loading
Loading