Skip to content

Commit 0d88a9c

Browse files
authored
Show arguments names in tooltips for local functions (#13429)
* Show arguments names in tooltips for local functions * Update
1 parent 0c5671f commit 0d88a9c

File tree

4 files changed

+38
-27
lines changed

4 files changed

+38
-27
lines changed

src/Compiler/Checking/CheckDeclarations.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,9 @@ module IncrClassChecking =
990990
let memberInfo = MakeMemberDataAndMangledNameForMemberVal(g, tcref, false, [], [], memberFlags, valSynInfo, mkSynId v.Range name, true)
991991

992992
let copyOfTyconTypars = ctorInfo.GetNormalizedInstanceCtorDeclaredTypars cenv env.DisplayEnv ctorInfo.TyconRef.Range
993+
994+
AdjustValToTopVal v (Parent tcref) topValInfo
995+
993996
// Add the 'this' pointer on to the function
994997
let memberTauTy, topValInfo =
995998
let tauTy = v.TauType

vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,13 +1554,6 @@ We really need to rewrite some code paths here to use the real parse tree rather
15541554
bar(
15551555
""", "bar(", ["int"]
15561556

1557-
"""
1558-
type T() =
1559-
let foo x = x + 1
1560-
member this.Run() =
1561-
foo(
1562-
""", "foo(", ["int"]
1563-
15641557
"""
15651558
let f (Some x) = x + 1
15661559
f(

vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.QuickInfo.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ Full name: Microsoft.FSharp.Control.Async""".TrimStart().Replace("\r\n", "\n")
764764
type A() =
765765
let fff n = n + 1
766766
"""
767-
this.AssertQuickInfoContainsAtEndOfMarker(code, "let ff", "val fff: (int -> int)")
767+
this.AssertQuickInfoContainsAtEndOfMarker(code, "let ff", "val fff: n: int -> int")
768768

769769
// Regression for 2494
770770
[<Test>]

vsintegration/tests/UnitTests/QuickInfoTests.fs

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
13
namespace Microsoft.VisualStudio.FSharp.Editor.Tests.Roslyn
24

35
open System.IO
4-
open FSharp.Compiler.CodeAnalysis
5-
open Microsoft.CodeAnalysis
6-
open Microsoft.CodeAnalysis.Text
76
open Microsoft.VisualStudio.FSharp.Editor
87
open NUnit.Framework
9-
open UnitTests.TestLib.LanguageService
108
open VisualFSharp.UnitTests.Roslyn
119

1210
[<Category "Roslyn Services">]
@@ -45,7 +43,6 @@ let GetQuickInfoTextFromCode (code:string) =
4543

4644
let expectedLines (lines:string list) = System.String.Join("\n", lines)
4745

48-
// migrated from legacy test
4946
[<Test>]
5047
let ``Automation.EnumDUInterfacefromFSBrowse.InsideComputationExpression`` () =
5148
let code = """
@@ -70,7 +67,6 @@ module Test =
7067
let expected = "MyColors.Red: MyColors = 0"
7168
Assert.AreEqual(expected, quickInfo)
7269

73-
// migrated from legacy test
7470
[<Test>]
7571
let ``Automation.EnumDUInterfacefromFSBrowse.InsideMatch`` () =
7672
let code = """
@@ -100,7 +96,6 @@ module Test =
10096
"Full name: FsTest.MyDistance" ]
10197
Assert.AreEqual(expected, quickInfo)
10298

103-
// migrated from legacy test
10499
[<Test>]
105100
let ``Automation.EnumDUInterfacefromFSBrowse.InsideLambda`` () =
106101
let code = """
@@ -129,7 +124,6 @@ module Test =
129124
let expected = "abstract IMyInterface.Represent: unit -> string"
130125
Assert.AreEqual(expected, quickInfo)
131126

132-
// migrated from legacy test
133127
[<Test>]
134128
let ``Automation.RecordAndInterfaceFromFSProj.InsideComputationExpression``() =
135129
let code = """
@@ -162,7 +156,6 @@ module Test =
162156
Assert.AreEqual(expected, quickInfo)
163157
()
164158

165-
// migrated from legacy test
166159
[<Test>]
167160
let ``Automation.RecordAndInterfaceFromFSProj.InsideQuotation``() =
168161
let code = """
@@ -186,7 +179,6 @@ module Test =
186179
Assert.AreEqual(expected, quickInfo)
187180
()
188181

189-
// migrated from legacy test
190182
[<Test>]
191183
let ``Automation.RecordAndInterfaceFromFSProj.InsideLambda``() =
192184
let code = """
@@ -212,7 +204,6 @@ module Test =
212204
Assert.AreEqual(expected, quickInfo)
213205
()
214206

215-
// migrated from legacy test
216207
[<Test>]
217208
let ``Automation.TupleRecordFromFSBrowse.InsideComputationExpression``() =
218209
let code = """
@@ -237,7 +228,6 @@ module Test =
237228
Assert.AreEqual(expected, quickInfo)
238229
()
239230

240-
// migrated from legacy test
241231
[<Test>]
242232
let ``Automation.TupleRecordFromFSBrowse.SequenceOfMethods``() =
243233
let code = """
@@ -266,7 +256,6 @@ module Test =
266256
Assert.AreEqual(expected, quickInfo)
267257
()
268258

269-
// migrated from legacy test
270259
[<Test>]
271260
let ``Automation.UnionAndStructFromFSProj.MatchExpression``() =
272261
let code = """
@@ -289,7 +278,6 @@ module Test =
289278
Assert.AreEqual(expected, quickInfo)
290279
()
291280

292-
// migrated from legacy test
293281
[<Test>]
294282
let ``Automation.UnionAndStructFromFSProj.MatchPattern``() =
295283
let code = """
@@ -312,7 +300,6 @@ module Test =
312300
Assert.AreEqual(expected, quickInfo)
313301
()
314302

315-
// migrated from legacy test
316303
[<Test>]
317304
let ``Automation.UnionAndStructFromFSProj.UnionIfPredicate``() =
318305
let code = """
@@ -334,7 +321,6 @@ module Test =
334321
Assert.AreEqual(expected, quickInfo)
335322
()
336323

337-
// migrated from legacy test
338324
[<Test>]
339325
let ``Automation.UnionAndStructFromFSProj.UnionForPattern``() =
340326
let code = """
@@ -356,7 +342,6 @@ module Test =
356342
Assert.AreEqual(expected, quickInfo)
357343
()
358344

359-
// migrated from legacy test
360345
[<Test>]
361346
let ``Automation.UnionAndStructFromFSProj.UnionMethodPatternMatch``() =
362347
let code = """
@@ -386,7 +371,6 @@ module Test =
386371
Assert.AreEqual(expected, quickInfo)
387372
()
388373

389-
// migrated from legacy test
390374
[<Test>]
391375
let ``Automation.UnionAndStructFromFSProj.UnionMethodPatternMatchBody``() =
392376
let code = """
@@ -414,7 +398,6 @@ module Test =
414398
Assert.AreEqual(expected, quickInfo)
415399
()
416400

417-
// migrated from legacy test
418401
[<Test>]
419402
let ``Automation.UnionAndStructFromFSProj.UnionPropertyInComputationExpression``() =
420403
let code = """
@@ -444,3 +427,35 @@ module Test =
444427
let expected = "property MyDistance.asNautical: MyDistance with get"
445428
Assert.AreEqual(expected, quickInfo)
446429
()
430+
431+
[<Test>]
432+
let ``Automation.LetBindings.InsideModule``() =
433+
let code = """
434+
namespace FsTest
435+
436+
module Test =
437+
let fu$$nc x = ()
438+
"""
439+
let expectedSignature = "val func: x: 'a -> unit"
440+
441+
let tooltip = GetQuickInfoTextFromCode code
442+
443+
StringAssert.StartsWith(expectedSignature, tooltip)
444+
()
445+
446+
[<Test>]
447+
let ``Automation.LetBindings.InsideType``() =
448+
let code = """
449+
namespace FsTest
450+
451+
module Test =
452+
type T() =
453+
let fu$$nc x = ()
454+
"""
455+
456+
let expectedSignature = "val func: x: 'a -> unit"
457+
458+
let tooltip = GetQuickInfoTextFromCode code
459+
460+
StringAssert.StartsWith(expectedSignature, tooltip)
461+
()

0 commit comments

Comments
 (0)