@@ -161,39 +161,45 @@ end
161161
162162get_fcall_position (x, documentation, visited= nothing ) = documentation
163163
164- function get_fcall_position (x:: EXPR , documentation, visited= EXPR[] )
164+ function get_fcall_position (x:: EXPR , documentation, visited= Set { EXPR} () )
165165 if x in visited # TODO : remove
166166 throw (LSInfiniteLoop (" Possible infinite loop." )) # TODO : remove
167167 else # TODO : remove
168168 push! (visited, x) # TODO : remove
169169 end # TODO : remove
170170 if parentof (x) isa EXPR
171171 if CSTParser. iscall (parentof (x))
172- call_counts = StaticLint. call_nargs (parentof (x))
173- call_counts[1 ] < 5 && return documentation
172+ minargs, _, _ = StaticLint. call_nargs (parentof (x))
174173 arg_i = 0
175- for (i, arg) = enumerate (parentof (x))
174+ for (i, arg) in enumerate (parentof (x))
176175 if arg == x
177176 arg_i = div (i - 1 , 2 )
178177 break
179178 end
180179 end
181- arg_i == 0 && return documentation
180+
181+ # hovering over the function name, so we might as well check the parent
182+ if arg_i == 0
183+ return get_fcall_position (parentof (x), documentation, visited)
184+ end
185+
186+ minargs < 4 && return documentation
187+
182188 fname = CSTParser. get_name (parentof (x))
183189 if StaticLint. hasref (fname) &&
184- (refof (fname) isa StaticLint. Binding && refof (fname). val isa EXPR && CSTParser. defines_struct (refof (fname). val) && StaticLint. struct_nargs (refof (fname). val)[1 ] == call_counts[ 1 ] )
190+ (refof (fname) isa StaticLint. Binding && refof (fname). val isa EXPR && CSTParser. defines_struct (refof (fname). val) && StaticLint. struct_nargs (refof (fname). val)[1 ] == minargs )
185191 dt_ex = refof (fname). val
186192 args = dt_ex. args[3 ]
187193 args. args === nothing || arg_i > length (args. args) && return documentation
188194 _fieldname = CSTParser. str_value (CSTParser. get_arg_name (args. args[arg_i]))
189195 documentation = string (" Datatype field `$_fieldname ` of $(CSTParser. str_value (CSTParser. get_name (dt_ex))) " , " \n " , documentation)
190196 elseif StaticLint. hasref (fname) && (refof (fname) isa SymbolServer. DataTypeStore || refof (fname) isa StaticLint. Binding && refof (fname). val isa SymbolServer. DataTypeStore)
191197 dts = refof (fname) isa StaticLint. Binding ? refof (fname). val : refof (fname)
192- if length (dts. fieldnames) == call_counts[ 1 ] && arg_i <= length (dts. fieldnames)
198+ if length (dts. fieldnames) == minargs && arg_i <= length (dts. fieldnames)
193199 documentation = string (" Datatype field `$(dts. fieldnames[arg_i]) `" , " \n " , documentation)
194200 end
195201 else
196- documentation = string (" Argument $arg_i of $(call_counts[ 1 ] ) in call to `" , CSTParser. str_value (fname), " `\n " , documentation)
202+ documentation = string (" Argument $arg_i of $(minargs ) in call to `" , CSTParser. str_value (fname), " `\n " , documentation)
197203 end
198204 return documentation
199205 else
0 commit comments