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

Added more highlightings #136

Closed
wants to merge 7 commits into from

Conversation

En3Tho
Copy link
Contributor

@En3Tho En3Tho commented Jun 9, 2020

More highlightings for F#!

  1. Computation expressions
  2. Extension methods
  3. Extension properties
    4. Generic constraints (not a separate option, gets auto highlighted like method or property)
    5. F# methods (let functions compiled as methods) (goes to FSharp functions)
  4. F# value functions
  5. F# mutable value functions
  6. Units of measure

Before:
image
After:
image

There is still work to do with parameter highlighting, but after spending some time and getting no result I've decided to try pulling this as it already covers about 90% of what I wanted to do

TODO:

  • Fix current tests. I need some advice here becase I have to change "gold" files and maybe you don't really need all those new highlighting options (althought I personanly find them all useful)
  • Add more tests
  • Ask someone from compiler team about highlighting of method parameters (couldn't figure out how to do this one, sadly)

@vasily-kirichenko
Copy link
Contributor

String literals and properties are given almost the same color:

image

@En3Tho
Copy link
Contributor Author

En3Tho commented Jun 9, 2020

Yes, but that's all up to the user. You can pick any color you want. I just wanted to demonstrate the ability to pick a color if you want extension methods/props to be more distinguishable. I mean you can try it yourself and get your own results :)
Edit: extension methods and properties by default inherit highliting colors of usual methods and properties

Copy link
Member

@auduchinok auduchinok left a comment

Choose a reason for hiding this comment

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

@En3Tho It looks very nice! Please add tests for the things that will now be highlighted differently.

@auduchinok
Copy link
Member

Fix current tests. I need some advice here becase I have to change "gold" files and maybe you don't really need all those new highlighting options (althought I personanly find them all useful)

It's OK to just update them with newer ids.

Add more tests (if needed)

Please do. 🙂

En3Tho added 2 commits June 13, 2020 19:08
Removed FSharpParameter processing due to unexpected behaviour
@En3Tho
Copy link
Contributor Author

En3Tho commented Jun 14, 2020

Sorry for the delay. I've fixed old tests and added new ones. Please tell me if there is more work I need to do on this thing.
Sadly, I couldn't find a way to get this FSharpParameter thing with static constrains to work properly. F# compiler knows that when 'T : (static member Two : 'T) - this is a Property and when 'T : (static member Two : unit -> 'T) - now this is a Method but it's either me or API does not give out this kind of info that easily
So it was really easy to confuse properties and methods. Also it gave false results at object instantiation in case like this:
image
I guess it's better to just leave those things highlighted as simple values for now.
Also, I will note again that FSharp Method's and FSharp Function's are not the same thing - FSharp Method is something we get from the "outside" (e.g. C#) and FSharp Function comes from F#. F# function can either be method or func but we have decided to not give out this kind of info via highlighting.
Also, should I check for [Extension] Attribute when highlighting extension methods? It's mainly for C# I guess and F# shouldn't really care about it internally. But on the other side it might be useful.

@En3Tho
Copy link
Contributor Author

En3Tho commented Jun 14, 2020

Also, without IsValCompiledAsMethodCheck things like these are not being shown as methods for some reason:
image
vs
image
I find this a kind of bug at F# comp side because it's a value, it's compiled as method, but for some reason it's not a function type. I'd say unit -> 'T signature instead of just 'T would be a more accurate one as it's actually a method

@En3Tho En3Tho requested a review from auduchinok June 15, 2020 09:56
En3Tho added 2 commits June 15, 2020 14:46
Added an additional IsTypeFunction check to determine if value needs to be highlighted as a function
Copy link
Member

@auduchinok auduchinok left a comment

Choose a reason for hiding this comment

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

@En3Tho Thanks! It's great to see a lot of new things covered in tests, but some cases seem a bit overcomplicated by seemingly not very related code. Could you try stripping some of it so it's easier to see the highlightings that each test case is about?

@En3Tho En3Tho requested a review from auduchinok June 15, 2020 17:23
auduchinok pushed a commit that referenced this pull request Jun 16, 2020
Fixed 2 broken tests.
Removed FSharpParameter processing due to unexpected behaviour

Added more tests

FSharp Function highlighting now inherits from Value, not Method
Added an additional IsTypeFunction check to determine if value needs to be highlighted as a function

Added more tests for FSharpFunction highlighting

Updated tests to be smaller and more concise

Fixed some tests with TestReferences attribute.

Cleanup
@auduchinok
Copy link
Member

@En3Tho Thanks for this change!
I'm glad you've found a way to highlight the type functions too (I wasn't sure if it's possible to see it via FCS right now).

@auduchinok
Copy link
Member

Sorry, I've messed it up a bit trying to push a small cleanup. The changes got merged without closing the PR automatically, so I'll close it manually.

@auduchinok auduchinok closed this Jun 16, 2020
@En3Tho
Copy link
Contributor Author

En3Tho commented Jun 16, 2020

No problem. Thank you for accepting :)

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.

3 participants