Skip to content

Commit 2a59703

Browse files
committed
Merge branch 'main' of github.com:EmmyLuaLs/emmylua-analyzer-rust
2 parents 70fb4f6 + 614962f commit 2a59703

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

crates/emmylua_ls/src/handlers/inlay_hint/build_function_hint.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ pub fn build_closure_hint(
4848
let mut label_parts = build_label_parts(semantic_model, &typ);
4949
// 为空时添加默认值
5050
if label_parts.is_empty() {
51-
let typ_desc = format!(": {}", hint_humanize_type(semantic_model, &typ));
51+
let typ_desc = format!(
52+
": {}",
53+
hint_humanize_type(semantic_model, &typ, RenderLevel::Simple)
54+
);
5255
label_parts.push(InlayHintLabelPart {
5356
value: typ_desc,
5457
location: Some(
@@ -134,7 +137,7 @@ fn get_part(semantic_model: &SemanticModel, typ: &LuaType) -> Option<InlayHintLa
134137
});
135138
}
136139
_ => {
137-
let value = hint_humanize_type(semantic_model, typ);
140+
let value = hint_humanize_type(semantic_model, typ, RenderLevel::Simple);
138141
let location = get_type_location(semantic_model, typ);
139142
return Some(InlayHintLabelPart {
140143
value,
@@ -184,7 +187,7 @@ fn get_base_type_location(semantic_model: &SemanticModel, name: &str) -> Option<
184187
Some(Location::new(document.get_uri(), lsp_range))
185188
}
186189

187-
fn hint_humanize_type(semantic_model: &SemanticModel, typ: &LuaType) -> String {
190+
fn hint_humanize_type(semantic_model: &SemanticModel, typ: &LuaType, level: RenderLevel) -> String {
188191
match typ {
189192
LuaType::Ref(id) | LuaType::Def(id) => {
190193
let namespace = semantic_model
@@ -204,13 +207,17 @@ fn hint_humanize_type(semantic_model: &SemanticModel, typ: &LuaType) -> String {
204207
id.get_name().to_string()
205208
}
206209
}
207-
LuaType::Union(union) => hint_humanize_union_type(semantic_model, union),
208-
_ => humanize_type(semantic_model.get_db(), typ, RenderLevel::Simple),
210+
LuaType::Union(union) => hint_humanize_union_type(semantic_model, union, level),
211+
_ => humanize_type(semantic_model.get_db(), typ, level),
209212
}
210213
}
211214

212-
fn hint_humanize_union_type(semantic_model: &SemanticModel, union: &LuaUnionType) -> String {
213-
format_union_type(union, RenderLevel::Simple, |ty, _| {
214-
hint_humanize_type(semantic_model, ty)
215+
fn hint_humanize_union_type(
216+
semantic_model: &SemanticModel,
217+
union: &LuaUnionType,
218+
level: RenderLevel,
219+
) -> String {
220+
format_union_type(union, level, |ty, _| {
221+
hint_humanize_type(semantic_model, ty, level)
215222
})
216223
}

0 commit comments

Comments
 (0)