Skip to content

Commit ac55622

Browse files
forkilatkin
authored andcommitted
Members hidden from IntelliSense are now also omitted in QuickInfo - fixes #50
closes #73 commit e127dfa Author: Steffen Forkmann <steffen.forkmann@msu-solutions.de> Date: Wed Jan 21 10:52:10 2015 +0100 fix typos in XmlDocumentation.fs and ast.fs commit 6f99029 Author: Steffen Forkmann <steffen.forkmann@msu-solutions.de> Date: Wed Jan 21 12:17:58 2015 +0100 Obsolete members are now also omitted in QuickInfo - references #50 commit ae54746 Author: Steffen Forkmann <steffen.forkmann@msu-solutions.de> Date: Wed Jan 21 12:17:16 2015 +0100 Capturing broken QuickTip for obsolete methods in test - references #50 commit 1e38a8a Author: Steffen Forkmann <steffen.forkmann@msu-solutions.de> Date: Wed Jan 21 10:51:23 2015 +0100 Members hidden from IntelliSense are now also omitted in QuickInfo - fixes #50 commit 5f27136 Author: Steffen Forkmann <steffen.forkmann@msu-solutions.de> Date: Sun Jan 18 10:49:41 2015 +0100 Capturing broken QuickTips for hidden methods in test - references #50
1 parent a932a13 commit ac55622

File tree

8 files changed

+71
-18
lines changed

8 files changed

+71
-18
lines changed

