From dbf006fc29ae7301e45a9a1e06bf61a1d5aab065 Mon Sep 17 00:00:00 2001 From: Adam Tao Date: Mon, 27 Feb 2023 20:30:00 +0800 Subject: [PATCH 1/3] refactor(Util.fs): Remove id Signed-off-by: Adam Tao --- src/CSharpLanguageServer/Util.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CSharpLanguageServer/Util.fs b/src/CSharpLanguageServer/Util.fs index 7d817e8d..856ebb59 100644 --- a/src/CSharpLanguageServer/Util.fs +++ b/src/CSharpLanguageServer/Util.fs @@ -68,14 +68,14 @@ let SemanticTokenTypeMap = ClassificationTypeMap |> Map.values |> Seq.distinct - |> fun types -> Seq.zip types (Seq.initInfinite (id >> uint32)) // There is no `flip` in F#, sadly + |> fun types -> Seq.zip types (Seq.initInfinite uint32) // There is no `flip` in F#, sadly |> Map.ofSeq let SemanticTokenModifierMap = ClassificationModifierMap |> Map.values |> Seq.distinct - |> fun modifiers -> Seq.zip modifiers (Seq.initInfinite (id >> uint32)) + |> fun modifiers -> Seq.zip modifiers (Seq.initInfinite uint32) |> Map.ofSeq let SemanticTokenTypes = From 1b0fb139307ada7d3ffa608350b9e301624c88e0 Mon Sep 17 00:00:00 2001 From: Adam Tao Date: Mon, 27 Feb 2023 20:35:25 +0800 Subject: [PATCH 2/3] refactor(Util.fs): Remove a few lambda functions via flip Signed-off-by: Adam Tao --- src/CSharpLanguageServer/Util.fs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/CSharpLanguageServer/Util.fs b/src/CSharpLanguageServer/Util.fs index 856ebb59..3db94637 100644 --- a/src/CSharpLanguageServer/Util.fs +++ b/src/CSharpLanguageServer/Util.fs @@ -64,18 +64,22 @@ let ClassificationModifierMap = Map [ (ClassificationTypeNames.StaticSymbol, "static") ] +// flip f takes its (first) two arguments in the reverse order of f, just like +// the function with the same name in Haskell. +let flip f x y = f y x + let SemanticTokenTypeMap = ClassificationTypeMap |> Map.values |> Seq.distinct - |> fun types -> Seq.zip types (Seq.initInfinite uint32) // There is no `flip` in F#, sadly + |> flip Seq.zip (Seq.initInfinite uint32) |> Map.ofSeq let SemanticTokenModifierMap = ClassificationModifierMap |> Map.values |> Seq.distinct - |> fun modifiers -> Seq.zip modifiers (Seq.initInfinite uint32) + |> flip Seq.zip (Seq.initInfinite uint32) |> Map.ofSeq let SemanticTokenTypes = @@ -91,12 +95,12 @@ let SemanticTokenModifiers = let GetSemanticTokenIdFromClassification (classification: string) = ClassificationTypeMap |> Map.tryFind classification - |> Option.bind (fun t -> Map.tryFind t SemanticTokenTypeMap) + |> Option.bind (flip Map.tryFind SemanticTokenTypeMap) let GetSemanticTokenModifierFlagFromClassification (classification: string) = ClassificationModifierMap |> Map.tryFind classification - |> Option.bind (fun m -> Map.tryFind m SemanticTokenModifierMap) + |> Option.bind (flip Map.tryFind SemanticTokenModifierMap) |> Option.defaultValue 0u |> int32 |> (<<<) 1u From f0bbc212b000737cab51718bcedf1d85d0b72921 Mon Sep 17 00:00:00 2001 From: Adam Tao Date: Mon, 27 Feb 2023 20:42:54 +0800 Subject: [PATCH 3/3] feat(Util.fs): Add ConstantName and DelegateName to semantic tokens Signed-off-by: Adam Tao --- src/CSharpLanguageServer/Util.fs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CSharpLanguageServer/Util.fs b/src/CSharpLanguageServer/Util.fs index 3db94637..cb69e396 100644 --- a/src/CSharpLanguageServer/Util.fs +++ b/src/CSharpLanguageServer/Util.fs @@ -35,7 +35,9 @@ let unwindProtect cleanupFn op = let ClassificationTypeMap = Map [ (ClassificationTypeNames.ClassName, "class"); (ClassificationTypeNames.Comment, "comment"); + (ClassificationTypeNames.ConstantName, "property"); (ClassificationTypeNames.ControlKeyword, "keyword"); + (ClassificationTypeNames.DelegateName, "class"); (ClassificationTypeNames.EnumMemberName, "enumMember"); (ClassificationTypeNames.EnumName, "enum"); (ClassificationTypeNames.EventName, "event");