From fbc336e93e0eb175311a86d6562a0f0db206693c Mon Sep 17 00:00:00 2001 From: Peter Semkin Date: Fri, 1 Jul 2022 14:49:51 +0200 Subject: [PATCH 1/2] Show arguments names in tooltips for local functions --- src/Compiler/Checking/CheckDeclarations.fs | 3 ++ .../tests/UnitTests/QuickInfoTests.fs | 47 +++++++++++-------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 60d650ed1fe..a2d1f759065 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -990,6 +990,9 @@ module IncrClassChecking = let memberInfo = MakeMemberDataAndMangledNameForMemberVal(g, tcref, false, [], [], memberFlags, valSynInfo, mkSynId v.Range name, true) let copyOfTyconTypars = ctorInfo.GetNormalizedInstanceCtorDeclaredTypars cenv env.DisplayEnv ctorInfo.TyconRef.Range + + AdjustValToTopVal v (Parent tcref) topValInfo + // Add the 'this' pointer on to the function let memberTauTy, topValInfo = let tauTy = v.TauType diff --git a/vsintegration/tests/UnitTests/QuickInfoTests.fs b/vsintegration/tests/UnitTests/QuickInfoTests.fs index be0e18f0412..ad2b3cca779 100644 --- a/vsintegration/tests/UnitTests/QuickInfoTests.fs +++ b/vsintegration/tests/UnitTests/QuickInfoTests.fs @@ -1,12 +1,10 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + namespace Microsoft.VisualStudio.FSharp.Editor.Tests.Roslyn open System.IO -open FSharp.Compiler.CodeAnalysis -open Microsoft.CodeAnalysis -open Microsoft.CodeAnalysis.Text open Microsoft.VisualStudio.FSharp.Editor open NUnit.Framework -open UnitTests.TestLib.LanguageService open VisualFSharp.UnitTests.Roslyn [] @@ -45,7 +43,6 @@ let GetQuickInfoTextFromCode (code:string) = let expectedLines (lines:string list) = System.String.Join("\n", lines) -// migrated from legacy test [] let ``Automation.EnumDUInterfacefromFSBrowse.InsideComputationExpression`` () = let code = """ @@ -70,7 +67,6 @@ module Test = let expected = "MyColors.Red: MyColors = 0" Assert.AreEqual(expected, quickInfo) -// migrated from legacy test [] let ``Automation.EnumDUInterfacefromFSBrowse.InsideMatch`` () = let code = """ @@ -100,7 +96,6 @@ module Test = "Full name: FsTest.MyDistance" ] Assert.AreEqual(expected, quickInfo) -// migrated from legacy test [] let ``Automation.EnumDUInterfacefromFSBrowse.InsideLambda`` () = let code = """ @@ -129,7 +124,6 @@ module Test = let expected = "abstract IMyInterface.Represent: unit -> string" Assert.AreEqual(expected, quickInfo) -// migrated from legacy test [] let ``Automation.RecordAndInterfaceFromFSProj.InsideComputationExpression``() = let code = """ @@ -162,7 +156,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.RecordAndInterfaceFromFSProj.InsideQuotation``() = let code = """ @@ -186,7 +179,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.RecordAndInterfaceFromFSProj.InsideLambda``() = let code = """ @@ -212,7 +204,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.TupleRecordFromFSBrowse.InsideComputationExpression``() = let code = """ @@ -237,7 +228,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.TupleRecordFromFSBrowse.SequenceOfMethods``() = let code = """ @@ -266,7 +256,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.UnionAndStructFromFSProj.MatchExpression``() = let code = """ @@ -289,7 +278,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.UnionAndStructFromFSProj.MatchPattern``() = let code = """ @@ -312,7 +300,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.UnionAndStructFromFSProj.UnionIfPredicate``() = let code = """ @@ -334,7 +321,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.UnionAndStructFromFSProj.UnionForPattern``() = let code = """ @@ -356,7 +342,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.UnionAndStructFromFSProj.UnionMethodPatternMatch``() = let code = """ @@ -386,7 +371,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.UnionAndStructFromFSProj.UnionMethodPatternMatchBody``() = let code = """ @@ -414,7 +398,6 @@ module Test = Assert.AreEqual(expected, quickInfo) () -// migrated from legacy test [] let ``Automation.UnionAndStructFromFSProj.UnionPropertyInComputationExpression``() = let code = """ @@ -444,3 +427,29 @@ module Test = let expected = "property MyDistance.asNautical: MyDistance with get" Assert.AreEqual(expected, quickInfo) () + +[] +let ``Automation.LetBindings.ArgumentNames``() = + let code1 = """ +namespace FsTest + +module Test = + let fu$$nc x = () +""" + + let code2 = """ +namespace FsTest + +module Test = + type T() = + let fu$$nc x = () +""" + + let expectedSignature = "val func: x: 'a -> unit" + + let tooltip1 = GetQuickInfoTextFromCode code1 + let tooltip2 = GetQuickInfoTextFromCode code2 + + StringAssert.StartsWith(expectedSignature, tooltip1) + StringAssert.StartsWith(expectedSignature, tooltip2) + () From 2cece5f773d20cf1bcf30212828b88d6fdd2de7e Mon Sep 17 00:00:00 2001 From: Peter Semkin Date: Mon, 4 Jul 2022 12:53:56 +0200 Subject: [PATCH 2/2] Update --- .../Tests.LanguageService.ParameterInfo.fs | 7 ------- .../Tests.LanguageService.QuickInfo.fs | 2 +- .../tests/UnitTests/QuickInfoTests.fs | 20 ++++++++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs index 0da7fce519b..0d9d9b875d4 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.ParameterInfo.fs @@ -1554,13 +1554,6 @@ We really need to rewrite some code paths here to use the real parse tree rather bar( """, "bar(", ["int"] - """ - type T() = - let foo x = x + 1 - member this.Run() = - foo( - """, "foo(", ["int"] - """ let f (Some x) = x + 1 f( diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.QuickInfo.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.QuickInfo.fs index d62f4274062..fa0064792d5 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.QuickInfo.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.QuickInfo.fs @@ -764,7 +764,7 @@ Full name: Microsoft.FSharp.Control.Async""".TrimStart().Replace("\r\n", "\n") type A() = let fff n = n + 1 """ - this.AssertQuickInfoContainsAtEndOfMarker(code, "let ff", "val fff: (int -> int)") + this.AssertQuickInfoContainsAtEndOfMarker(code, "let ff", "val fff: n: int -> int") // Regression for 2494 [] diff --git a/vsintegration/tests/UnitTests/QuickInfoTests.fs b/vsintegration/tests/UnitTests/QuickInfoTests.fs index ad2b3cca779..ff460f45144 100644 --- a/vsintegration/tests/UnitTests/QuickInfoTests.fs +++ b/vsintegration/tests/UnitTests/QuickInfoTests.fs @@ -429,15 +429,23 @@ module Test = () [] -let ``Automation.LetBindings.ArgumentNames``() = - let code1 = """ +let ``Automation.LetBindings.InsideModule``() = + let code = """ namespace FsTest module Test = let fu$$nc x = () """ + let expectedSignature = "val func: x: 'a -> unit" - let code2 = """ + let tooltip = GetQuickInfoTextFromCode code + + StringAssert.StartsWith(expectedSignature, tooltip) + () + +[] +let ``Automation.LetBindings.InsideType``() = + let code = """ namespace FsTest module Test = @@ -447,9 +455,7 @@ module Test = let expectedSignature = "val func: x: 'a -> unit" - let tooltip1 = GetQuickInfoTextFromCode code1 - let tooltip2 = GetQuickInfoTextFromCode code2 + let tooltip = GetQuickInfoTextFromCode code - StringAssert.StartsWith(expectedSignature, tooltip1) - StringAssert.StartsWith(expectedSignature, tooltip2) + StringAssert.StartsWith(expectedSignature, tooltip) ()