Skip to main content

summer_lsp/
lib.rs

1//! # summer-lsp
2//!
3//! Language Server Protocol implementation for summer-rs framework.
4//!
5//! summer-lsp 提供智能的开发体验,包括:
6//! - TOML 配置文件的智能补全和验证
7//! - Rust 宏的分析和展开
8//! - 路由的识别和导航
9//! - 依赖注入验证
10//!
11//! ## 架构
12//!
13//! summer-lsp 采用分层架构:
14//! - **LSP Protocol Layer**: 处理 LSP 协议通信
15//! - **Server Core Layer**: 消息分发和状态管理
16//! - **Analysis Modules**: 各种分析功能模块
17//! - **Foundation Layer**: 基础设施和工具
18//!
19//! ## 模块组织
20//!
21//! ```text
22//! summer-lsp/
23//! ├── protocol/          # LSP 协议层
24//! │   ├── server.rs      # LSP 服务器核心
25//! │   ├── handlers/      # 请求处理器
26//! │   └── types.rs       # 协议类型定义
27//! ├── analysis/          # 分析引擎层
28//! │   ├── toml/          # TOML 分析
29//! │   ├── rust/          # Rust 代码分析
30//! │   ├── completion/    # 补全引擎
31//! │   ├── diagnostic/    # 诊断引擎
32//! │   └── validation/    # 验证引擎
33//! ├── scanner/           # 扫描器层
34//! │   ├── component.rs   # 组件扫描
35//! │   ├── route.rs       # 路由扫描
36//! │   ├── job.rs         # 任务扫描
37//! │   ├── plugin.rs      # 插件扫描
38//! │   └── config.rs      # 配置扫描
39//! ├── core/              # 核心层
40//! │   ├── document.rs    # 文档管理
41//! │   ├── index.rs       # 符号索引
42//! │   ├── schema.rs      # Schema 管理
43//! │   └── config.rs      # 配置管理
44//! └── utils/             # 工具层
45//!     ├── error.rs       # 错误定义
46//!     ├── logging.rs     # 日志系统
47//!     └── status.rs      # 状态管理
48//! ```
49
50// ============================================================================
51// 协议层 (Protocol Layer)
52// ============================================================================
53pub mod protocol {
54    //! LSP 协议处理模块
55
56    pub mod handlers;
57    pub mod server;
58    pub mod types;
59
60    pub use server::LspServer;
61}
62
63// ============================================================================
64// 分析层 (Analysis Layer)
65// ============================================================================
66pub mod analysis {
67    //! 代码分析模块
68
69    pub mod completion;
70    pub mod diagnostic;
71    pub mod rust;
72    pub mod toml;
73    pub mod validation;
74
75    pub use completion::CompletionEngine;
76    pub use diagnostic::DiagnosticEngine;
77}
78
79// ============================================================================
80// 扫描器层 (Scanner Layer)
81// ============================================================================
82pub mod scanner {
83    //! 项目扫描模块
84
85    pub mod component;
86    pub mod config;
87    pub mod job;
88    pub mod plugin;
89    pub mod route;
90
91    pub use component::ComponentScanner;
92    pub use config::ConfigScanner;
93    pub use job::JobScanner;
94    pub use plugin::PluginScanner;
95    pub use route::RouteScanner;
96}
97
98// ============================================================================
99// 核心层 (Core Layer)
100// ============================================================================
101pub mod core {
102    //! 核心功能模块
103
104    pub mod config;
105    pub mod document;
106    pub mod index;
107    pub mod schema;
108
109    pub use document::DocumentManager;
110    pub use index::SymbolIndex;
111    pub use schema::SchemaProvider;
112}
113
114// ============================================================================
115// 工具层 (Utils Layer)
116// ============================================================================
117pub mod utils {
118    //! 工具和辅助模块
119
120    pub mod error;
121    pub mod logging;
122    pub mod status;
123
124    pub use error::{Error, Result};
125    pub use logging::init_logging;
126    pub use status::ServerStatus;
127}
128
129// ============================================================================
130// 向后兼容的重导出
131// ============================================================================
132
133// 协议层
134pub use protocol::server;
135pub use protocol::LspServer;
136
137// 分析层
138pub use analysis::completion;
139pub use analysis::diagnostic;
140pub use analysis::rust::macro_analyzer;
141pub use analysis::toml::toml_analyzer;
142pub use analysis::validation::di_validator;
143
144// 扫描器层
145// 注意:这些是模块重导出,不是类型重导出
146pub use scanner::component;
147// config 模块与 core::config 冲突,使用别名
148pub use scanner::config as scanner_config;
149pub use scanner::job;
150pub use scanner::plugin;
151// route 模块与下面的 route 模块冲突,使用别名
152pub use scanner::route as scanner_route;
153
154// 核心层
155pub use core::config;
156pub use core::document;
157pub use core::index;
158pub use core::schema;
159
160// 工具层
161pub use utils::error;
162pub use utils::logging;
163pub use utils::status;
164
165// 类型重导出
166pub use utils::error::{Error, Result};
167
168// 路由相关(保持向后兼容)
169pub mod route {
170    pub use crate::scanner::route::*;
171}