pub struct RouteNavigator {
pub index: RouteIndex,
}Expand description
路由导航器
负责识别、索引和导航项目中的所有路由
Fields§
§index: RouteIndex路由索引
Implementations§
Sourcepub fn build_index(&mut self, documents: &[RustDocument])
pub fn build_index(&mut self, documents: &[RustDocument])
Sourcepub fn find_routes(&self, pattern: &str) -> Vec<&RouteInfo>
pub fn find_routes(&self, pattern: &str) -> Vec<&RouteInfo>
查找路由
支持模糊匹配和正则表达式搜索路由
§Arguments
pattern- 搜索模式,可以是:- 普通字符串:进行模糊匹配(路径包含该字符串)
- 正则表达式:以 “regex:” 开头,如 “regex:^/api/.*”
§Returns
返回匹配的路由信息列表
§Requirements
- 9.4: 支持模糊匹配和正则表达式搜索
§Examples
use spring_lsp::route::RouteNavigator;
let navigator = RouteNavigator::new();
// 模糊匹配
let routes = navigator.find_routes("users");
// 正则表达式匹配
let routes = navigator.find_routes("regex:^/api/v[0-9]+/.*");Sourcepub fn get_all_routes(&self) -> &[RouteInfo]
pub fn get_all_routes(&self) -> &[RouteInfo]
Sourcepub fn find_routes_by_handler(&self, handler_name: &str) -> Vec<&RouteInfo>
pub fn find_routes_by_handler(&self, handler_name: &str) -> Vec<&RouteInfo>
根据处理器函数名查找路由
实现处理器路由反查功能,根据处理器函数名查找对应的所有路由
§Arguments
handler_name- 处理器函数名称
§Returns
返回该处理器对应的所有路由信息
§Requirements
- 9.3: 实现处理器路由反查
§Examples
use spring_lsp::route::RouteNavigator;
let navigator = RouteNavigator::new();
let routes = navigator.find_routes_by_handler("get_user");
for route in routes {
println!("Handler 'get_user' handles: {:?} {}", route.methods[0], route.path);
}Sourcepub fn validate_routes(&self) -> Vec<Diagnostic>
pub fn validate_routes(&self) -> Vec<Diagnostic>
验证路由
验证所有路由的正确性,包括:
- 路径字符验证
- 路径参数语法验证
- 路径参数类型匹配验证
- RESTful 风格检查
§Returns
返回诊断信息列表
§Requirements
- 10.1: 路径字符验证
- 10.2: 路径参数语法验证
- 10.3: 路径参数类型匹配验证
- 10.5: RESTful 风格检查
§Examples
use spring_lsp::route::RouteNavigator;
let navigator = RouteNavigator::new();
let diagnostics = navigator.validate_routes();
for diagnostic in diagnostics {
println!("Validation error: {}", diagnostic.message);
}Sourcepub fn detect_conflicts(&self) -> Vec<RouteConflict>
pub fn detect_conflicts(&self) -> Vec<RouteConflict>
检测路由冲突
检测具有相同路径和 HTTP 方法的路由冲突
§Returns
返回路由冲突列表
§Requirements
- 9.5: 检测路由冲突
- 10.4: 路由路径冲突检测
§Examples
use spring_lsp::route::RouteNavigator;
let navigator = RouteNavigator::new();
let conflicts = navigator.detect_conflicts();
for conflict in conflicts {
println!("Route conflict detected between routes {} and {}",
conflict.index1, conflict.index2);
}Trait Implementations§
Source§fn clone(&self) -> RouteNavigator
fn clone(&self) -> RouteNavigator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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