src/fsharp/NicePrint.fs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,8 @@ module private TastDefinitionPrinting =
15001500
// Don't print individual methods forming interface implementations - these are currently never exported
15011501
not (isInterfaceTy denv.g oty)
15021502
| [] -> true)
1503-
|> List.filter (fun v -> denv.showObsoleteMembers || not (HasFSharpAttribute denv.g denv.g.attrib_SystemObsolete v.Attribs))
1503+
|> List.filter (fun v -> denv.showObsoleteMembers || not (Infos.AttributeChecking.CheckFSharpAttributesForObsolete denv.g v.Attribs))
1504+
|> List.filter (fun v -> denv.showHiddenMembers || not (Infos.AttributeChecking.CheckFSharpAttributesForHidden denv.g v.Attribs))
15041505
// sort
15051506
let sortKey (v:ValRef) = (not v.IsConstructor, // constructors before others
15061507
v.Id.idText, // sort by name

src/fsharp/ast.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type XmlDocCollector() =
5151
lazy (savedLines.ToArray() |> Array.sortWith (fun (_,p1) (_,p2) -> posCompare p1 p2))
5252

5353
let check() =
54-
assert (not savedLinesAsArray.IsValueCreated && "can't add more XmlDoc elements to XmlDocCOllector after extracting first XmlDoc from the overall results" <> "")
54+
assert (not savedLinesAsArray.IsValueCreated && "can't add more XmlDoc elements to XmlDocCollector after extracting first XmlDoc from the overall results" <> "")
5555

5656
member x.AddGrabPoint(pos) =
5757
check()

src/fsharp/fsc.fs

+4-2
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,13 @@ let runFromCommandLineToImportingAssemblies(displayPSTypeProviderSecurityDialogB
548548
// Code from here on down is just used by fsc.exe
549549
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
550550

551-
let BuildInitialDisplayEnvForDocGeneration tcGlobals =
551+
let BuildInitialDisplayEnvForSigFileGeneration tcGlobals =
552552
let denv = DisplayEnv.Empty tcGlobals
553553
let denv =
554554
{ denv with
555555
showImperativeTyparAnnotations=true;
556+
showHiddenMembers=true;
557+
showObsoleteMembers=true;
556558
showAttributes=true; }
557559
denv.SetOpenPaths
558560
[ FSharpLib.RootPath
@@ -577,7 +579,7 @@ module InterfaceFileWriter =
577579
fprintfn os ""
578580

579581
for (TImplFile(_,_,mexpr,_,_)) in declaredImpls do
580-
let denv = BuildInitialDisplayEnvForDocGeneration tcGlobals
582+
let denv = BuildInitialDisplayEnvForSigFileGeneration tcGlobals
581583
writeViaBufferWithEnvironmentNewLines os (fun os s -> Printf.bprintf os "%s\n\n" s)
582584
(NicePrint.layoutInferredSigOfModuleExpr true denv infoReader AccessibleFromSomewhere range0 mexpr |> Layout.squashTo 80 |> Layout.showL)
583585

src/fsharp/infos.fs

+19-12
Original file line numberDiff line numberDiff line change
@@ -2660,22 +2660,29 @@ module AttributeChecking =
26602660
let (AttribInfo(tref,_)) = g.attrib_SystemObsolete
26612661
isSome (TryDecodeILAttribute g tref (Some(tref.Scope)) cattrs)
26622662

2663+
/// Checks the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows
2664+
/// items to be suppressed from intellisense.
2665+
let CheckFSharpAttributesForHidden g attribs =
2666+
nonNil attribs &&
2667+
(match TryFindFSharpAttribute g g.attrib_CompilerMessageAttribute attribs with
2668+
| Some(Attrib(_,_,[AttribStringArg _; AttribInt32Arg messageNumber],
2669+
ExtractAttribNamedArg "IsHidden" (AttribBoolArg v),_,_,_)) ->
2670+
// Message number 62 is for "ML Compatibility". Items labelled with this are visible in intellisense
2671+
// when mlCompatibility is set.
2672+
v && not (messageNumber = 62 && g.mlCompatibility)
2673+
| _ -> false)
2674+
2675+
/// Indicate if a list of F# attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense.
2676+
let CheckFSharpAttributesForObsolete g attribs =
2677+
nonNil attribs && (HasFSharpAttribute g g.attrib_SystemObsolete attribs)
2678+
26632679
/// Indicate if a list of F# attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense.
26642680
/// Also check the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows
26652681
/// items to be suppressed from intellisense.
26662682
let CheckFSharpAttributesForUnseen g attribs _m =
2667-
nonNil attribs &&
2668-
(let isObsolete = isSome (TryFindFSharpAttribute g g.attrib_SystemObsolete attribs)
2669-
let isHidden =
2670-
(match TryFindFSharpAttribute g g.attrib_CompilerMessageAttribute attribs with
2671-
| Some(Attrib(_,_,[AttribStringArg _; AttribInt32Arg messageNumber],
2672-
ExtractAttribNamedArg "IsHidden" (AttribBoolArg v),_,_,_)) ->
2673-
// Message number 62 is for "ML Compatibility". Items labelled with this are visible in intellisense
2674-
// when mlCompatibility is set.
2675-
v && not (messageNumber = 62 && g.mlCompatibility)
2676-
| _ -> false)
2677-
isObsolete || isHidden
2678-
)
2683+
nonNil attribs &&
2684+
(CheckFSharpAttributesForObsolete g attribs ||
2685+
CheckFSharpAttributesForHidden g attribs)
26792686

26802687
#if EXTENSIONTYPING
26812688
/// Indicate if a list of provided attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense.

src/fsharp/tastops.fs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2344,6 +2344,7 @@ type DisplayEnv =
23442344
suppressNestedTypes: bool;
23452345
maxMembers : int option;
23462346
showObsoleteMembers: bool;
2347+
showHiddenMembers: bool;
23472348
showTyparBinding: bool;
23482349
showImperativeTyparAnnotations: bool;
23492350
suppressInlineKeyword: bool;
@@ -2374,7 +2375,8 @@ type DisplayEnv =
23742375
shortTypeNames=false;
23752376
suppressNestedTypes=false;
23762377
maxMembers=None;
2377-
showObsoleteMembers=true;
2378+
showObsoleteMembers=false;
2379+
showHiddenMembers=false;
23782380
showTyparBinding = false;
23792381
showImperativeTyparAnnotations=false;
23802382
suppressInlineKeyword=false;

src/fsharp/tastops.fsi

+1
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ type DisplayEnv =
587587
suppressNestedTypes: bool;
588588
maxMembers : int option;
589589
showObsoleteMembers: bool;
590+
showHiddenMembers: bool;
590591
showTyparBinding: bool;
591592
showImperativeTyparAnnotations: bool;
592593
suppressInlineKeyword:bool;

vsintegration/src/unittests/Tests.LanguageService.QuickInfo.fs

+40
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,46 @@ type QuickInfoTests() =
165165
f = (fun ((text, _), _) -> printfn "actual %s" text; Assert.IsTrue(text.Contains "tooltip for operator"))
166166
)
167167

168+
[<Test>]
169+
member public this.``QuickInfo.HiddenMember``() =
170+
// Tooltips showed hidden members - #50
171+
let source = """
172+
open System.ComponentModel
173+
174+
type TypeU = { Element : string }
175+
with
176+
[<EditorBrowsableAttribute(EditorBrowsableState.Never)>]
177+
[<CompilerMessageAttribute("This method is intended for use in generated code only.", 10001, IsHidden=true, IsError=false)>]
178+
member x._Print = x.Element.ToString()
179+
180+
let u = { Element = "abc" }
181+
"""
182+
this.CheckTooltip(
183+
code = source,
184+
marker = "ypeU =",
185+
atStart = true,
186+
f = (fun ((text, _), _) -> printfn "actual %s" text; Assert.IsFalse(text.Contains "member _Print"))
187+
)
188+
189+
[<Test>]
190+
member public this.``QuickInfo.ObsoleteMember``() =
191+
// Tooltips showed obsolete members - #50
192+
let source = """
193+
type TypeU = { Element : string }
194+
with
195+
[<System.ObsoleteAttribute("This is replaced with Print2")>]
196+
member x.Print1 = x.Element.ToString()
197+
member x.Print2 = x.Element.ToString()
198+
199+
let u = { Element = "abc" }
200+
"""
201+
this.CheckTooltip(
202+
code = source,
203+
marker = "ypeU =",
204+
atStart = true,
205+
f = (fun ((text, _), _) -> printfn "actual %s" text; Assert.IsFalse(text.Contains "member Print1"))
206+
)
207+
168208
[<Test>]
169209
member public this.``QuickInfo.OverriddenMethods``() =
170210
let source = """

vsintegration/src/vs/FsPkgs/FSharp.LanguageService/XmlDocumentation.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module internal XmlDocumentation =
2626
"<root>" + xml + "</root>"
2727
else xml
2828

29-
/// Provide Xml Documentatation
29+
/// Provide Xml Documentation
3030
type Provider(xmlIndexService:IVsXMLMemberIndexService) =
3131
/// Index of assembly name to xml member index.
3232
let mutable xmlCache = new AgedLookup<string,IVsXMLMemberIndex>(10,areSame=(fun (x,y) -> x = y))

0 commit comments

Comments
 (0)