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

Generate parameter name in sighelp when there is no public parameter name #10761

Merged
merged 3 commits into from
Dec 22, 2020
Merged
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
21 changes: 14 additions & 7 deletions vsintegration/src/FSharp.Editor/Completion/SignatureHelp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -360,38 +360,45 @@ type internal FSharpSignatureHelpProvider
let displayArgs = ResizeArray()

// Offset by 1 here until we support reverse indexes in this codebase
for argument in definedArgs.[.. definedArgs.Length - 1 - numArgsAlreadyApplied] do
definedArgs.[.. definedArgs.Length - 1 - numArgsAlreadyApplied] |> Array.iteri (fun index argument ->
let taggedText = ResizeArray()
let tt = ResizeArray()
let layout = argument.Type.FormatLayout symbolUse.DisplayContext
LayoutRender.emitL taggedText.Add layout |> ignore
for part in taggedText do
RoslynHelpers.CollectTaggedText tt part

let name =
if String.IsNullOrWhiteSpace(argument.DisplayName) then
"arg" + string index
else
argument.DisplayName

let display =
[|
RoslynTaggedText(TextTags.Local, argument.DisplayName)
RoslynTaggedText(TextTags.Local, name)
RoslynTaggedText(TextTags.Punctuation, ":")
RoslynTaggedText(TextTags.Space, " ")
|]
|> ResizeArray

if argument.Type.IsFunctionType then
display.Add(TaggedText(TextTags.Punctuation, "("))
display.Add(RoslynTaggedText(TextTags.Punctuation, "("))

display.AddRange(tt)

if argument.Type.IsFunctionType then
display.Add(TaggedText(TextTags.Punctuation, ")"))
display.Add(RoslynTaggedText(TextTags.Punctuation, ")"))

let info =
{ ParameterName = argument.DisplayName
{ ParameterName = name
IsOptional = false
CanonicalTypeTextForSorting = argument.FullName
// No need to do anything different here, as this field is only relevant for overloaded parameter names in methods.
CanonicalTypeTextForSorting = name
Documentation = ResizeArray()
DisplayParts = display }

displayArgs.Add(info)
displayArgs.Add(info))

do! Option.guard (displayArgs.Count > 0)

Expand Down