From 5f27136d47c72ed2d9d502105ee5f65814e2c088 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Sun, 18 Jan 2015 10:49:41 +0100 Subject: [PATCH 1/5] Capturing broken QuickTips for hidden methods in test - references #50 --- .../Tests.LanguageService.QuickInfo.fs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs b/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs index 0c5b4767cf6..d3030595ab5 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs @@ -165,6 +165,27 @@ type QuickInfoTests() = f = (fun ((text, _), _) -> printfn "actual %s" text; Assert.IsTrue(text.Contains "tooltip for operator")) ) + [] + member public this.``QuickInfo.HiddenMember``() = + // Tooltips showed hidden members - #50 + let source = """ + open System.ComponentModel + + type TypeU = { Element : string } + with + [] + [] + member x._Print = x.Element.ToString() + + let u = { Element = "abc" } + """ + this.CheckTooltip( + code = source, + marker = "ypeU =", + atStart = true, + f = (fun ((text, _), _) -> printfn "actual %s" text; Assert.IsFalse(text.Contains "member _Print")) + ) + [] member public this.``QuickInfo.OverriddenMethods``() = let source = """ From 1e38a8a8889a805880c30cdb05075704e5732206 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Wed, 21 Jan 2015 10:51:23 +0100 Subject: [PATCH 2/5] Members hidden from IntelliSense are now also omitted in QuickInfo - fixes #50 --- src/fsharp/NicePrint.fs | 1 + src/fsharp/infos.fs | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index 653c075aaa4..0734795c9e2 100644 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -1505,6 +1505,7 @@ module private TastDefinitionPrinting = not (isInterfaceTy denv.g oty) | [] -> true) |> List.filter (fun v -> denv.showObsoleteMembers || not (HasFSharpAttribute denv.g denv.g.attrib_SystemObsolete v.Attribs)) + |> List.filter (fun v -> not (Infos.AttributeChecking.CheckFSharpAttributesForHidden denv.g v.Attribs)) // sort let sortKey (v:ValRef) = (not v.IsConstructor, // constructors before others v.Id.idText, // sort by name diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index 495b47260cb..838a1e4b878 100644 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -2637,20 +2637,25 @@ module AttributeChecking = let (AttribInfo(tref,_)) = g.attrib_SystemObsolete isSome (TryDecodeILAttribute g tref (Some(tref.Scope)) cattrs) + /// Checks the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows + /// items to be suppressed from intellisense. + let CheckFSharpAttributesForHidden g attribs = + nonNil attribs && + (match TryFindFSharpAttribute g g.attrib_CompilerMessageAttribute attribs with + | Some(Attrib(_,_,[AttribStringArg _; AttribInt32Arg messageNumber], + ExtractAttribNamedArg "IsHidden" (AttribBoolArg v),_,_,_)) -> + // Message number 62 is for "ML Compatibility". Items labelled with this are visible in intellisense + // when mlCompatibility is set. + v && not (messageNumber = 62 && g.mlCompatibility) + | _ -> false) + /// Indicate if a list of F# attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense. /// Also check the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows /// items to be suppressed from intellisense. let CheckFSharpAttributesForUnseen g attribs _m = nonNil attribs && (let isObsolete = isSome (TryFindFSharpAttribute g g.attrib_SystemObsolete attribs) - let isHidden = - (match TryFindFSharpAttribute g g.attrib_CompilerMessageAttribute attribs with - | Some(Attrib(_,_,[AttribStringArg _; AttribInt32Arg messageNumber], - ExtractAttribNamedArg "IsHidden" (AttribBoolArg v),_,_,_)) -> - // Message number 62 is for "ML Compatibility". Items labelled with this are visible in intellisense - // when mlCompatibility is set. - v && not (messageNumber = 62 && g.mlCompatibility) - | _ -> false) + let isHidden = CheckFSharpAttributesForHidden g attribs isObsolete || isHidden ) From ae547469cca7d50cde5feb6b4329e35e3f14d5c4 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Wed, 21 Jan 2015 12:17:16 +0100 Subject: [PATCH 3/5] Capturing broken QuickTip for obsolete methods in test - references #50 --- .../Tests.LanguageService.QuickInfo.fs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs b/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs index d3030595ab5..5977e2b9377 100644 --- a/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs +++ b/vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs @@ -185,6 +185,25 @@ type QuickInfoTests() = atStart = true, f = (fun ((text, _), _) -> printfn "actual %s" text; Assert.IsFalse(text.Contains "member _Print")) ) + + [] + member public this.``QuickInfo.ObsoleteMember``() = + // Tooltips showed obsolete members - #50 + let source = """ + type TypeU = { Element : string } + with + [] + member x.Print1 = x.Element.ToString() + member x.Print2 = x.Element.ToString() + + let u = { Element = "abc" } + """ + this.CheckTooltip( + code = source, + marker = "ypeU =", + atStart = true, + f = (fun ((text, _), _) -> printfn "actual %s" text; Assert.IsFalse(text.Contains "member Print1")) + ) [] member public this.``QuickInfo.OverriddenMethods``() = From 6f9902997b42ceddeb8ff4db7f533000e5b23998 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Wed, 21 Jan 2015 12:17:58 +0100 Subject: [PATCH 4/5] Obsolete members are now also omitted in QuickInfo - references #50 --- src/fsharp/NicePrint.fs | 4 ++-- src/fsharp/fsc.fs | 6 ++++-- src/fsharp/infos.fs | 12 +++++++----- src/fsharp/tastops.fs | 4 +++- src/fsharp/tastops.fsi | 1 + 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index 0734795c9e2..3f5e5acf919 100644 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -1504,8 +1504,8 @@ module private TastDefinitionPrinting = // Don't print individual methods forming interface implementations - these are currently never exported not (isInterfaceTy denv.g oty) | [] -> true) - |> List.filter (fun v -> denv.showObsoleteMembers || not (HasFSharpAttribute denv.g denv.g.attrib_SystemObsolete v.Attribs)) - |> List.filter (fun v -> not (Infos.AttributeChecking.CheckFSharpAttributesForHidden denv.g v.Attribs)) + |> List.filter (fun v -> denv.showObsoleteMembers || not (Infos.AttributeChecking.CheckFSharpAttributesForObsolete denv.g v.Attribs)) + |> List.filter (fun v -> denv.showHiddenMembers || not (Infos.AttributeChecking.CheckFSharpAttributesForHidden denv.g v.Attribs)) // sort let sortKey (v:ValRef) = (not v.IsConstructor, // constructors before others v.Id.idText, // sort by name diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index fa391204bfb..370628de128 100644 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -548,11 +548,13 @@ let runFromCommandLineToImportingAssemblies(displayPSTypeProviderSecurityDialogB // Code from here on down is just used by fsc.exe /////////////////////////////////////////////////////////////////////////////////////////////////////////////// -let BuildInitialDisplayEnvForDocGeneration tcGlobals = +let BuildInitialDisplayEnvForSigFileGeneration tcGlobals = let denv = DisplayEnv.Empty tcGlobals let denv = { denv with showImperativeTyparAnnotations=true; + showHiddenMembers=true; + showObsoleteMembers=true; showAttributes=true; } denv.SetOpenPaths [ FSharpLib.RootPath @@ -577,7 +579,7 @@ module InterfaceFileWriter = fprintfn os "" for (TImplFile(_,_,mexpr,_,_)) in declaredImpls do - let denv = BuildInitialDisplayEnvForDocGeneration tcGlobals + let denv = BuildInitialDisplayEnvForSigFileGeneration tcGlobals writeViaBufferWithEnvironmentNewLines os (fun os s -> Printf.bprintf os "%s\n\n" s) (NicePrint.layoutInferredSigOfModuleExpr true denv infoReader AccessibleFromSomewhere range0 mexpr |> Layout.squashTo 80 |> Layout.showL) diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index 838a1e4b878..73bae7b6a39 100644 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -2649,15 +2649,17 @@ module AttributeChecking = v && not (messageNumber = 62 && g.mlCompatibility) | _ -> false) + /// Indicate if a list of F# attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense. + let CheckFSharpAttributesForObsolete g attribs = + nonNil attribs && (HasFSharpAttribute g g.attrib_SystemObsolete attribs) + /// Indicate if a list of F# attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense. /// Also check the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows /// items to be suppressed from intellisense. let CheckFSharpAttributesForUnseen g attribs _m = - nonNil attribs && - (let isObsolete = isSome (TryFindFSharpAttribute g g.attrib_SystemObsolete attribs) - let isHidden = CheckFSharpAttributesForHidden g attribs - isObsolete || isHidden - ) + nonNil attribs && + (CheckFSharpAttributesForObsolete g attribs || + CheckFSharpAttributesForHidden g attribs) #if EXTENSIONTYPING /// Indicate if a list of provided attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense. diff --git a/src/fsharp/tastops.fs b/src/fsharp/tastops.fs index 8dda48725a3..aaa33d6af3f 100644 --- a/src/fsharp/tastops.fs +++ b/src/fsharp/tastops.fs @@ -2354,6 +2354,7 @@ type DisplayEnv = suppressNestedTypes: bool; maxMembers : int option; showObsoleteMembers: bool; + showHiddenMembers: bool; showTyparBinding: bool; showImperativeTyparAnnotations: bool; suppressInlineKeyword: bool; @@ -2384,7 +2385,8 @@ type DisplayEnv = shortTypeNames=false; suppressNestedTypes=false; maxMembers=None; - showObsoleteMembers=true; + showObsoleteMembers=false; + showHiddenMembers=false; showTyparBinding = false; showImperativeTyparAnnotations=false; suppressInlineKeyword=false; diff --git a/src/fsharp/tastops.fsi b/src/fsharp/tastops.fsi index c6c7f692b71..f7911659e54 100644 --- a/src/fsharp/tastops.fsi +++ b/src/fsharp/tastops.fsi @@ -590,6 +590,7 @@ type DisplayEnv = suppressNestedTypes: bool; maxMembers : int option; showObsoleteMembers: bool; + showHiddenMembers: bool; showTyparBinding: bool; showImperativeTyparAnnotations: bool; suppressInlineKeyword:bool; From e127dfaa034ce8a515bb7aae57dc9c0d7e56a175 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Wed, 21 Jan 2015 10:52:10 +0100 Subject: [PATCH 5/5] fix typos in XmlDocumentation.fs and ast.fs --- src/fsharp/ast.fs | 2 +- .../src/vs/FsPkgs/FSharp.LanguageService/XmlDocumentation.fs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsharp/ast.fs b/src/fsharp/ast.fs index 3af95cf757c..447039e4857 100644 --- a/src/fsharp/ast.fs +++ b/src/fsharp/ast.fs @@ -51,7 +51,7 @@ type XmlDocCollector() = lazy (savedLines.ToArray() |> Array.sortWith (fun (_,p1) (_,p2) -> posCompare p1 p2)) let check() = - assert (not savedLinesAsArray.IsValueCreated && "can't add more XmlDoc elements to XmlDocCOllector after extracting first XmlDoc from the overall results" <> "") + assert (not savedLinesAsArray.IsValueCreated && "can't add more XmlDoc elements to XmlDocCollector after extracting first XmlDoc from the overall results" <> "") member x.AddGrabPoint(pos) = check() diff --git a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/XmlDocumentation.fs b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/XmlDocumentation.fs index 8b920c5ea2c..f17e64404b4 100644 --- a/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/XmlDocumentation.fs +++ b/vsintegration/src/vs/FsPkgs/FSharp.LanguageService/XmlDocumentation.fs @@ -26,7 +26,7 @@ module internal XmlDocumentation = "" + xml + "" else xml - /// Provide Xml Documentatation + /// Provide Xml Documentation type Provider(xmlIndexService:IVsXMLMemberIndexService) = /// Index of assembly name to xml member index. let mutable xmlCache = new AgedLookup(10,areSame=(fun (x,y) -> x = y))