Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make inlay hints more like named parameters and no short or redundant labels #1320

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/requests/features.jl
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@
sigs = collect_signatures(x, doc, server)

nargs = length(parentof(x).args) - 1
nargs == 0 && return nothing
nargs < 2 && return nothing

Check warning on line 600 in src/requests/features.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/features.jl#L600

Added line #L600 was not covered by tests

filter!(s -> length(s.parameters) == nargs, sigs)
isempty(sigs) && return nothing
Expand All @@ -613,15 +613,23 @@
if thisarg <= nargs && thisarg <= length(pars)
label = pars[thisarg].label
label == "#unused#" && return nothing
length(label) <= 2 && return nothing
CSTParser.str_value(x) == label && return nothing
x.head == :parameters && return nothing
if x.head isa CSTParser.EXPR && x.head.head == :OPERATOR && x.head.val == "."
if x.args[end] isa CSTParser.EXPR && x.args[end].args[end] isa CSTParser.EXPR
x.args[end].args[end].val == label && return nothing

Check warning on line 621 in src/requests/features.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/features.jl#L616-L621

Added lines #L616 - L621 were not covered by tests
end
end

return InlayHint(
Position(get_position_from_offset(doc, pos)...),
string(label, ':'),
string(label, "="),
InlayHintKinds.Parameter,
missing,
pars[thisarg].documentation,
false,
true,
false,
missing
)
end
Expand Down
Loading