resharper-fsharp icon indicating copy to clipboard operation
resharper-fsharp copied to clipboard

Type annotations improvements

Open En3Tho opened this issue 3 years ago • 8 comments

I've been working on this for some time and instead of writing tests right away I've used ide manual checking. So now all of those tests are gone it seems -.-

This was supposed to intoduce granular parameter annotation, let!/use! local values annotations, member and property annotations, logically split function annotation and parameter/value annotation, also fix functions with no parameters but without tests it's hard to check.. I will write some more when I have more time.

Problems with my code: Initially I took approach of splitting every annotateable pattern into separate functions but this approach is problematic because I coudn't find any way to get type of ArrayOrListPat/WildPat/ActivePatternPat (or something like that) on it's own. I mean it looks like there is simply no corresponding unique fcssymbol with type information for those.

That made me split my code into 2 parts - handling parameters and non-parameters. I think this is a kinda working approach for now but I'm not happy with my implementation because it's messy right now.

The idea is that we either have locals or parameters and for parameters we can extract the type because there is a function or a method providing those. So even aforementioned problematic patterns are easy to annotate.

For locals it's different. We can annotate IReferencePatterns only, sadly.

I'm sorta struggling making the right split for patterns with types specified and patterns with no types. I guess some kind of option is okay?

Changes are mostly moving tests to different folders

En3Tho avatar May 03 '22 17:05 En3Tho

Not sure build failure is related (frontend)

En3Tho avatar May 20 '22 12:05 En3Tho

This is ready for review.

I've formatted code and cleaned up all that initial wip mess I made.

In this pr: parameter annotations, member annotations, let! bindings annotations.

Various checks to determine if pattern is annotated. Split code to different logical modules.

Any parameter pattern can be annotated (I guess), values are only annotated I'd there is a ref pat bound to it.

There are still some unresolved questions (like with member val) and I'm not sure I've done everything right from api usage standpoint.

En3Tho avatar May 21 '22 10:05 En3Tho

I've resolved all previous review comments I believe. This needs a new review anyway.

En3Tho avatar May 24 '22 10:05 En3Tho

Added an special case for ConstrainedTypeUsage - that was sorta quirky

En3Tho avatar May 24 '22 13:05 En3Tho

I did some fixes, but not all of them. I guess more tests actually need to be written (like those examples you've shown in CR). I like this generic way of annotating things but I guess to rewrite it I need more stuff to check. Or maybe I'm wrong and it's just type of node that needs to be changed.

En3Tho avatar May 25 '22 08:05 En3Tho

@auduchinok I belive I've fixed all the thing you noted except for those that are still in question. I've added those tricky stuff you've mentioned in tests like let x: [] _ = 1 Please look at specifyReturnTypeInfo function, it is super quircky, sadly. Should I add more tests or maybe remove some? And I guess I have to run other tests to see if I changed behavior of some other features.

En3Tho avatar May 26 '22 11:05 En3Tho

@auduchinok Any new input about this pr?

En3Tho avatar Jun 22 '22 11:06 En3Tho

@En3Tho Sorry for the delay, I'll try to get back to it today.

auduchinok avatar Jun 22 '22 11:06 auduchinok

@auduchinok First of all I want to say sorry for spending so much of your time on reviews and never actually finishing the feature. Is it still needed? I believe some of the tests written here could be useful but I'm not sure about general work. How much has changed between verisons? Is there an already released version of this?

P.S. sometimes I with there was a reverse version of this, e.g. remove type annotation. But I'm not sure how to do proper analysis because IDE have to be sure type is rooted somewhere else and it's exactly the same not to break code. Do you think it's useful to have?

En3Tho avatar Nov 30 '23 18:11 En3Tho

@En3Tho Thanks for bringing this up. I'm going to work on it. I think the tests could be useful indeed, thanks!

auduchinok avatar Jan 16 '24 14:01 auduchinok