Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
DedSec256 committed Nov 8, 2024
1 parent 2846ee9 commit 21e091f
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ type public Strings() =
static member FSharpTypeHints_LocalBindings_Description = Strings.ResourceManager.GetString("FSharpTypeHints_LocalBindings_Description")
static member FSharpTypeHints_ShowPipeReturnTypes_Description = Strings.ResourceManager.GetString("FSharpTypeHints_ShowPipeReturnTypes_Description")
static member FSharpTypeHints_HideSameLinePipe_Description = Strings.ResourceManager.GetString("FSharpTypeHints_HideSameLinePipe_Description")
static member FSharpTypeHints_MatchClauses_Description = Strings.ResourceManager.GetString("FSharpTypeHints_MatchClauses_Description")
static member FSharpTypeHints_MatchClausesSettings_Header = Strings.ResourceManager.GetString("FSharpTypeHints_MatchClausesSettings_Header")
static member FSharpTypeHints_MatchPatterns_Description = Strings.ResourceManager.GetString("FSharpTypeHints_MatchPatterns_Description")
static member FSharpTypeHints_MatchPatternsSettings_Header = Strings.ResourceManager.GetString("FSharpTypeHints_MatchPatternsSettings_Header")
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
<data name="FSharpTypeHints_HideSameLinePipe_Description" xml:space="preserve">
<value>Hide when |&gt; is on same line as argument</value>
</data>
<data name="FSharpTypeHints_MatchClauses_Description" xml:space="preserve">
<value>Type hints for match clauses</value>
<data name="FSharpTypeHints_MatchPatterns_Description" xml:space="preserve">
<value>Type hints for match patterns</value>
</data>
<data name="FSharpTypeHints_MatchClausesSettings_Header" xml:space="preserve">
<value>Match clauses</value>
<data name="FSharpTypeHints_MatchPatternsSettings_Header" xml:space="preserve">
<value>Match patterns</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ type FSharpTypeHintOptions =

[<SettingsEntry(PushToHintMode.PushToShowHints,
DescriptionResourceType = typeof<Strings>,
DescriptionResourceName = nameof(Strings.FSharpTypeHints_MatchClauses_Description))>]
mutable ShowTypeHintsForMatchClauses: PushToHintMode }
DescriptionResourceName = nameof(Strings.FSharpTypeHints_MatchPatterns_Description))>]
mutable ShowTypeHintsForMatchPatterns: PushToHintMode }


[<OptionsPage("FSharpOptionsPage", "F#", typeof<ProjectModelThemedIcons.Fsharp>)>]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ type public Strings() =
static member FSharpTypeHints_ShowPipeReturnTypes_Description = Strings.ResourceManager.GetString("FSharpTypeHints_ShowPipeReturnTypes_Description")
static member FSharpTypeHints_HideSameLinePipe_Description = Strings.ResourceManager.GetString("FSharpTypeHints_HideSameLinePipe_Description")
static member FSharpTypeHints_PipesSettings_Header = Strings.ResourceManager.GetString("FSharpTypeHints_PipesSettings_Header")
static member FSharpTypeHints_MatchClausesSettings_Header = Strings.ResourceManager.GetString("FSharpTypeHints_MatchClausesSettings_Header")
static member FSharpTypeHints_MatchPatternsSettings_Header = Strings.ResourceManager.GetString("FSharpTypeHints_MatchPatternsSettings_Header")
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<data name="FSharpTypeHints_PipesSettings_Header" xml:space="preserve">
<value>Pipe operators</value>
</data>
<data name="FSharpTypeHints_MatchClausesSettings_Header" xml:space="preserve">
<value>Match clauses</value>
<data name="FSharpTypeHints_MatchPatternsSettings_Header" xml:space="preserve">
<value>Match patterns</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ type FSharpLocalBindingTypeHintBulbActionsProvider private () =
static member val Instance = FSharpLocalBindingTypeHintBulbActionsProvider()

