@@ -55,7 +55,7 @@ pub fn build_closure_hint(
55
55
label_parts. push ( InlayHintLabelPart {
56
56
value : typ_desc,
57
57
location : Some (
58
- get_type_location ( semantic_model, typ)
58
+ get_type_location ( semantic_model, typ, 0 )
59
59
. unwrap_or ( Location :: new ( document. get_uri ( ) , lsp_range) ) ,
60
60
) ,
61
61
..Default :: default ( )
@@ -132,13 +132,13 @@ fn get_part(semantic_model: &SemanticModel, typ: &LuaType) -> Option<InlayHintLa
132
132
LuaType :: Nil => {
133
133
return Some ( InlayHintLabelPart {
134
134
value : "?" . to_string ( ) ,
135
- location : get_type_location ( semantic_model, typ) ,
135
+ location : get_type_location ( semantic_model, typ, 0 ) ,
136
136
..Default :: default ( )
137
137
} ) ;
138
138
}
139
139
_ => {
140
140
let value = hint_humanize_type ( semantic_model, typ, RenderLevel :: Simple ) ;
141
- let location = get_type_location ( semantic_model, typ) ;
141
+ let location = get_type_location ( semantic_model, typ, 0 ) ;
142
142
return Some ( InlayHintLabelPart {
143
143
value,
144
144
location,
@@ -148,7 +148,14 @@ fn get_part(semantic_model: &SemanticModel, typ: &LuaType) -> Option<InlayHintLa
148
148
}
149
149
}
150
150
151
- fn get_type_location ( semantic_model : & SemanticModel , typ : & LuaType ) -> Option < Location > {
151
+ fn get_type_location (
152
+ semantic_model : & SemanticModel ,
153
+ typ : & LuaType ,
154
+ depth : usize ,
155
+ ) -> Option < Location > {
156
+ if depth > 10 {
157
+ return None ;
158
+ }
152
159
match typ {
153
160
LuaType :: Ref ( id) | LuaType :: Def ( id) => {
154
161
let type_decl = semantic_model
@@ -162,9 +169,11 @@ fn get_type_location(semantic_model: &SemanticModel, typ: &LuaType) -> Option<Lo
162
169
}
163
170
LuaType :: Generic ( generic) => {
164
171
let base_type_id = generic. get_base_type_id ( ) ;
165
- get_type_location ( semantic_model, & LuaType :: Ref ( base_type_id) )
172
+ get_type_location ( semantic_model, & LuaType :: Ref ( base_type_id) , depth + 1 )
173
+ }
174
+ LuaType :: Array ( array_type) => {
175
+ get_type_location ( semantic_model, array_type. get_base ( ) , depth + 1 )
166
176
}
167
- LuaType :: Array ( array_type) => get_type_location ( semantic_model, array_type. get_base ( ) ) ,
168
177
LuaType :: Any => get_base_type_location ( semantic_model, "any" ) ,
169
178
LuaType :: Nil => get_base_type_location ( semantic_model, "nil" ) ,
170
179
LuaType :: Unknown => get_base_type_location ( semantic_model, "unknown" ) ,
0 commit comments