From 25bfec92e4a45a5aea244c7e00f3ab2d065df0fa Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 27 Sep 2022 09:52:34 +0200 Subject: [PATCH 1/2] Reflecting PR feedback - keeping values internal where possible - not disposing a dict, but rather a function for keyword description lookup --- src/Compiler/Service/FSharpCheckerResults.fs | 6 +++--- src/Compiler/Service/ServiceDeclarationLists.fs | 2 +- src/Compiler/Service/ServiceDeclarationLists.fsi | 2 +- src/Compiler/Service/ServiceLexing.fs | 7 ++++++- src/Compiler/Service/ServiceLexing.fsi | 2 +- ...FSharp.CompilerService.SurfaceArea.netstandard.expected | 3 --- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 2abbb49b4d2..70647f70d59 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -2652,9 +2652,9 @@ type FSharpCheckFileResults ToolTipText.ToolTipText [ for kw in names do - match Tokenization.FSharpKeywords.KeywordsDescriptionLookup.TryGetValue kw with - | false, _ -> () - | true, kwDescription -> + match Tokenization.FSharpKeywords.KeywordsDescriptionLookup kw with + | None -> () + | Some kwDescription -> let kwText = kw |> TaggedText.tagKeyword |> wordL |> LayoutRender.toArray let kwTip = ToolTipElementData.Create(kwText, FSharpXmlDoc.None) diff --git a/src/Compiler/Service/ServiceDeclarationLists.fs b/src/Compiler/Service/ServiceDeclarationLists.fs index 17f8b27213d..399a3037eac 100644 --- a/src/Compiler/Service/ServiceDeclarationLists.fs +++ b/src/Compiler/Service/ServiceDeclarationLists.fs @@ -39,7 +39,7 @@ type ToolTipElementData = Remarks: TaggedText[] option ParamName : string option } - static member Create(layout, xml, ?typeMapping, ?paramName, ?remarks) = + static member internal Create(layout, xml, ?typeMapping, ?paramName, ?remarks) = { MainDescription=layout; XmlDoc=xml; TypeMapping=defaultArg typeMapping []; ParamName=paramName; Remarks=remarks } /// A single data tip display element diff --git a/src/Compiler/Service/ServiceDeclarationLists.fsi b/src/Compiler/Service/ServiceDeclarationLists.fsi index b67f53da34b..5bb8dcd9173 100644 --- a/src/Compiler/Service/ServiceDeclarationLists.fsi +++ b/src/Compiler/Service/ServiceDeclarationLists.fsi @@ -31,7 +31,7 @@ type public ToolTipElementData = ParamName: string option } - static member Create: layout: TaggedText[] * xml: FSharpXmlDoc * ?typeMapping: TaggedText[] list * ?paramName: string * ?remarks: TaggedText[] -> ToolTipElementData + static member internal Create: layout: TaggedText[] * xml: FSharpXmlDoc * ?typeMapping: TaggedText[] list * ?paramName: string * ?remarks: TaggedText[] -> ToolTipElementData /// A single tool tip display element // diff --git a/src/Compiler/Service/ServiceLexing.fs b/src/Compiler/Service/ServiceLexing.fs index 6ee75eab602..94e485b98a9 100644 --- a/src/Compiler/Service/ServiceLexing.fs +++ b/src/Compiler/Service/ServiceLexing.fs @@ -1216,7 +1216,12 @@ module FSharpKeywords = let KeywordsWithDescription = PrettyNaming.keywordsWithDescription - let KeywordsDescriptionLookup = KeywordsWithDescription |> dict + let internal KeywordsDescriptionLookup = + let d = KeywordsWithDescription |> dict + fun kw -> + match d.TryGetValue kw with + | false, _ -> None + | true, desc -> Some desc let KeywordNames = Lexhelp.Keywords.keywordNames diff --git a/src/Compiler/Service/ServiceLexing.fsi b/src/Compiler/Service/ServiceLexing.fsi index a53bba2669f..39b2febf315 100755 --- a/src/Compiler/Service/ServiceLexing.fsi +++ b/src/Compiler/Service/ServiceLexing.fsi @@ -345,7 +345,7 @@ module FSharpKeywords = val KeywordsWithDescription: (string * string) list /// A lookup from keywords to their descriptions - val KeywordsDescriptionLookup: System.Collections.Generic.IDictionary + val internal KeywordsDescriptionLookup: (string -> string option) /// All the keywords in the F# language val KeywordNames: string list diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected index 736193358e7..6c3b9c7a42f 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.CompilerService.SurfaceArea.netstandard.expected @@ -3977,7 +3977,6 @@ FSharp.Compiler.EditorServices.ToolTipElementData FSharp.Compiler.EditorServices.ToolTipElementData: Boolean Equals(FSharp.Compiler.EditorServices.ToolTipElementData) FSharp.Compiler.EditorServices.ToolTipElementData: Boolean Equals(System.Object) FSharp.Compiler.EditorServices.ToolTipElementData: Boolean Equals(System.Object, System.Collections.IEqualityComparer) -FSharp.Compiler.EditorServices.ToolTipElementData: FSharp.Compiler.EditorServices.ToolTipElementData Create(FSharp.Compiler.Text.TaggedText[], FSharp.Compiler.Symbols.FSharpXmlDoc, Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Text.TaggedText[]]], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Text.TaggedText[]]) FSharp.Compiler.EditorServices.ToolTipElementData: FSharp.Compiler.Symbols.FSharpXmlDoc XmlDoc FSharp.Compiler.EditorServices.ToolTipElementData: FSharp.Compiler.Symbols.FSharpXmlDoc get_XmlDoc() FSharp.Compiler.EditorServices.ToolTipElementData: FSharp.Compiler.Text.TaggedText[] MainDescription @@ -9901,8 +9900,6 @@ FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharp FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharpList`1[System.String] get_KeywordNames() FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.String,System.String]] KeywordsWithDescription FSharp.Compiler.Tokenization.FSharpKeywords: Microsoft.FSharp.Collections.FSharpList`1[System.Tuple`2[System.String,System.String]] get_KeywordsWithDescription() -FSharp.Compiler.Tokenization.FSharpKeywords: System.Collections.Generic.IDictionary`2[System.String,System.String] KeywordsDescriptionLookup -FSharp.Compiler.Tokenization.FSharpKeywords: System.Collections.Generic.IDictionary`2[System.String,System.String] get_KeywordsDescriptionLookup() FSharp.Compiler.Tokenization.FSharpKeywords: System.String NormalizeIdentifierBackticks(System.String) FSharp.Compiler.Tokenization.FSharpLexer FSharp.Compiler.Tokenization.FSharpLexer: Void Tokenize(FSharp.Compiler.Text.ISourceText, Microsoft.FSharp.Core.FSharpFunc`2[FSharp.Compiler.Tokenization.FSharpToken,Microsoft.FSharp.Core.Unit], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[System.String], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.String]], Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Tokenization.FSharpLexerFlags], Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpMap`2[System.String,System.String]], Microsoft.FSharp.Core.FSharpOption`1[System.Threading.CancellationToken]) From 642b66b3aaf926023947eb4bfe703424835989bd Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Tue, 27 Sep 2022 11:26:09 +0200 Subject: [PATCH 2/2] Satisfying Fantomas rules --- src/Compiler/Driver/CompilerImports.fs | 1 + src/Compiler/Service/ServiceLexing.fs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Driver/CompilerImports.fs b/src/Compiler/Driver/CompilerImports.fs index 56513446bd3..a329635b609 100644 --- a/src/Compiler/Driver/CompilerImports.fs +++ b/src/Compiler/Driver/CompilerImports.fs @@ -2142,6 +2142,7 @@ and [] TcImports CheckDisposed() let tcConfig = tcConfigP.Get ctok + let runMethod = match tcConfig.parallelReferenceResolution with | ParallelReferenceResolution.On -> NodeCode.Parallel diff --git a/src/Compiler/Service/ServiceLexing.fs b/src/Compiler/Service/ServiceLexing.fs index 94e485b98a9..80cfb38cc6c 100644 --- a/src/Compiler/Service/ServiceLexing.fs +++ b/src/Compiler/Service/ServiceLexing.fs @@ -1216,8 +1216,9 @@ module FSharpKeywords = let KeywordsWithDescription = PrettyNaming.keywordsWithDescription - let internal KeywordsDescriptionLookup = + let internal KeywordsDescriptionLookup = let d = KeywordsWithDescription |> dict + fun kw -> match d.TryGetValue kw with | false, _ -> None