type FSharpMatchClauseTypeHintBulbActionsProvider private () =
inherit FSharpTypeHintBulbActionsProvider((fun x -> x.ShowTypeHintsForMatchClauses), Strings.FSharpTypeHints_MatchClausesSettings_Header)
inherit FSharpTypeHintBulbActionsProvider((fun x -> x.ShowTypeHintsForMatchPatterns), Strings.FSharpTypeHints_MatchPatternsSettings_Header)
static member val Instance = FSharpMatchClauseTypeHintBulbActionsProvider()
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type FSharpTypeHintsOptionsPage(lifetime: Lifetime, optionsPageContext: OptionsP
this.AddHeader(Strings.FSharpTypeHints_LocalBindingsSettings_Header) |> ignore
this.AddVisibilityOption(fun (s: FSharpTypeHintOptions) -> s.ShowTypeHintsForLocalBindings)

this.AddHeader(Strings.FSharpTypeHints_MatchClausesSettings_Header) |> ignore
this.AddVisibilityOption(fun (s: FSharpTypeHintOptions) -> s.ShowTypeHintsForMatchClauses)
this.AddHeader(Strings.FSharpTypeHints_MatchPatternsSettings_Header) |> ignore
this.AddVisibilityOption(fun (s: FSharpTypeHintOptions) -> s.ShowTypeHintsForMatchPatterns)


this.AddHeader(Strings.FSharpTypeHints_PipesSettings_Header) |> ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,32 @@ open JetBrains.TextControl.DocumentMarkup.Adornments.IntraTextAdornments
type private NodesRequiringHints =
{ TopLevelNodes: List<ITreeNode>
LocalNodes: List<ITreeNode>
MatchClauses: List<ITreeNode> }
MatchNodes: List<ITreeNode> }

type private FSharpTypeHintSettings =
{ TopLevelMembers: PushToHintMode
LocalBindings: PushToHintMode
MatchClauses: PushToHintMode } with
MatchPatterns: PushToHintMode } with

static member Create(settingsStore: IContextBoundSettingsStore) =
{ TopLevelMembers = settingsStore.GetValue(fun (key: FSharpTypeHintOptions) -> key.ShowTypeHintsForTopLevelMembers)
.EnsureInlayHintsDefault(settingsStore)
LocalBindings = settingsStore.GetValue(fun (key: FSharpTypeHintOptions) -> key.ShowTypeHintsForLocalBindings)
.EnsureInlayHintsDefault(settingsStore)
MatchClauses = settingsStore.GetValue(fun (key: FSharpTypeHintOptions) -> key.ShowTypeHintsForMatchClauses)
.EnsureInlayHintsDefault(settingsStore)}
MatchPatterns = settingsStore.GetValue(fun (key: FSharpTypeHintOptions) -> key.ShowTypeHintsForMatchPatterns)
.EnsureInlayHintsDefault(settingsStore)}

member x.IsDisabled =
x.TopLevelMembers = PushToHintMode.Never &&
x.LocalBindings = PushToHintMode.Never &&
x.MatchClauses = PushToHintMode.Never
x.MatchPatterns = PushToHintMode.Never


type private MembersVisitor(settings) =
inherit TreeNodeVisitor<NodesRequiringHints>()
let disabledForTopBindings = settings.TopLevelMembers = PushToHintMode.Never
let disabledForLocalBindings = settings.LocalBindings = PushToHintMode.Never
let disabledForMatchClauses = settings.MatchClauses = PushToHintMode.Never
let disabledForMatchPatterns = settings.MatchPatterns = PushToHintMode.Never

let isTopLevelMember (node: ITreeNode) =
match node with
Expand All @@ -62,7 +62,7 @@ type private MembersVisitor(settings) =
| _ -> false

override x.VisitNode(node, context) =
if disabledForLocalBindings && disabledForMatchClauses && isTopLevelMember node then () else
if disabledForLocalBindings && disabledForMatchPatterns && isTopLevelMember node then () else

