Skip to content

Conversation

@Cythia828
Copy link
Collaborator

@Cythia828 Cythia828 commented Oct 28, 2025

功能

支持HoverProvider的开发

描述

在我们dt-sql-parser内部,CommonEntityContext实体被收集的时候,区分了是新建还是使用,如果是新建的情况下,会从当前CREATE语句中捞到columns挂在当前实体上,而我们当前功能就是当用户使用通过SQL新建出来的表时,使用表的地方hover到表名上方,可以展示出对应的字段列表,字段列表里包含字段名以及字段类型。

preview

https://cythia828.github.io/monaco-sql-languages/

自测

image

demo

CREATE TABLE postgresql.public.employees ( emp_id BIGINT COMMENT 'sfsf', name VARCHAR, department VARCHAR ) WITH ( connector = 'postgresql', connection_url = 'jdbc:postgresql://localhost:5432/company', connection_user = 'user', connection_password = 'password' ); select emp_id from postgresql.public.employees as tb1 select id from "postgresql.public.employees" select name from 'postgresql.public.employees' select name from postgresql.public.employees``

allEntities.find(
(en): en is CommonEntityContext =>
en.entityContextType === EntityContextType.TABLE_CREATE && en.text === tableName
) ?? null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑实体一边加反引号,一边没加的情况应该也匹配上

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种情况我调试一下看看

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加了加了

p.endColumn >= position.column &&
p.line === position.lineNumber
);
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当hover在表别名上时,也可以查找到的,展示的时候可以把表和别名一起展示

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确实,我加一下

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants