@@ -116,8 +116,8 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
116
116
use writeCookie = WriteLockCookie.Create( binding.IsPhysical())
117
117
use disableFormatter = new DisableCodeFormatter()
118
118
119
- let factory = signatureModuleOrNamespaceDecl .CreateElementFactory()
120
- let typeInfo = factory.CreateTypeUsageForSignature ( text)
119
+ let factory = binding .CreateElementFactory()
120
+ let typeInfo = factory.CreateTypeUsage ( text, TypeUsageContext.Return )
121
121
122
122
// Enrich the type info with the found parameters from binding.
123
123
let rec visit ( index : int ) ( t : ITypeUsage ) =
@@ -127,7 +127,9 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
127
127
// If the return type is a function itself, the safest thing to do is to wrap it in parentheses.
128
128
// Example: `let g _ = (*) 3`
129
129
// `val g: 'a -> int -> int` is not valid, `val g: 'a -> (int -> int)` is.
130
- replace t ( factory.WrapParenAroundTypeUsageForSignature( t))
130
+ let parenType = factory.CreateParenType()
131
+ replace parenType.InnerTypeUsage t
132
+ replace t parenType
131
133
| _ -> ()
132
134
else
133
135
let parameterAtIndex = tryFindParameterName true ( binding.ParameterPatterns.Item( index))
@@ -139,8 +141,7 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
139
141
| :? IFunctionTypeUsage as ft, ParameterNameFromPattern.SingleName ( name, attributes) ->
140
142
match ft.ArgumentTypeUsage with
141
143
| :? IParameterSignatureTypeUsage as pstu ->
142
- factory.CreateParameterSignatureTypeUsage( attributes, name, pstu.TypeUsage)
143
- |> replace ft.ArgumentTypeUsage
144
+ pstu.SetIdentifier( name) |> ignore
144
145
| _ -> ()
145
146
146
147
visit ( index + 1 ) ft.ReturnTypeUsage
@@ -153,8 +154,7 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
153
154
|> Seq.iter ( fun ( p , t ) ->
154
155
match t, p with
155
156
| :? IParameterSignatureTypeUsage as pstu, ParameterNameFromPattern.SingleName ( name, attributes) ->
156
- factory.CreateParameterSignatureTypeUsage( attributes, name, pstu.TypeUsage)
157
- |> replace t
157
+ pstu.SetIdentifier( name) |> ignore
158
158
| _ -> ()
159
159
)
160
160
| _ -> visit ( index + 1 ) ft.ReturnTypeUsage
@@ -164,7 +164,10 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
164
164
if not binding.ParameterPatterns.IsEmpty then
165
165
visit 0 typeInfo
166
166
167
- let valSig = factory.CreateBindingSignature( refPat, typeInfo)
167
+ let valSig =
168
+ let signatureFactory = signatureModuleOrNamespaceDecl.CreateElementFactory()
169
+ signatureFactory.CreateBindingSignature( refPat, typeInfo)
170
+
168
171
let newlineNode = NewLine( signatureModuleOrNamespaceDecl.GetLineEnding()) :> ITreeNode
169
172
addNodesAfter signatureModuleOrNamespaceDecl.LastChild [| newlineNode; valSig |] |> ignore
170
173
0 commit comments