Skip to content

Commit 92b16fb

Browse files
reset
1 parent e2826fb commit 92b16fb

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

crates/pgt_hover/src/hovered_node.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ impl HoveredNode {
6464
Some(HoveredNode::Role(NodeIdentification::Name(node_content)))
6565
}
6666

67+
"policy_table" | "revoke_table" | "grant_table" => {
68+
if let Some(schema) = ctx.schema_or_alias_name.as_ref() {
69+
Some(HoveredNode::Table(NodeIdentification::SchemaAndName((
70+
schema.clone(),
71+
node_content,
72+
))))
73+
} else {
74+
Some(HoveredNode::Table(NodeIdentification::Name(node_content)))
75+
}
76+
}
77+
6778
_ => None,
6879
}
6980
}

crates/pgt_hover/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ pub struct OnHoverParams<'a> {
2020
pub ts_tree: &'a tree_sitter::Tree,
2121
}
2222

23+
#[tracing::instrument(level = "debug", skip_all, fields(
24+
text = params.stmt_sql,
25+
position = params.position.to_string()
26+
))]
2327
pub fn on_hover(params: OnHoverParams) -> Vec<String> {
2428
let ctx = pgt_treesitter::context::TreesitterContext::new(TreeSitterContextParams {
2529
position: params.position,

crates/pgt_lsp/src/handlers/hover.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use tower_lsp::lsp_types::{self, MarkedString, MarkupContent};
33

44
use crate::{adapters::get_cursor_position, diagnostics::LspError, session::Session};
55

6+
#[tracing::instrument(level = "debug", skip(session), err)]
67
pub(crate) fn on_hover(
78
session: &Session,
89
params: lsp_types::HoverParams,

crates/pgt_workspace/src/workspace/server.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,11 @@ impl Workspace for WorkspaceServer {
719719
}
720720
}
721721

722+
#[ignored_path(path=&params.path)]
723+
#[tracing::instrument(level = "debug", skip_all, fields(
724+
path = params.path.as_os_str().to_str(),
725+
position = params.position.to_string()
726+
), err)]
722727
fn on_hover(&self, params: OnHoverParams) -> Result<OnHoverResult, WorkspaceError> {
723728
let documents = self.documents.read().unwrap();
724729
let doc = documents
@@ -742,7 +747,7 @@ impl Workspace for WorkspaceServer {
742747
.next()
743748
{
744749
Some((stmt_id, range, ts_tree, maybe_ast)) => {
745-
let position_in_stmt = params.position + range.start();
750+
let position_in_stmt = params.position - range.start();
746751

747752
let markdown_blocks = pgt_hover::on_hover(pgt_hover::OnHoverParams {
748753
ts_tree: &ts_tree,

0 commit comments

Comments
 (0)