Skip to main content

LspServer

Struct LspServer 

Source
pub struct LspServer {
    pub state: ServerState,
    pub document_manager: Arc<DocumentManager>,
    pub config: ServerConfig,
    pub status: ServerStatus,
    pub schema_provider: Arc<SchemaProvider>,
    pub toml_analyzer: Arc<TomlAnalyzer>,
    pub macro_analyzer: Arc<MacroAnalyzer>,
    pub route_navigator: Arc<RouteNavigator>,
    pub completion_engine: Arc<CompletionEngine>,
    pub diagnostic_engine: Arc<DiagnosticEngine>,
    pub index_manager: Arc<IndexManager>,
    /* private fields */
}
Expand description

LSP 服务器

Fields§

§state: ServerState

服务器状态

§document_manager: Arc<DocumentManager>

文档管理器

§config: ServerConfig

服务器配置

§status: ServerStatus

服务器状态跟踪器

§schema_provider: Arc<SchemaProvider>

Schema 提供者

§toml_analyzer: Arc<TomlAnalyzer>

TOML 分析器

§macro_analyzer: Arc<MacroAnalyzer>

宏分析器

§route_navigator: Arc<RouteNavigator>

路由导航器

§completion_engine: Arc<CompletionEngine>

补全引擎

§diagnostic_engine: Arc<DiagnosticEngine>

诊断引擎

§index_manager: Arc<IndexManager>

索引管理器

Implementations§

Source§

impl LspServer

Source

pub fn start() -> Result<Self>

启动 LSP 服务器

这个方法创建服务器实例并初始化 LSP 连接

Source

pub fn new_for_test() -> Result<Self>

为测试创建 LSP 服务器(不使用 stdio 连接)

Source

pub fn run(&mut self) -> Result<()>

运行服务器主循环

这个方法处理初始化握手,然后进入主事件循环处理来自客户端的消息

Source

pub fn handle_did_open( &mut self, params: DidOpenTextDocumentParams, ) -> Result<()>

处理文档打开通知

Source

pub fn handle_did_change( &mut self, params: DidChangeTextDocumentParams, ) -> Result<()>

处理文档修改通知

Source

pub fn handle_did_close( &mut self, params: DidCloseTextDocumentParams, ) -> Result<()>

处理文档关闭通知

Source

pub fn analyze_document(&mut self, uri: &Url, language_id: &str) -> Result<()>

分析文档并生成诊断

Source

pub fn handle_initialize( &mut self, params: InitializeParams, ) -> Result<InitializeResult>

处理初始化请求

声明服务器支持的所有能力,包括:

  • 文档同步(增量更新)
  • 智能补全(TOML 配置、宏参数、环境变量)
  • 悬停提示(配置文档、宏展开、路由信息)
  • 诊断(配置验证、路由验证、依赖注入验证)
  • 定义跳转(路由导航)
  • 文档符号(路由列表)
Source

pub fn shutdown(&mut self) -> Result<()>

优雅关闭服务器

Trait Implementations§

Source§

impl Default for LspServer

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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