-
Notifications
You must be signed in to change notification settings - Fork 793
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
Better classification: such colors, much wow #9511
Conversation
[ | ||
FSharpClassificationTypes.MutableVar, (Color.FromRgb(160uy, 128uy, 0uy), Color.FromRgb(255uy, 210uy, 28uy)) | ||
FSharpClassificationTypes.Printf, (Color.FromRgb(43uy, 145uy, 175uy), Color.FromRgb(78uy, 220uy, 176uy)) | ||
FSharpClassificationTypes.Disposable, (Colors.Tomato, Colors.Tomato) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't be the actual color picked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also lmao "picked" because it's a tomato
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aww why not keep tomato = disposable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I already love Tomato, IDisposable
is scary, and tomatos are explosive, I like the combo :)
This implements #4618 . So 👍. Tomatoes are disposable so it's a sensible choice. |
One thing that VSCode does in its semantic highlighting API is separating token type and modifiers - each token can be classified as a single type and has zero or more modifiers. From VSCode docs:
This means instead of having |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks straight forward to me. I like the additional semantic classification types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's still some additional design considerations left:
- Work through a better color (that meets accessibility standards) for disposables
- Consider going back to the old behavior for constructors where they looked like the types they were constructing
- Consider renaming
ReferenceType
andValueType
toClass
andStruct
vsintegration/src/FSharp.Editor/Classification/ClassificationDefinitions.fs
Outdated
Show resolved
Hide resolved
Okay, decided to revert the "color ctors as methods" approach. They're classified as specific kinds of constructors, but the VS coloring will use the current approach of coloring the constructors like the type: All other considerations I had are now resolved. The big remaining things are:
|
Does this only apply for specific ctors with |
@abelbraaksma classification depends on name resolution, so the answer is "whatever the compiler resolves it to be". That kind of "constructor" isn't a constructor, but a function that returns an instance of something. So the function is resolved as a function, which leads to getting classified as such. It's no different than a function which constructs a new disposable via object expressions. |
From the VSCode spec, the following are covered by this API:
The following are not:
|
Got it, makes sense. I was mainly just curious. Coloring a "ctor as a function" as a function, because it's a function, seems pretty ok to me. I really like this pr, it's absolutely awesome! |
Do you mean "type alias" here? Cause I can see some benefit in a (slightly) different color to distinguish Though in practice I guess that's pretty rare, since usually you don't specify the type anyway. |
* First go at updated classifications * More complete classification * More accurate classification that roughly matches glyph computations * Proper measure classification and tests * remove ze comments * Add clarifying comment * Distinguish property setter args from named argument labels * Color local values, don't color properties and property-like things that way * Dont't do the dumb * We can't distinguish between params and locals right now * Updates per feedback from myself * do discards right * Accessible colors for disposables + some fixes * Remove exports for things we don't do anymore * Softer green * Reduce diff
* First go at updated classifications * More complete classification * More accurate classification that roughly matches glyph computations * Proper measure classification and tests * remove ze comments * Add clarifying comment * Distinguish property setter args from named argument labels * Color local values, don't color properties and property-like things that way * Dont't do the dumb * We can't distinguish between params and locals right now * Updates per feedback from myself * do discards right * Accessible colors for disposables + some fixes * Remove exports for things we don't do anymore * Softer green * Reduce diff
* First go at updated classifications * More complete classification * More accurate classification that roughly matches glyph computations * Proper measure classification and tests * remove ze comments * Add clarifying comment * Distinguish property setter args from named argument labels * Color local values, don't color properties and property-like things that way * Dont't do the dumb * We can't distinguish between params and locals right now * Updates per feedback from myself * do discards right * Accessible colors for disposables + some fixes * Remove exports for things we don't do anymore * Softer green * Reduce diff
This all started because I wanted to fix #4618 and then fix #6117
Firstly, this PR produces a lot more distinct classification data than before. This can allow a much finer degree of control over what an editor chooses to do with it, such as coloring. It is done in a way that matches how we compute
FSharpGlyph
data.For VS specifically, we do centralize a lot of these classification types to more common Roslyn classifications. That said, a lot have been updated so that we can have some Fancy Colors.
Currently, to get these Fancy Colors in VS, you'll need to toggle a setting int he C# settings. I will endeavor to submit a PR to Roslyn to move this to a more central location, or have a similar setting specifically for F#.
Once this is turned on, you'll see the pretty colors.
Structs are distinct from classes. Methods and properties are colored distinctly:
This applies to records and DUs too:
Anonymous record labels are now classified:
Functions, methods, constructors are colored similarly, unless they are record labels. Note the distinction between constructor invocation and qualifying something with the class name:
Disposable types and bindings are classified (color TBD, I picked
Colors.Tomato
because the name seemed funny to me):(note that the
this
was colored, but if you mark it as a discard then it won't be)Here's what a lot of different things (generics, class, structs vs classes, UoM, functions, type abbreviations, exceptions) look like together:
And here's what it looks like in some larger, more involved/complicated parts of the F# compiler codebase:
THIS ALSO FIXED SOME STUFF
Indexers now don't color the
.
like it was a classMultiple active patterns can still be marked as "unused" and the ranges for that are still bonkers, but at least it doesn't show random white characters anymore:
Before:
After:
BUT GENERIC PARAMETERS CAN STILL BE WEIRD