@@ -589,6 +589,46 @@ function textDocument_inlayHint_request(params::InlayHintParams, server::Languag
589589 return collect_inlay_hints (getcst (doc), server, doc, start, stop)
590590end
591591
592+ function get_inlay_parameter_hints (x:: EXPR , server:: LanguageServerInstance , doc, pos= 0 )
593+ if server. inlay_hints_parameter_names === :all || (
594+ server. inlay_hints_parameter_names === :literals &&
595+ CSTParser. isliteral (x)
596+ )
597+ sigs = collect_signatures (x, doc, server)
598+
599+ nargs = length (parentof (x). args) - 1
600+ nargs == 0 && return nothing
601+
602+ filter! (s -> length (s. parameters) == nargs, sigs)
603+ isempty (sigs) && return nothing
604+
605+ pars = first (sigs). parameters
606+ thisarg = 0
607+ for a in parentof (x). args
608+ if x == a
609+ break
610+ end
611+ thisarg += 1
612+ end
613+ if thisarg <= nargs && thisarg <= length (pars)
614+ label = pars[thisarg]. label
615+ label == " #unused#" && return nothing
616+
617+ return InlayHint (
618+ Position (get_position_from_offset (doc, pos)... ),
619+ string (label, ' :' ),
620+ InlayHintKinds. Parameter,
621+ missing ,
622+ pars[thisarg]. documentation,
623+ false ,
624+ true ,
625+ missing
626+ )
627+ end
628+ end
629+ return nothing
630+ end
631+
592632function collect_inlay_hints (x:: EXPR , server:: LanguageServerInstance , doc, start, stop, pos= 0 , hints= InlayHint[])
593633 if x isa EXPR && parentof (x) isa EXPR &&
594634 CSTParser. iscall (parentof (x)) &&
@@ -597,47 +637,9 @@ function collect_inlay_hints(x::EXPR, server::LanguageServerInstance, doc, start
597637 CSTParser. defines_function (parentof (parentof (x)))
598638 ) &&
599639 parentof (x). args[1 ] != x # function calls
600-
601- if server. inlay_hints_parameter_names === :all || (
602- server. inlay_hints_parameter_names === :literals &&
603- CSTParser. isliteral (x)
604- )
605- sigs = collect_signatures (x, doc, server)
606- if ! isempty (sigs)
607- args = length (parentof (x). args) - 1
608- if args > 0
609- filter! (s -> length (s. parameters) == args, sigs)
610- if ! isempty (sigs)
611- pars = first (sigs). parameters
612- thisarg = 0
613- for a in parentof (x). args
614- if x == a
615- break
616- end
617- thisarg += 1
618- end
619- if thisarg <= args && thisarg <= length (pars)
620- label = pars[thisarg]. label
621- if label == " #unused#"
622- label = " _"
623- end
624- push! (
625- hints,
626- InlayHint (
627- Position (get_position_from_offset (doc, pos)... ),
628- string (label, ' :' ),
629- InlayHintKinds. Parameter,
630- missing ,
631- pars[thisarg]. documentation,
632- false ,
633- true ,
634- missing
635- )
636- )
637- end
638- end
639- end
640- end
640+ maybe_hint = get_inlay_parameter_hints (x, server, doc, pos)
641+ if maybe_hint != = nothing
642+ push! (hints, maybe_hint)
641643 end
642644 elseif x isa EXPR && parentof (x) isa EXPR &&
643645 CSTParser. isassignment (parentof (x)) &&
0 commit comments