@@ -54,6 +54,38 @@ type ParseAndCheckResults
5454
5555 let logger = LogProvider.getLoggerByName " ParseAndCheckResults"
5656
57+ let getAllEntitiesUncached ( publicOnly : bool ) : AssemblySymbol list =
58+ try
59+ [ yield !
60+ AssemblyContent.GetAssemblySignatureContent AssemblyContentType.Full checkResults.PartialAssemblySignature
61+ let ctx = checkResults.ProjectContext
62+
63+ let assembliesByFileName =
64+ ctx.GetReferencedAssemblies()
65+ |> List.groupBy ( fun asm -> asm.FileName)
66+ |> List.rev // if mscorlib.dll is the first then FSC raises exception when we try to
67+ // get Content.Entities from it.
68+
69+ for fileName, signatures in assembliesByFileName do
70+ let contentType =
71+ if publicOnly then
72+ AssemblyContentType.Public
73+ else
74+ AssemblyContentType.Full
75+
76+ let content =
77+ AssemblyContent.GetAssemblyContent entityCache.Locking contentType fileName signatures
78+
79+ yield ! content ]
80+ with _ ->
81+ []
82+
83+ let cachedPublicEntities = lazy ( getAllEntitiesUncached true )
84+ let cachedFullEntities = lazy ( getAllEntitiesUncached false )
85+
86+ let cachedCrefResolver =
87+ lazy ( cachedFullEntities.Force() |> TipFormatter.createCrefResolver)
88+
5789 let getFileName ( loc : range ) =
5890 // Keep the full FCS path, just normalize backslashes to forward slashes.
5991 // FCS may prepend a workspace prefix if the PDB path isn't absolute on this platform.
@@ -529,32 +561,33 @@ type ParseAndCheckResults
529561 member x.TryGetFormattedDocumentationForSymbol ( xmlSig : string ) ( assembly : string ) =
530562 let entities = x.GetAllEntities false
531563
564+ let matchesSymbol includeAssembly ( symbol : FSharpSymbol ) =
565+ try
566+ symbol.XmlDocSig = xmlSig
567+ && ( not includeAssembly || symbol.Assembly.SimpleName = assembly)
568+ with _ ->
569+ false
570+
571+ let matchesAbbreviatedEntity includeAssembly ( symbol : FSharpSymbol ) =
572+ match symbol with
573+ | FSharpEntity(_, abrvEnt, _) ->
574+ try
575+ abrvEnt.XmlDocSig = xmlSig
576+ && ( not includeAssembly || abrvEnt.Assembly.SimpleName = assembly)
577+ with _ ->
578+ false
579+ | _ -> false
580+
532581 let ent =
533582 entities
534- |> List.tryFind ( fun e ->
535- let check = ( e.Symbol.XmlDocSig = xmlSig && e.Symbol.Assembly.SimpleName = assembly)
536-
537- if not check then
538- match e.Symbol with
539- | FSharpEntity(_, abrvEnt, _) -> abrvEnt.XmlDocSig = xmlSig && abrvEnt.Assembly.SimpleName = assembly
540- | _ -> false
541- else
542- true )
583+ |> List.tryFind ( fun e -> matchesSymbol true e.Symbol || matchesAbbreviatedEntity true e.Symbol)
543584
544585 let ent =
545586 match ent with
546587 | Some ent -> Some ent
547588 | None ->
548589 entities
549- |> List.tryFind ( fun e ->
550- let check = ( e.Symbol.XmlDocSig = xmlSig)
551-
552- if not check then
553- match e.Symbol with
554- | FSharpEntity(_, abrvEnt, _) -> abrvEnt.XmlDocSig = xmlSig
555- | _ -> false
556- else
557- true )
590+ |> List.tryFind ( fun e -> matchesSymbol false e.Symbol || matchesAbbreviatedEntity false e.Symbol)
558591
559592 let symbol =
560593 match ent with
@@ -564,14 +597,48 @@ type ParseAndCheckResults
564597 |> List.tryPick ( fun e ->
565598 match e.Symbol with
566599 | FSharpEntity( ent, _, _) ->
567- match ent.MembersFunctionsAndValues |> Seq.tryFind ( fun f -> f.XmlDocSig = xmlSig) with
568- | Some e -> Some( e :> FSharpSymbol)
600+ match
601+ ent.MembersFunctionsAndValues
602+ |> Seq.tryPick ( fun f ->
603+ try
604+ if f.XmlDocSig = xmlSig then
605+ Some( f :> FSharpSymbol)
606+ else
607+ None
608+ with _ ->
609+ None)
610+ with
611+ | Some e -> Some e
569612 | None ->
570- match ent.FSharpFields |> Seq.tryFind ( fun f -> f.XmlDocSig = xmlSig) with
571- | Some e -> Some( e :> FSharpSymbol)
572- | None -> None
613+ match
614+ ent.FSharpFields
615+ |> Seq.tryPick ( fun f ->
616+ try
617+ if f.XmlDocSig = xmlSig then
618+ Some( f :> FSharpSymbol)
619+ else
620+ None
621+ with _ ->
622+ None)
623+ with
624+ | Some e -> Some e
625+ | None ->
626+ ent.UnionCases
627+ |> Seq.tryPick ( fun f ->
628+ try
629+ if f.XmlDocSig = xmlSig then
630+ Some( f :> FSharpSymbol)
631+ else
632+ None
633+ with _ ->
634+ None)
573635 | _ -> None)
574636
637+ let symbol =
638+ match symbol with
639+ | Some symbol when matchesSymbol false symbol -> Some symbol
640+ | _ -> None
641+
575642 match symbol with
576643 | None -> Error " No matching symbol information"
577644 | Some symbol ->
@@ -756,33 +823,12 @@ type ParseAndCheckResults
756823 }
757824
758825 member __.GetAllEntities ( publicOnly : bool ) : AssemblySymbol list =
759- try
760- let res =
761- [ yield !
762- AssemblyContent.GetAssemblySignatureContent AssemblyContentType.Full checkResults.PartialAssemblySignature
763- let ctx = checkResults.ProjectContext
764-
765- let assembliesByFileName =
766- ctx.GetReferencedAssemblies()
767- |> List.groupBy ( fun asm -> asm.FileName)
768- |> List.rev // if mscorlib.dll is the first then FSC raises exception when we try to
769- // get Content.Entities from it.
770-
771- for fileName, signatures in assembliesByFileName do
772- let contentType =
773- if publicOnly then
774- AssemblyContentType.Public
775- else
776- AssemblyContentType.Full
777-
778- let content =
779- AssemblyContent.GetAssemblyContent entityCache.Locking contentType fileName signatures
826+ if publicOnly then
827+ cachedPublicEntities.Force()
828+ else
829+ cachedFullEntities.Force()
780830
781- yield ! content ]
782-
783- res
784- with _ ->
785- []
831+ member __.GetCrefResolver () = cachedCrefResolver.Force()
786832
787833 member __.GetAllSymbolUsesInFile () = checkResults.GetAllUsesOfAllSymbolsInFile()
788834
0 commit comments