pub struct SqlParser { /* private fields */ }Expand description
SQL 解析器(基于 Tree-sitter)
Implementations§
Source§impl SqlParser
impl SqlParser
Sourcepub fn parse(&mut self, sql: &str) -> ParseResult
pub fn parse(&mut self, sql: &str) -> ParseResult
解析 SQL 语句
Sourcepub fn tokenize(&self, tree: &Tree, source: &str) -> Vec<Token>
pub fn tokenize(&self, tree: &Tree, source: &str) -> Vec<Token>
提取所有 Token(参考 sqls 的 tokenizer)
Sourcepub fn get_node_at_position<'a>(
&self,
tree: &'a Tree,
position: Position,
) -> Option<Node<'a>>
pub fn get_node_at_position<'a>( &self, tree: &'a Tree, position: Position, ) -> Option<Node<'a>>
获取指定位置的节点
Sourcepub fn is_in_from_context(&self, node: Node<'_>, source: &str) -> bool
pub fn is_in_from_context(&self, node: Node<'_>, source: &str) -> bool
检查节点是否在 FROM/JOIN 上下文中
Sourcepub fn is_in_column_context(&self, node: Node<'_>, source: &str) -> bool
pub fn is_in_column_context(&self, node: Node<'_>, source: &str) -> bool
检查节点是否在列上下文中(SELECT/WHERE/ORDER BY 等)
Sourcepub fn node_range(&self, node: Node<'_>) -> Range
pub fn node_range(&self, node: Node<'_>) -> Range
获取节点的范围
Sourcepub fn analyze_completion_context(
&self,
node: Node<'_>,
source: &str,
) -> CompletionContext
pub fn analyze_completion_context( &self, node: Node<'_>, source: &str, ) -> CompletionContext
分析补全上下文 根据光标位置的 AST 节点,判断应该提供什么类型的补全
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SqlParser
impl RefUnwindSafe for SqlParser
impl Send for SqlParser
impl Sync for SqlParser
impl Unpin for SqlParser
impl UnwindSafe for SqlParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more