DslParser

Struct DslParser 

Source
pub struct DslParser { /* private fields */ }
Expand description

Elasticsearch DSL 解析器(基于 Tree-sitter JSON) 注意:DSL 是 JSON 格式,使用 tree-sitter-json 解析

Implementations§

Source§

impl DslParser

Source

pub fn new() -> Self

Source

pub fn parse(&mut self, dsl: &str) -> Vec<Diagnostic>

解析 Elasticsearch DSL(JSON 格式)

Source

pub fn parse_with_tree(&mut self, dsl: &str) -> (Option<Tree>, Vec<Diagnostic>)

解析并返回 Tree(用于补全等功能)

Source

pub fn extract_fields(&self, tree: &Tree, source: &str) -> Vec<String>

提取 JSON 中的字段名(用于代码补全)

Source

pub fn get_node_at_position<'a>( &self, tree: &'a Tree, position: Position, ) -> Option<Node<'a>>

获取指定位置的节点

Source

pub fn node_text(&self, node: Node<'_>, source: &str) -> String

获取节点的文本内容

Source

pub fn node_range(&self, node: Node<'_>) -> Range

获取节点的范围

Source

pub fn analyze_completion_context( &self, node: Node<'_>, source: &str, ) -> DslCompletionContext

分析补全上下文 根据光标位置的 AST 节点,判断应该提供什么类型的补全

Source

pub fn is_in_field_object( &self, node: Node<'_>, source: &str, field_name: &str, ) -> bool

检查节点是否在指定字段的对象内

Source

pub fn extract_field_name(&self, node: Node<'_>, source: &str) -> Option<String>

提取字段名(用于跳转定义和查找引用)

Trait Implementations§

Source§

impl Default for DslParser

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more