for child in node.Children() do
if disabledForTopBindings && isTopLevelMember child || disabledForLocalBindings && isLocalBinding child
Expand Down Expand Up @@ -115,9 +115,9 @@ type private MembersVisitor(settings) =
x.VisitNode(forEachExpr, context)

override x.VisitMatchClause(matchClause, context) =
if not disabledForMatchClauses then
if not disabledForMatchPatterns then
let result = collectTypeHintAnchorsForMatchClause matchClause
context.MatchClauses.AddRange(result)
context.MatchNodes.AddRange(result)

x.VisitNode(matchClause, context)

Expand Down Expand Up @@ -225,17 +225,17 @@ type private PatternsHighlightingProcess(fsFile, settingsStore: IContextBoundSet

adornNodes topLevelNodes settings.TopLevelMembers FSharpTopLevelMembersTypeHintBulbActionsProvider.Instance
adornNodes localNodes settings.LocalBindings FSharpLocalBindingTypeHintBulbActionsProvider.Instance
adornNodes matchClauses settings.MatchClauses FSharpMatchClauseTypeHintBulbActionsProvider.Instance
adornNodes matchClauses settings.MatchPatterns FSharpMatchClauseTypeHintBulbActionsProvider.Instance

highlightingConsumer.CollectHighlightings()

override x.Execute(committer) =
let consumer = { TopLevelNodes = List(); LocalNodes = List(); MatchClauses = List() }
let consumer = { TopLevelNodes = List(); LocalNodes = List(); MatchNodes = List() }
fsFile.Accept(MembersVisitor(settings), consumer)

let topLevelNodes = consumer.TopLevelNodes |> Array.ofSeq
let localNodes = consumer.LocalNodes |> Array.ofSeq
let matchClauses = consumer.MatchClauses |> Array.ofSeq
let matchClauses = consumer.MatchNodes |> Array.ofSeq

// Visible range may be larger than document range by 1 char
// Intersect them to ensure commit doesn't throw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open NUnit.Framework
[<TestSettingsKey(typeof<FSharpTypeHintOptions>)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForTopLevelMembers", PushToHintMode.Always)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForLocalBindings", PushToHintMode.Always)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForMatchClauses", PushToHintMode.Always)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForMatchPatterns", PushToHintMode.Always)>]
type TypeHintStageTest() =
inherit FSharpHighlightingTestBase()

Expand All @@ -22,11 +22,11 @@ type TypeHintStageTest() =
[<Test>] member x.``Signatures - Show all 01``() = x.DoPatternsCommonTest()

[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForLocalBindings", PushToHintMode.Never)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForMatchClauses", PushToHintMode.Never)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForMatchPatterns", PushToHintMode.Never)>]
[<Test>] member x.``Signatures - Top level 01``() = x.DoPatternsCommonTest()

[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForTopLevelMembers", PushToHintMode.Never)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForMatchClauses", PushToHintMode.Never)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForMatchPatterns", PushToHintMode.Never)>]
[<Test>] member x.``Signatures - Locals 01``() = x.DoPatternsCommonTest()

[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForTopLevelMembers", PushToHintMode.Never)>]
Expand All @@ -39,7 +39,7 @@ type TypeHintStageTest() =
[<TestSetting(typeof<GeneralInlayHintsOptions>, "DefaultMode", PushToHintMode.Never)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForTopLevelMembers", PushToHintMode.Default)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForLocalBindings", PushToHintMode.Default)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForMatchClauses", PushToHintMode.Default)>]
[<TestSetting(typeof<FSharpTypeHintOptions>, "ShowTypeHintsForMatchPatterns", PushToHintMode.Default)>]
[<Test>] member x.``Disabled 02 - By mode``() = x.DoPatternsCommonTest()

[<Test>] member x.``Signatures - Unfinished declarations 01``() = x.DoNamedTest()
Expand Down

0 comments on commit 21e091f

Please sign in to comment.