Skip to content

Commit

Permalink
light up method parameters!
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel committed Oct 14, 2023
1 parent a01db57 commit 2ecb8f6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/FsAutoComplete.Core/InlayHints.fs
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,8 @@ let provideHints
parameterHints.Add hint

| :? FSharpMemberOrFunctionOrValue as methodOrConstructor when
hintConfig.ShowParameterHints && methodOrConstructor.IsConstructor
hintConfig.ShowParameterHints
&& (methodOrConstructor.IsConstructor || methodOrConstructor.IsMethod)
-> // TODO: support methods when this API comes into FCS
let endPosForMethod = symbolUse.Range.End
let line, _ = Position.toZ endPosForMethod
Expand Down Expand Up @@ -1004,7 +1005,10 @@ let provideHints
for (definitionArg, appliedArgRange) in parms do
let! appliedArgText = text[appliedArgRange]

if ShouldCreate.paramHint methodOrConstructor definitionArg appliedArgText then
let shouldCreate =
ShouldCreate.paramHint methodOrConstructor definitionArg appliedArgText

if shouldCreate then
let hint = createParamHint appliedArgRange definitionArg.DisplayName
parameterHints.Add(hint)

Expand Down
27 changes: 27 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/InlayHintTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,33 @@ let private paramHintTests state =
"""
[ paramHint "uriString"; paramHint "uriKind" ]

testCaseAsync "can show param for method applied in curried form"
<| checkAllInMarkedRange
server
"""
$|System.Environment.GetFolderPath $0System.Environment.SpecialFolder.Desktop
|> ignore$|
"""
[ paramHint "folder" ]

testCaseAsync "can show param for method called in tuple form"
<| checkAllInMarkedRange
server
"""
$|System.Environment.GetFolderPath($0System.Environment.SpecialFolder.Desktop)
|> ignore$|
"""
[ paramHint "folder" ]

testCaseAsync "can show param for method called in tuple form with multiple parameters"
<| checkAllInMarkedRange
server
"""
$|System.Environment.GetFolderPath($0System.Environment.SpecialFolder.Desktop, $0System.Environment.SpecialFolderOption.Create)
|> ignore$|
"""
[ paramHint "folder"; paramHint "option" ]

testCaseAsync "can show param for name in backticks"
<| checkAllInMarkedRange
server
Expand Down

0 comments on commit 2ecb8f6

Please sign in to comment.