@@ -116,8 +116,8 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
116116 use writeCookie = WriteLockCookie.Create( binding.IsPhysical())
117117 use disableFormatter = new DisableCodeFormatter()
118118
119- let factory = signatureModuleOrNamespaceDecl .CreateElementFactory()
120- let typeInfo = factory.CreateTypeUsageForSignature ( text)
119+ let factory = binding .CreateElementFactory()
120+ let typeInfo = factory.CreateTypeUsage ( text, TypeUsageContext.Return )
121121
122122 // Enrich the type info with the found parameters from binding.
123123 let rec visit ( index : int ) ( t : ITypeUsage ) =
@@ -127,7 +127,9 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
127127 // If the return type is a function itself, the safest thing to do is to wrap it in parentheses.
128128 // Example: `let g _ = (*) 3`
129129 // `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
131133 | _ -> ()
132134 else
133135 let parameterAtIndex = tryFindParameterName true ( binding.ParameterPatterns.Item( index))
@@ -139,8 +141,7 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
139141 | :? IFunctionTypeUsage as ft, ParameterNameFromPattern.SingleName ( name, attributes) ->
140142 match ft.ArgumentTypeUsage with
141143 | :? IParameterSignatureTypeUsage as pstu ->
142- factory.CreateParameterSignatureTypeUsage( attributes, name, pstu.TypeUsage)
143- |> replace ft.ArgumentTypeUsage
144+ pstu.SetIdentifier( name) |> ignore
144145 | _ -> ()
145146
146147 visit ( index + 1 ) ft.ReturnTypeUsage
@@ -153,8 +154,7 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
153154 |> Seq.iter ( fun ( p , t ) ->
154155 match t, p with
155156 | :? IParameterSignatureTypeUsage as pstu, ParameterNameFromPattern.SingleName ( name, attributes) ->
156- factory.CreateParameterSignatureTypeUsage( attributes, name, pstu.TypeUsage)
157- |> replace t
157+ pstu.SetIdentifier( name) |> ignore
158158 | _ -> ()
159159 )
160160 | _ -> visit ( index + 1 ) ft.ReturnTypeUsage
@@ -164,7 +164,10 @@ type AddFunctionToSignatureFileAction(dataProvider: FSharpContextActionDataProvi
164164 if not binding.ParameterPatterns.IsEmpty then
165165 visit 0 typeInfo
166166
167- let valSig = factory.CreateBindingSignature( refPat, typeInfo)
167+ let valSig =
168+ let signatureFactory = signatureModuleOrNamespaceDecl.CreateElementFactory()
169+ signatureFactory.CreateBindingSignature( refPat, typeInfo)
170+
168171 let newlineNode = NewLine( signatureModuleOrNamespaceDecl.GetLineEnding()) :> ITreeNode
169172 addNodesAfter signatureModuleOrNamespaceDecl.LastChild [| newlineNode; valSig |] |> ignore
170173
0 commit comments