From f149ec8b36960e3854bf9556f477d127fbff0fce Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Tue, 19 Nov 2024 01:54:21 +0300 Subject: [PATCH 1/4] Inlay hints/Patterns: support optional parameters --- .../src/Stages/PatternTypeHintsStage.fs | 7 +++ .../src/Util/TypeAnnotationsUtil.fs | 4 +- .../daemon/typeHints/Disabled 01.fs.gold | 5 ++ .../typeHints/Disabled 02 - By mode.fs.gold | 5 ++ .../typeHints/Signatures - Locals 01.fs.gold | 5 ++ .../Signatures - Show all 01.fs.gold | 57 +++++++++++-------- .../Signatures - Top level 01.fs.gold | 51 ++++++++++------- .../features/daemon/typeHints/_TestSource.fs | 5 ++ 8 files changed, 91 insertions(+), 48 deletions(-) diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/PatternTypeHintsStage.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/PatternTypeHintsStage.fs index 1ae714c1cf..e48be8c70a 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/PatternTypeHintsStage.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/PatternTypeHintsStage.fs @@ -169,6 +169,13 @@ type private PatternsHighlightingProcess(fsFile, settingsStore: IContextBoundSet let fcsType = symbol.FullType let range = pattern.GetNavigationRange().EndOffsetRange() + let isOptional = isNotNull (OptionalValPatNavigator.GetByPattern(refPat)) + let fcsType = + if isOptional then + let genericParameters = fcsType.GenericArguments + if genericParameters.Count = 0 then fcsType else fcsType.GenericArguments[0] + else fcsType + createTypeHintHighlighting fcsType defaultDisplayContext range pushToHintMode actionsProvider false |> ValueSome diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/TypeAnnotationsUtil.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/TypeAnnotationsUtil.fs index e2940c9b49..99b8571dcb 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/TypeAnnotationsUtil.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Services/src/Util/TypeAnnotationsUtil.fs @@ -6,7 +6,7 @@ open JetBrains.ReSharper.Psi.Tree let rec private visitPattern (acc: ITreeNode list) (pattern: IFSharpPattern) = match pattern with | null - | :? IUnitPat + | :? IConstPat | :? IWildPat | :? ITypedPat -> acc @@ -31,6 +31,8 @@ let rec private visitPattern (acc: ITreeNode list) (pattern: IFSharpPattern) = parametersOwnerPat.ParametersEnumerable |> Seq.fold visitPattern acc + | :? IOptionalValPat as optionalPat -> visitPattern acc optionalPat.Pattern + | :? INamedUnionCaseFieldsPat as unionCaseFieldsPat -> unionCaseFieldsPat.FieldPatternsEnumerable |> Seq.fold visitPattern acc diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 01.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 01.fs.gold index 736bcaaf9f..2d3d75ed1e 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 01.fs.gold @@ -2,6 +2,7 @@ open System open System.Collections.Generic +open System.Runtime.InteropServices type SingleCaseDU<'a, 'b> = SingleCaseDU of x: 'a type Record = { Foo: int; Bar: string } @@ -67,6 +68,8 @@ type A(x) = let res = x + y + z res + member _.M1([] ?x) = x.Value + 1 + interface IDisposable with member _.Dispose() = () @@ -99,6 +102,8 @@ type Typed(x: int) = let res: int = x + y + z res + member _.M1([] ?x: int) : int = x.Value + 1 + interface IDisposable with member _.Dispose(): unit = () diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 02 - By mode.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 02 - By mode.fs.gold index 736bcaaf9f..2d3d75ed1e 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 02 - By mode.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 02 - By mode.fs.gold @@ -2,6 +2,7 @@ open System open System.Collections.Generic +open System.Runtime.InteropServices type SingleCaseDU<'a, 'b> = SingleCaseDU of x: 'a type Record = { Foo: int; Bar: string } @@ -67,6 +68,8 @@ type A(x) = let res = x + y + z res + member _.M1([] ?x) = x.Value + 1 + interface IDisposable with member _.Dispose() = () @@ -99,6 +102,8 @@ type Typed(x: int) = let res: int = x + y + z res + member _.M1([] ?x: int) : int = x.Value + 1 + interface IDisposable with member _.Dispose(): unit = () diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Locals 01.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Locals 01.fs.gold index 7f410803de..7201cb469a 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Locals 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Locals 01.fs.gold @@ -2,6 +2,7 @@ open System open System.Collections.Generic +open System.Runtime.InteropServices type SingleCaseDU<'a, 'b> = SingleCaseDU of x: 'a type Record = { Foo: int; Bar: string } @@ -67,6 +68,8 @@ type A(x) = let res||(11) = x + y + z res + member _.M1([] ?x) = x.Value + 1 + interface IDisposable with member _.Dispose() = () @@ -99,6 +102,8 @@ type Typed(x: int) = let res: int = x + y + z res + member _.M1([] ?x: int) : int = x.Value + 1 + interface IDisposable with member _.Dispose(): unit = () diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Show all 01.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Show all 01.fs.gold index 51a32f9826..c48b6b60dc 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Show all 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Show all 01.fs.gold @@ -2,6 +2,7 @@ open System open System.Collections.Generic +open System.Runtime.InteropServices type SingleCaseDU<'a, 'b> = SingleCaseDU of x: 'a type Record = { Foo: int; Bar: string } @@ -67,8 +68,10 @@ type A(x||(24)) = let res||(41) = x + y + z res + member _.M1([] ?x||(42)) ||(43)= x.Value + 1 + interface IDisposable with - member _.Dispose() ||(42)= () + member _.Dispose() ||(44)= () type Typed(x: int) = @@ -88,7 +91,7 @@ type Typed(x: int) = member val P3: int = 3 with get, set - member x.P4||(43) + member x.P4||(45) with get (index: int) = let x: string = array[index] x @@ -99,12 +102,14 @@ type Typed(x: int) = let res: int = x + y + z res + member _.M1([] ?x: int) : int = x.Value + 1 + interface IDisposable with member _.Dispose(): unit = () -let delimiter (delim1||(44), delim2||(45), value||(46)) ||(47)= +let delimiter (delim1||(46), delim2||(47), value||(48)) ||(49)= { new IFormattable with - member x.ToString(format||(48), provider||(49)) ||(50)= + member x.ToString(format||(50), provider||(51)) ||(52)= if format = "D" then delim1 + value + delim2 else @@ -116,19 +121,19 @@ type MyStruct = val mutable myString : string -let (|Active|) arg||(51) valueToMatch||(52) ||(53)= +let (|Active|) arg||(53) valueToMatch||(54) ||(55)= Active(if arg && valueToMatch = 2 then "" else "") -let (|Active1|Active2|) valueToMatch||(54) ||(55)= +let (|Active1|Active2|) valueToMatch||(56) ||(57)= if valueToMatch then Choice1Of2(1) else Choice2Of2("") -let (|ActiveOption|_|) _ ||(56)= None +let (|ActiveOption|_|) _ ||(58)= None let (|Int|) (x: MyStruct) : int = Int(x.myInt) let (|String|) (x: MyStruct) : string = String(x.myString) -let f1 (x||(57) & Int(i||(58)) & String(s||(59))) ||(60)= () +let f1 (x||(59) & Int(i||(60)) & String(s||(61))) ||(62)= () --------------------------------------------------------- (0): ReSharper Parameter Name Hint: : 'b @@ -173,22 +178,24 @@ let f1 (x||(57) & Int(i||(58)) & String(s||(59))) ||(60)= () (39): ReSharper Parameter Name Hint: : int (40): ReSharper Parameter Name Hint: : int (41): ReSharper Parameter Name Hint: : int -(42): ReSharper Parameter Name Hint: : unit -(43): ReSharper Parameter Name Hint: : string -(44): ReSharper Parameter Name Hint: : string -(45): ReSharper Parameter Name Hint: : string +(42): ReSharper Parameter Name Hint: : int +(43): ReSharper Parameter Name Hint: : int +(44): ReSharper Parameter Name Hint: : unit +(45): ReSharper Parameter Name Hint: : string (46): ReSharper Parameter Name Hint: : string -(47): ReSharper Parameter Name Hint: : IFormattable +(47): ReSharper Parameter Name Hint: : string (48): ReSharper Parameter Name Hint: : string -(49): ReSharper Parameter Name Hint: : IFormatProvider -(50): ReSharper Parameter Name Hint: : string -(51): ReSharper Parameter Name Hint: : bool -(52): ReSharper Parameter Name Hint: : int -(53): ReSharper Parameter Name Hint: : string -(54): ReSharper Parameter Name Hint: : bool -(55): ReSharper Parameter Name Hint: : Choice -(56): ReSharper Parameter Name Hint: : 'b option -(57): ReSharper Parameter Name Hint: : MyStruct -(58): ReSharper Parameter Name Hint: : int -(59): ReSharper Parameter Name Hint: : string -(60): ReSharper Parameter Name Hint: : unit +(49): ReSharper Parameter Name Hint: : IFormattable +(50): ReSharper Parameter Name Hint: : string +(51): ReSharper Parameter Name Hint: : IFormatProvider +(52): ReSharper Parameter Name Hint: : string +(53): ReSharper Parameter Name Hint: : bool +(54): ReSharper Parameter Name Hint: : int +(55): ReSharper Parameter Name Hint: : string +(56): ReSharper Parameter Name Hint: : bool +(57): ReSharper Parameter Name Hint: : Choice +(58): ReSharper Parameter Name Hint: : 'b option +(59): ReSharper Parameter Name Hint: : MyStruct +(60): ReSharper Parameter Name Hint: : int +(61): ReSharper Parameter Name Hint: : string +(62): ReSharper Parameter Name Hint: : unit diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Top level 01.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Top level 01.fs.gold index 2ca02fa7ad..6cb8d33f9f 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Top level 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Top level 01.fs.gold @@ -2,6 +2,7 @@ open System open System.Collections.Generic +open System.Runtime.InteropServices type SingleCaseDU<'a, 'b> = SingleCaseDU of x: 'a type Record = { Foo: int; Bar: string } @@ -67,8 +68,10 @@ type A(x||(16)) = let res = x + y + z res + member _.M1([] ?x||(31)) ||(32)= x.Value + 1 + interface IDisposable with - member _.Dispose() ||(31)= () + member _.Dispose() ||(33)= () type Typed(x: int) = @@ -88,7 +91,7 @@ type Typed(x: int) = member val P3: int = 3 with get, set - member x.P4||(32) + member x.P4||(34) with get (index: int) = let x: string = array[index] x @@ -99,10 +102,12 @@ type Typed(x: int) = let res: int = x + y + z res + member _.M1([] ?x: int) : int = x.Value + 1 + interface IDisposable with member _.Dispose(): unit = () -let delimiter (delim1||(33), delim2||(34), value||(35)) ||(36)= +let delimiter (delim1||(35), delim2||(36), value||(37)) ||(38)= { new IFormattable with member x.ToString(format, provider) = if format = "D" then @@ -116,19 +121,19 @@ type MyStruct = val mutable myString : string -let (|Active|) arg||(37) valueToMatch||(38) ||(39)= +let (|Active|) arg||(39) valueToMatch||(40) ||(41)= Active(if arg && valueToMatch = 2 then "" else "") -let (|Active1|Active2|) valueToMatch||(40) ||(41)= +let (|Active1|Active2|) valueToMatch||(42) ||(43)= if valueToMatch then Choice1Of2(1) else Choice2Of2("") -let (|ActiveOption|_|) _ ||(42)= None +let (|ActiveOption|_|) _ ||(44)= None let (|Int|) (x: MyStruct) : int = Int(x.myInt) let (|String|) (x: MyStruct) : string = String(x.myString) -let f1 (x||(43) & Int(i||(44)) & String(s||(45))) ||(46)= () +let f1 (x||(45) & Int(i||(46)) & String(s||(47))) ||(48)= () --------------------------------------------------------- (0): ReSharper Parameter Name Hint: : 'b @@ -162,19 +167,21 @@ let f1 (x||(43) & Int(i||(44)) & String(s||(45))) ||(46)= () (28): ReSharper Parameter Name Hint: : int (29): ReSharper Parameter Name Hint: : int (30): ReSharper Parameter Name Hint: : int -(31): ReSharper Parameter Name Hint: : unit -(32): ReSharper Parameter Name Hint: : string -(33): ReSharper Parameter Name Hint: : string -(34): ReSharper Parameter Name Hint: : string +(31): ReSharper Parameter Name Hint: : int +(32): ReSharper Parameter Name Hint: : int +(33): ReSharper Parameter Name Hint: : unit +(34): ReSharper Parameter Name Hint: : string (35): ReSharper Parameter Name Hint: : string -(36): ReSharper Parameter Name Hint: : IFormattable -(37): ReSharper Parameter Name Hint: : bool -(38): ReSharper Parameter Name Hint: : int -(39): ReSharper Parameter Name Hint: : string -(40): ReSharper Parameter Name Hint: : bool -(41): ReSharper Parameter Name Hint: : Choice -(42): ReSharper Parameter Name Hint: : 'b option -(43): ReSharper Parameter Name Hint: : MyStruct -(44): ReSharper Parameter Name Hint: : int -(45): ReSharper Parameter Name Hint: : string -(46): ReSharper Parameter Name Hint: : unit +(36): ReSharper Parameter Name Hint: : string +(37): ReSharper Parameter Name Hint: : string +(38): ReSharper Parameter Name Hint: : IFormattable +(39): ReSharper Parameter Name Hint: : bool +(40): ReSharper Parameter Name Hint: : int +(41): ReSharper Parameter Name Hint: : string +(42): ReSharper Parameter Name Hint: : bool +(43): ReSharper Parameter Name Hint: : Choice +(44): ReSharper Parameter Name Hint: : 'b option +(45): ReSharper Parameter Name Hint: : MyStruct +(46): ReSharper Parameter Name Hint: : int +(47): ReSharper Parameter Name Hint: : string +(48): ReSharper Parameter Name Hint: : unit diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/_TestSource.fs b/ReSharper.FSharp/test/data/features/daemon/typeHints/_TestSource.fs index fa7a922488..f05929e737 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/_TestSource.fs +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/_TestSource.fs @@ -2,6 +2,7 @@ module Test open System open System.Collections.Generic +open System.Runtime.InteropServices type SingleCaseDU<'a, 'b> = SingleCaseDU of x: 'a type Record = { Foo: int; Bar: string } @@ -67,6 +68,8 @@ type A(x) = let res = x + y + z res + member _.M1([] ?x) = x.Value + 1 + interface IDisposable with member _.Dispose() = () @@ -99,6 +102,8 @@ type Typed(x: int) = let res: int = x + y + z res + member _.M1([] ?x: int) : int = x.Value + 1 + interface IDisposable with member _.Dispose(): unit = () From f81ea07cab39842d504ac7aaa8a1361854fb62d5 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Tue, 19 Nov 2024 01:59:44 +0300 Subject: [PATCH 2/4] wip --- .../FSharp.Psi.Daemon/src/Stages/PatternTypeHintsStage.fs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/PatternTypeHintsStage.fs b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/PatternTypeHintsStage.fs index e48be8c70a..33fd413aa8 100644 --- a/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/PatternTypeHintsStage.fs +++ b/ReSharper.FSharp/src/FSharp/FSharp.Psi.Daemon/src/Stages/PatternTypeHintsStage.fs @@ -12,6 +12,7 @@ open JetBrains.ReSharper.Plugins.FSharp.Psi.Features.Daemon.Stages open JetBrains.ReSharper.Plugins.FSharp.Psi.Impl open JetBrains.ReSharper.Plugins.FSharp.Psi.Tree open JetBrains.ReSharper.Plugins.FSharp.Settings +open JetBrains.ReSharper.Plugins.FSharp.Util open JetBrains.ReSharper.Psi.Tree open JetBrains.TextControl.DocumentMarkup.Adornments open JetBrains.ReSharper.Plugins.FSharp.Psi.Services.Util.TypeAnnotationsUtil @@ -170,11 +171,7 @@ type private PatternsHighlightingProcess(fsFile, settingsStore: IContextBoundSet let range = pattern.GetNavigationRange().EndOffsetRange() let isOptional = isNotNull (OptionalValPatNavigator.GetByPattern(refPat)) - let fcsType = - if isOptional then - let genericParameters = fcsType.GenericArguments - if genericParameters.Count = 0 then fcsType else fcsType.GenericArguments[0] - else fcsType + let fcsType = if isOptional && isOption fcsType then fcsType.GenericArguments[0] else fcsType createTypeHintHighlighting fcsType defaultDisplayContext range pushToHintMode actionsProvider false |> ValueSome From 97d4c43e4b2bac9d340563a31d293c7de8d8b488 Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Tue, 19 Nov 2024 03:13:23 +0300 Subject: [PATCH 3/4] wip --- .../typeHints/Disabled 02 - By mode.fs.gold | 4 +- .../typeHints/Signatures - Locals 01.fs.gold | 4 +- .../Signatures - Show all 01.fs.gold | 57 ++++++++++--------- .../Signatures - Top level 01.fs.gold | 49 ++++++++-------- .../features/daemon/typeHints/_TestSource.fs | 4 +- 5 files changed, 60 insertions(+), 58 deletions(-) diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 02 - By mode.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 02 - By mode.fs.gold index 2d3d75ed1e..999aec4aa5 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 02 - By mode.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 02 - By mode.fs.gold @@ -68,7 +68,7 @@ type A(x) = let res = x + y + z res - member _.M1([] ?x) = x.Value + 1 + member _.M1([] ?x, ?y) = x.Value + y.Value + 1 interface IDisposable with member _.Dispose() = () @@ -102,7 +102,7 @@ type Typed(x: int) = let res: int = x + y + z res - member _.M1([] ?x: int) : int = x.Value + 1 + member _.M1([] ?x: int, ?y: int) : int = x.Value + y.Value + 1 interface IDisposable with member _.Dispose(): unit = () diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Locals 01.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Locals 01.fs.gold index 7201cb469a..3569db89ad 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Locals 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Locals 01.fs.gold @@ -68,7 +68,7 @@ type A(x) = let res||(11) = x + y + z res - member _.M1([] ?x) = x.Value + 1 + member _.M1([] ?x, ?y) = x.Value + y.Value + 1 interface IDisposable with member _.Dispose() = () @@ -102,7 +102,7 @@ type Typed(x: int) = let res: int = x + y + z res - member _.M1([] ?x: int) : int = x.Value + 1 + member _.M1([] ?x: int, ?y: int) : int = x.Value + y.Value + 1 interface IDisposable with member _.Dispose(): unit = () diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Show all 01.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Show all 01.fs.gold index c48b6b60dc..99fa3204ed 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Show all 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Show all 01.fs.gold @@ -68,10 +68,10 @@ type A(x||(24)) = let res||(41) = x + y + z res - member _.M1([] ?x||(42)) ||(43)= x.Value + 1 + member _.M1([] ?x||(42), ?y||(43)) ||(44)= x.Value + y.Value + 1 interface IDisposable with - member _.Dispose() ||(44)= () + member _.Dispose() ||(45)= () type Typed(x: int) = @@ -91,7 +91,7 @@ type Typed(x: int) = member val P3: int = 3 with get, set - member x.P4||(45) + member x.P4||(46) with get (index: int) = let x: string = array[index] x @@ -102,14 +102,14 @@ type Typed(x: int) = let res: int = x + y + z res - member _.M1([] ?x: int) : int = x.Value + 1 + member _.M1([] ?x: int, ?y: int) : int = x.Value + y.Value + 1 interface IDisposable with member _.Dispose(): unit = () -let delimiter (delim1||(46), delim2||(47), value||(48)) ||(49)= +let delimiter (delim1||(47), delim2||(48), value||(49)) ||(50)= { new IFormattable with - member x.ToString(format||(50), provider||(51)) ||(52)= + member x.ToString(format||(51), provider||(52)) ||(53)= if format = "D" then delim1 + value + delim2 else @@ -121,19 +121,19 @@ type MyStruct = val mutable myString : string -let (|Active|) arg||(53) valueToMatch||(54) ||(55)= +let (|Active|) arg||(54) valueToMatch||(55) ||(56)= Active(if arg && valueToMatch = 2 then "" else "") -let (|Active1|Active2|) valueToMatch||(56) ||(57)= +let (|Active1|Active2|) valueToMatch||(57) ||(58)= if valueToMatch then Choice1Of2(1) else Choice2Of2("") -let (|ActiveOption|_|) _ ||(58)= None +let (|ActiveOption|_|) _ ||(59)= None let (|Int|) (x: MyStruct) : int = Int(x.myInt) let (|String|) (x: MyStruct) : string = String(x.myString) -let f1 (x||(59) & Int(i||(60)) & String(s||(61))) ||(62)= () +let f1 (x||(60) & Int(i||(61)) & String(s||(62))) ||(63)= () --------------------------------------------------------- (0): ReSharper Parameter Name Hint: : 'b @@ -179,23 +179,24 @@ let f1 (x||(59) & Int(i||(60)) & String(s||(61))) ||(62)= () (40): ReSharper Parameter Name Hint: : int (41): ReSharper Parameter Name Hint: : int (42): ReSharper Parameter Name Hint: : int -(43): ReSharper Parameter Name Hint: : int -(44): ReSharper Parameter Name Hint: : unit -(45): ReSharper Parameter Name Hint: : string -(46): ReSharper Parameter Name Hint: : string +(43): ReSharper Parameter Name Hint: : int +(44): ReSharper Parameter Name Hint: : int +(45): ReSharper Parameter Name Hint: : unit +(46): ReSharper Parameter Name Hint: : string (47): ReSharper Parameter Name Hint: : string (48): ReSharper Parameter Name Hint: : string -(49): ReSharper Parameter Name Hint: : IFormattable -(50): ReSharper Parameter Name Hint: : string -(51): ReSharper Parameter Name Hint: : IFormatProvider -(52): ReSharper Parameter Name Hint: : string -(53): ReSharper Parameter Name Hint: : bool -(54): ReSharper Parameter Name Hint: : int -(55): ReSharper Parameter Name Hint: : string -(56): ReSharper Parameter Name Hint: : bool -(57): ReSharper Parameter Name Hint: : Choice -(58): ReSharper Parameter Name Hint: : 'b option -(59): ReSharper Parameter Name Hint: : MyStruct -(60): ReSharper Parameter Name Hint: : int -(61): ReSharper Parameter Name Hint: : string -(62): ReSharper Parameter Name Hint: : unit +(49): ReSharper Parameter Name Hint: : string +(50): ReSharper Parameter Name Hint: : IFormattable +(51): ReSharper Parameter Name Hint: : string +(52): ReSharper Parameter Name Hint: : IFormatProvider +(53): ReSharper Parameter Name Hint: : string +(54): ReSharper Parameter Name Hint: : bool +(55): ReSharper Parameter Name Hint: : int +(56): ReSharper Parameter Name Hint: : string +(57): ReSharper Parameter Name Hint: : bool +(58): ReSharper Parameter Name Hint: : Choice +(59): ReSharper Parameter Name Hint: : 'b option +(60): ReSharper Parameter Name Hint: : MyStruct +(61): ReSharper Parameter Name Hint: : int +(62): ReSharper Parameter Name Hint: : string +(63): ReSharper Parameter Name Hint: : unit diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Top level 01.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Top level 01.fs.gold index 6cb8d33f9f..cadcb9bfe2 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Top level 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Signatures - Top level 01.fs.gold @@ -68,10 +68,10 @@ type A(x||(16)) = let res = x + y + z res - member _.M1([] ?x||(31)) ||(32)= x.Value + 1 + member _.M1([] ?x||(31), ?y||(32)) ||(33)= x.Value + y.Value + 1 interface IDisposable with - member _.Dispose() ||(33)= () + member _.Dispose() ||(34)= () type Typed(x: int) = @@ -91,7 +91,7 @@ type Typed(x: int) = member val P3: int = 3 with get, set - member x.P4||(34) + member x.P4||(35) with get (index: int) = let x: string = array[index] x @@ -102,12 +102,12 @@ type Typed(x: int) = let res: int = x + y + z res - member _.M1([] ?x: int) : int = x.Value + 1 + member _.M1([] ?x: int, ?y: int) : int = x.Value + y.Value + 1 interface IDisposable with member _.Dispose(): unit = () -let delimiter (delim1||(35), delim2||(36), value||(37)) ||(38)= +let delimiter (delim1||(36), delim2||(37), value||(38)) ||(39)= { new IFormattable with member x.ToString(format, provider) = if format = "D" then @@ -121,19 +121,19 @@ type MyStruct = val mutable myString : string -let (|Active|) arg||(39) valueToMatch||(40) ||(41)= +let (|Active|) arg||(40) valueToMatch||(41) ||(42)= Active(if arg && valueToMatch = 2 then "" else "") -let (|Active1|Active2|) valueToMatch||(42) ||(43)= +let (|Active1|Active2|) valueToMatch||(43) ||(44)= if valueToMatch then Choice1Of2(1) else Choice2Of2("") -let (|ActiveOption|_|) _ ||(44)= None +let (|ActiveOption|_|) _ ||(45)= None let (|Int|) (x: MyStruct) : int = Int(x.myInt) let (|String|) (x: MyStruct) : string = String(x.myString) -let f1 (x||(45) & Int(i||(46)) & String(s||(47))) ||(48)= () +let f1 (x||(46) & Int(i||(47)) & String(s||(48))) ||(49)= () --------------------------------------------------------- (0): ReSharper Parameter Name Hint: : 'b @@ -168,20 +168,21 @@ let f1 (x||(45) & Int(i||(46)) & String(s||(47))) ||(48)= () (29): ReSharper Parameter Name Hint: : int (30): ReSharper Parameter Name Hint: : int (31): ReSharper Parameter Name Hint: : int -(32): ReSharper Parameter Name Hint: : int -(33): ReSharper Parameter Name Hint: : unit -(34): ReSharper Parameter Name Hint: : string -(35): ReSharper Parameter Name Hint: : string +(32): ReSharper Parameter Name Hint: : int +(33): ReSharper Parameter Name Hint: : int +(34): ReSharper Parameter Name Hint: : unit +(35): ReSharper Parameter Name Hint: : string (36): ReSharper Parameter Name Hint: : string (37): ReSharper Parameter Name Hint: : string -(38): ReSharper Parameter Name Hint: : IFormattable -(39): ReSharper Parameter Name Hint: : bool -(40): ReSharper Parameter Name Hint: : int -(41): ReSharper Parameter Name Hint: : string -(42): ReSharper Parameter Name Hint: : bool -(43): ReSharper Parameter Name Hint: : Choice -(44): ReSharper Parameter Name Hint: : 'b option -(45): ReSharper Parameter Name Hint: : MyStruct -(46): ReSharper Parameter Name Hint: : int -(47): ReSharper Parameter Name Hint: : string -(48): ReSharper Parameter Name Hint: : unit +(38): ReSharper Parameter Name Hint: : string +(39): ReSharper Parameter Name Hint: : IFormattable +(40): ReSharper Parameter Name Hint: : bool +(41): ReSharper Parameter Name Hint: : int +(42): ReSharper Parameter Name Hint: : string +(43): ReSharper Parameter Name Hint: : bool +(44): ReSharper Parameter Name Hint: : Choice +(45): ReSharper Parameter Name Hint: : 'b option +(46): ReSharper Parameter Name Hint: : MyStruct +(47): ReSharper Parameter Name Hint: : int +(48): ReSharper Parameter Name Hint: : string +(49): ReSharper Parameter Name Hint: : unit diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/_TestSource.fs b/ReSharper.FSharp/test/data/features/daemon/typeHints/_TestSource.fs index f05929e737..38654da71a 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/_TestSource.fs +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/_TestSource.fs @@ -68,7 +68,7 @@ type A(x) = let res = x + y + z res - member _.M1([] ?x) = x.Value + 1 + member _.M1([] ?x, ?y) = x.Value + y.Value + 1 interface IDisposable with member _.Dispose() = () @@ -102,7 +102,7 @@ type Typed(x: int) = let res: int = x + y + z res - member _.M1([] ?x: int) : int = x.Value + 1 + member _.M1([] ?x: int, ?y: int) : int = x.Value + y.Value + 1 interface IDisposable with member _.Dispose(): unit = () From b59cba05037dd5b1311cdb89fb102583cc97538a Mon Sep 17 00:00:00 2001 From: "Alexey.Berezhnykh" Date: Tue, 19 Nov 2024 03:57:28 +0300 Subject: [PATCH 4/4] fix --- .../test/data/features/daemon/typeHints/Disabled 01.fs.gold | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 01.fs.gold b/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 01.fs.gold index 2d3d75ed1e..999aec4aa5 100644 --- a/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 01.fs.gold +++ b/ReSharper.FSharp/test/data/features/daemon/typeHints/Disabled 01.fs.gold @@ -68,7 +68,7 @@ type A(x) = let res = x + y + z res - member _.M1([] ?x) = x.Value + 1 + member _.M1([] ?x, ?y) = x.Value + y.Value + 1 interface IDisposable with member _.Dispose() = () @@ -102,7 +102,7 @@ type Typed(x: int) = let res: int = x + y + z res - member _.M1([] ?x: int) : int = x.Value + 1 + member _.M1([] ?x: int, ?y: int) : int = x.Value + y.Value + 1 interface IDisposable with member _.Dispose(): unit = ()