File tree Expand file tree Collapse file tree 3 files changed +43
-4
lines changed
emmylua_code_analysis/src/compilation/analyzer/doc
emmylua_ls/src/handlers/test
emmylua_parser/src/syntax/node/doc Expand file tree Collapse file tree 3 files changed +43
-4
lines changed Original file line number Diff line number Diff line change @@ -93,12 +93,12 @@ impl<'a> DocAnalyzer<'a> {
93
93
}
94
94
95
95
pub fn preprocess_description ( mut description : & str , owner : Option < & LuaSemanticDeclId > ) -> String {
96
- let has_remove_start_char = if let Some ( owner) = owner {
96
+ let need_remove_start_char = if let Some ( owner) = owner {
97
97
!matches ! ( owner, LuaSemanticDeclId :: Signature ( _) )
98
98
} else {
99
99
true
100
100
} ;
101
- if has_remove_start_char {
101
+ if need_remove_start_char {
102
102
if description. starts_with ( [ '#' , '@' ] ) {
103
103
description = description. trim_start_matches ( |c| c == '#' || c == '@' ) ;
104
104
}
Original file line number Diff line number Diff line change @@ -478,4 +478,27 @@ mod tests {
478
478
} ,
479
479
) ) ;
480
480
}
481
+
482
+ #[ test]
483
+ fn test_annotation_search ( ) {
484
+ let mut ws = ProviderVirtualWorkspace :: new ( ) ;
485
+ ws. def_file (
486
+ "a.lua" ,
487
+ r#"
488
+ ---@version 5.4
489
+ ---测试
490
+ function test()
491
+ end
492
+
493
+ "# ,
494
+ ) ;
495
+ assert ! ( ws. check_hover(
496
+ r#"
497
+ <??>test()
498
+ "# ,
499
+ VirtualHoverResult {
500
+ value: "```lua\n function test()\n ```\n \n ---\n \n 测试" . to_string( ) ,
501
+ } ,
502
+ ) ) ;
503
+ }
481
504
}
Original file line number Diff line number Diff line change @@ -45,6 +45,19 @@ impl LuaAstNode for LuaComment {
45
45
}
46
46
}
47
47
48
+ /// 检查语法节点是否为附加性质的文档标签
49
+ ///
50
+ /// 附加性质的标签不会阻止查找 DocDescription
51
+ fn is_additive_doc_tag ( kind : LuaSyntaxKind ) -> bool {
52
+ matches ! (
53
+ kind,
54
+ LuaSyntaxKind :: DocTagVisibility
55
+ | LuaSyntaxKind :: DocTagExport
56
+ | LuaSyntaxKind :: DocTagVersion
57
+ | LuaSyntaxKind :: DocTagNodiscard
58
+ )
59
+ }
60
+
48
61
impl LuaComment {
49
62
pub fn get_owner ( & self ) -> Option < LuaAst > {
50
63
if let Some ( inline_node) = find_inline_node ( & self . syntax ) {
@@ -66,8 +79,11 @@ impl LuaComment {
66
79
LuaKind :: Syntax ( LuaSyntaxKind :: DocDescription ) => {
67
80
return LuaDocDescription :: cast ( child. into_node ( ) . unwrap ( ) ) ;
68
81
}
69
- LuaKind :: Token ( LuaTokenKind :: TkDocStart ) => {
70
- return None ;
82
+ LuaKind :: Token ( LuaTokenKind :: TkDocStart ) => { }
83
+ LuaKind :: Syntax ( syntax_kind) => {
84
+ if !is_additive_doc_tag ( syntax_kind) {
85
+ return None ;
86
+ }
71
87
}
72
88
_ => { }
73
89
}
You can’t perform that action at this time.
0 commit comments