@@ -4,8 +4,8 @@ use super::{
4
4
use crate :: context:: ClientId ;
5
5
use crate :: util:: parse_desc;
6
6
use emmylua_code_analysis:: {
7
- LuaDecl , LuaDeclExtra , LuaMemberId , LuaMemberOwner , LuaSemanticDeclId , LuaType , LuaTypeDeclId ,
8
- SemanticDeclLevel , SemanticModel , WorkspaceId , check_export_visibility,
7
+ Emmyrc , LuaDecl , LuaDeclExtra , LuaMemberId , LuaMemberOwner , LuaSemanticDeclId , LuaType ,
8
+ LuaTypeDeclId , SemanticDeclLevel , SemanticModel , WorkspaceId , check_export_visibility,
9
9
parse_require_module_info,
10
10
} ;
11
11
use emmylua_parser:: {
@@ -21,6 +21,7 @@ pub fn build_semantic_tokens(
21
21
semantic_model : & mut SemanticModel ,
22
22
support_muliline_token : bool ,
23
23
client_id : ClientId ,
24
+ emmyrc : & Emmyrc ,
24
25
) -> Option < Vec < SemanticToken > > {
25
26
let root = semantic_model. get_root ( ) ;
26
27
let document = semantic_model. get_document ( ) ;
@@ -34,10 +35,16 @@ pub fn build_semantic_tokens(
34
35
for node_or_token in root. syntax ( ) . descendants_with_tokens ( ) {
35
36
match node_or_token {
36
37
NodeOrToken :: Node ( node) => {
37
- build_node_semantic_token ( semantic_model, & mut builder, node) ;
38
+ build_node_semantic_token ( semantic_model, & mut builder, node, emmyrc ) ;
38
39
}
39
40
NodeOrToken :: Token ( token) => {
40
- build_tokens_semantic_token ( semantic_model, & mut builder, & token, client_id) ;
41
+ build_tokens_semantic_token (
42
+ semantic_model,
43
+ & mut builder,
44
+ & token,
45
+ client_id,
46
+ emmyrc,
47
+ ) ;
41
48
}
42
49
}
43
50
}
@@ -50,6 +57,7 @@ fn build_tokens_semantic_token(
50
57
builder : & mut SemanticBuilder ,
51
58
token : & LuaSyntaxToken ,
52
59
client_id : ClientId ,
60
+ emmyrc : & Emmyrc ,
53
61
) {
54
62
match token. kind ( ) . into ( ) {
55
63
LuaTokenKind :: TkLongString | LuaTokenKind :: TkString => {
@@ -164,10 +172,7 @@ fn build_tokens_semantic_token(
164
172
let rendering_description = token
165
173
. parent ( )
166
174
. is_some_and ( |parent| parent. kind ( ) == LuaSyntaxKind :: DocDescription . into ( ) ) ;
167
- let description_parsing_is_enabled = semantic_model
168
- . get_emmyrc ( )
169
- . semantic_tokens
170
- . render_documentation_markup ;
175
+ let description_parsing_is_enabled = emmrc. semantic_tokens . render_documentation_markup ;
171
176
172
177
if !( rendering_description && description_parsing_is_enabled) {
173
178
builder. push ( token, SemanticTokenType :: COMMENT ) ;
@@ -232,6 +237,7 @@ fn build_node_semantic_token(
232
237
semantic_model : & SemanticModel ,
233
238
builder : & mut SemanticBuilder ,
234
239
node : LuaSyntaxNode ,
240
+ emmyrc : & Emmyrc ,
235
241
) -> Option < ( ) > {
236
242
match LuaAst :: cast ( node) ? {
237
243
LuaAst :: LuaDocTagClass ( doc_class) => {
@@ -590,11 +596,7 @@ fn build_node_semantic_token(
590
596
_ => { }
591
597
} ,
592
598
LuaAst :: LuaDocDescription ( description) => {
593
- if !semantic_model
594
- . get_emmyrc ( )
595
- . semantic_tokens
596
- . render_documentation_markup
597
- {
599
+ if !emmyrc. semantic_tokens . render_documentation_markup {
598
600
for token in description. tokens :: < LuaGeneralToken > ( ) {
599
601
if matches ! (
600
602
token. get_token_kind( ) ,
@@ -614,7 +616,7 @@ fn build_node_semantic_token(
614
616
. get_module ( )
615
617
. map ( |m| m. workspace_id )
616
618
. unwrap_or ( WorkspaceId :: MAIN ) ,
617
- semantic_model . get_emmyrc ( ) ,
619
+ emmyrc ,
618
620
text,
619
621
description,
620
622
None ,
0 commit comments