File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed
tests/FSharp.Editor.Tests/Hints Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ type InlineParameterNameHints(parseResults: FSharpParseFileResults) =
5454 >> Seq.map ( fun location -> location.ArgumentRange)
5555 >> Seq.contains range
5656
57+ let isCustomOperation ( symbol : FSharpMemberOrFunctionOrValue ) =
58+ symbol.HasAttribute< CustomOperationAttribute>()
59+
5760 let getSourceTextAtRange ( sourceText : SourceText ) ( range : range ) =
5861 ( RoslynHelpers.FSharpRangeToTextSpan( sourceText, range) |> sourceText.GetSubText)
5962 .ToString()
@@ -65,11 +68,9 @@ type InlineParameterNameHints(parseResults: FSharpParseFileResults) =
6568 symbol.DeclaringEntity
6669 |> Option.exists ( fun entity -> entity.CompiledName <> " Operators" )
6770
68- let isNotCustomOperation = not <| symbol.HasAttribute< CustomOperationAttribute>()
69-
7071 ( symbol.IsFunction && isNotBuiltInOperator) // arguably, hints for those would be rather useless
7172 || symbol.IsConstructor
72- || ( symbol.IsMethod && isNotCustomOperation )
73+ || symbol.IsMethod
7374 else
7475 false
7576
@@ -100,8 +101,10 @@ type InlineParameterNameHints(parseResults: FSharpParseFileResults) =
100101 |> Seq.filter ( fun range -> argumentLocations |> ( not << isNamedArgument range))
101102
102103 let argumentNames = Seq.map ( getSourceTextAtRange sourceText) ranges
104+ let skipped = if symbol |> isCustomOperation then 1 else 0
103105
104106 parameters
107+ |> Seq.skip skipped
105108 |> Seq.zip ranges // Seq.zip is important as List.zip requires equal lengths
106109 |> Seq.where ( snd >> parameterNameExists)
107110 |> Seq.zip argumentNames
Original file line number Diff line number Diff line change @@ -481,17 +481,38 @@ let test sequences =
481481 Assert.Equal( expected, actual)
482482
483483 [<Fact>]
484- let ``Hints are not shown when CustomOperation attribute is detected `` () =
484+ let ``Hints are shown correctly for custom operations `` () =
485485 let code =
486486 """
487487let q = query { for x in { 1 .. 10 } do select x }
488488"""
489489
490490 let document = getFsDocument code
491491
492+ let expected =
493+ [
494+ {
495+ Content = " projection = "
496+ Location = ( 1 , 48 )
497+ }
498+ ]
499+
500+ let actual = getParameterNameHints document
501+
502+ Assert.Equal( expected, actual)
503+
504+ [<Fact>]
505+ let ``Hints are not shown for custom operations with only 1 parameter`` () =
506+ let code =
507+ """
508+ let q = query { for _ in { 1 .. 10 } do count }
509+ """
510+
511+ let document = getFsDocument code
512+
492513 let actual = getParameterNameHints document
493514
494- Assert.Empty actual
515+ Assert.Empty( actual)
495516
496517 [<Fact>]
497518 let ``Hints are not shown when parameter names coincide with variable names`` () =
You can’t perform that action at this time.
0 commit comments