Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inlay hints/PatternTypeHintsStage: support other patterns #756

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DedSec256
Copy link
Collaborator

@DedSec256 DedSec256 commented Oct 31, 2024

{BEB256F4-5DD9-481A-8B66-8929F26EA3BB}

  • FCS update

@DedSec256 DedSec256 marked this pull request as ready for review October 31, 2024 15:01
@auduchinok
Copy link
Member

@DedSec256 Do you think it could make sense to introduce another option, so hints for bindings/parameter declarations could be controlled separately? With both currently defaulting to 'push-to-hint' it doesn't make much difference, but I'm also trying to imagine if somebody could want to make the declaration hints be always shown while keep the 'match' ones in push-to-hint mode.

@DedSec256 DedSec256 force-pushed the ber.a/matchClausePatterns branch from 3297ca0 to 5ce6bfb Compare November 7, 2024 23:26
@@ -41,34 +41,34 @@ let g||(15) = fun x -> ()

type A(x||(16)) =
do
let x||(17) = 3
Copy link
Collaborator Author

@DedSec256 DedSec256 Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidentally fixed the case when hints showed for some local bindings even if it was disabled

@DedSec256
Copy link
Collaborator Author

DedSec256 commented Nov 7, 2024

Perhaps, we can name it Match clause patterns

image

@auduchinok
Copy link
Member

auduchinok commented Nov 8, 2024

Perhaps, we can name it Match clause patterns

"Clause" sounds like a rather technical term to me. I've never heard it from non-compiler people. Something like "patterns" or "branches" may sound much more user-friendly here, I think?

@DedSec256 DedSec256 requested a review from auduchinok November 8, 2024 13:36
@@ -130,6 +130,21 @@ let (|String|) (x: MyStruct) : string = String(x.myString)

let f1 (x & Int(i) & String(s)) = ()


let _ = function x -> ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about splitting this test files into smaller ones, so it could be easier to think about unrelated cases separately?

member _.Dispose(): unit = ()

let delimiter (delim1, delim2, value) =
{ new IFormattable with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really a part of match-related test?

If the idea here is to test how different settings work, can these tests be simplified to only include minimal code needed for such tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to suggest we refactor these tests in a separate pull request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sounds good. Maybe we should merge the refactor first then.

@DedSec256 DedSec256 force-pushed the ber.a/matchClausePatterns branch from 21e091f to 38d2c7e Compare December 7, 2024 22:54
@DedSec256 DedSec256 force-pushed the ber.a/matchClausePatterns branch from 38d2c7e to c476a56 Compare December 16, 2024 19:39
@DedSec256 DedSec256 requested a review from auduchinok December 16, 2024 20:51
[<SettingsEntry(PushToHintMode.PushToShowHints,
DescriptionResourceType = typeof<Strings>,
DescriptionResourceName = nameof(Strings.FSharpTypeHints_MatchPatterns_Description))>]
mutable ShowTypeHintsForMatchPatterns: PushToHintMode }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the idea behind having separate settings for patterns in local bindings and match clauses?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we discussed this question here #756 (comment), or was it about something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it wasn't about having a setting specifically about match patterns? I think we don't want to end up introducing separate settings for each place where patterns are allowed.

let consumer = { TopLevelNodes = VisibilityConsumer(visibleRange, _.GetNavigationRange())
LocalNodes = VisibilityConsumer(visibleRange, _.GetNavigationRange()) }
let consumer = {
TopLevelNodes = VisibilityConsumer(visibleRange, _.GetNavigationRange())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reformat.

@@ -181,7 +196,25 @@ type private PatternsHighlightingProcess(fsFile, settingsStore: IContextBoundSet
createTypeHintHighlighting fcsType defaultDisplayContext range pushToHintMode actionsProvider false
|> ValueSome

| _ -> ValueNone
| :? IParametersOwnerPat as pattern ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this change?

let y||(27) = 5 in ()

match [[5]] with
| [[]||(28)]||(29) -> ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to do it recursively here?

| x :: _||(14) -> ()
| _ :: x :: _||(15) -> ()
| x :: _ :: _||(16) -> ()
| x :: Some y||(17) :: _||(18) -> ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to do it recursively here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for such cases I would like to see annotations for inner patterns as well

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the inferred types are going to be shown in the outer hint anyway, though. I'm not sure if it's helpful to show it for non-generic fields types. While it might help somewhat to see the types next to the patterns, I think about how to prevent such hints from becoming too noisy.

do
let x||(12) = 3
let x||(16) = 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DedSec256 This seems unrelated to match clauses. Could you split these test cases, please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a special test case where all hints are enabled and contains the minimum set of each hint category. Previously I split tests into smaller ones here
313392c

@DedSec256 DedSec256 force-pushed the ber.a/matchClausePatterns branch from c476a56 to a5717e3 Compare February 12, 2025 14:01
@DedSec256 DedSec256 changed the title Inlay hints/PatternTypeHintsStage: support match clause Inlay hints/PatternTypeHintsStage: support other patterns Feb 12, 2025
@DedSec256 DedSec256 force-pushed the ber.a/matchClausePatterns branch from a5717e3 to 098f0f5 Compare February 12, 2025 14:17
@DedSec256 DedSec256 force-pushed the ber.a/matchClausePatterns branch from 91179eb to b802973 Compare February 12, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants