Skip to content

Add type annotations as code lens #2368

Closed

Description

@saul

This is a feature request.

The type annotations displayed above value definitions in VS Code is really useful:
image

It would be great if we could utilise the 'code lens' feature of Visual Studio, as shown below:
image

I'm not sure how difficult this would be to add, but I'm under the impression that the code lens code is available on Roslyn:
https://github.com/dotnet/roslyn/blob/614299ff83da9959fa07131c6d0ffbc58873b6ae/src/Features/CSharp/Portable/CodeLens/CSharpCodeLensDisplayInfoService.cs

Activity

  1. vasily-kirichenko commented on Feb 4, 2017

    @vasily-kirichenko
    Contributor

    I looked at it earlier, the problem is that the API is ISyntaxNode based, which we don't support.

  2. vasily-kirichenko commented on Feb 4, 2017

    @vasily-kirichenko
    Contributor

    (BTW, I personally don't like the ionide feature - too much noise)

  3. forki commented on Feb 4, 2017

    @forki
    Contributor

    The signature feature is amazing. I really love it.

  4. vasily-kirichenko commented on Feb 4, 2017

    @vasily-kirichenko
    Contributor

    @forki go ahead :)

  5. forki commented on Feb 4, 2017

    @forki
    Contributor

    No I don't love it that much ;-)

  6. saul commented on Feb 4, 2017

    @saul
    ContributorAuthor

    Obviously if it was to be implemented we'd need to give the option to disable it in the settings.

  7. cartermp commented on Feb 4, 2017

    @cartermp
    Contributor

    I'm not sure how best to approach this - from what I understand, the CodeLens APIs themselves are closed source, so I believe that there is first a dependency on making them open. I can try to reach out to the people who own that area to see how feasible it would be to open them up so that the F# community can start implementing things like this feature request.

    In terms of specifically making CodeLens show type signatures, I agree that it's a cool thing and also agree that it ought to be toggled. I'm not too sure about making it on by default, though. It's a somewhat divisive feature, and a lot of care would have to go in to making sure that it isn't too "jumpy". I know @Krzysztof-Cieslak had to do some work here and may be able to offer some advice on that.

  8. vasily-kirichenko commented on Feb 4, 2017

    @vasily-kirichenko
    Contributor

    Type signatures in Ionide as "jumpy" as before. It makes the feature even less enjoyable.

  9. cartermp commented on Feb 4, 2017

    @cartermp
    Contributor

    Right, and I would say that if it were implemented, it should be off by default until a non-jumpy implementation could get implemented.

  10. cartermp commented on Feb 4, 2017

    @cartermp
    Contributor

    All of this would be preceded by proper support for configurability, though.

  11. Krzysztof-Cieslak commented on Feb 4, 2017

    @Krzysztof-Cieslak
    Contributor

    I've fixed some performance issue we had in FSAC with finding locations of CodeLenses but it doesn't remove "jumpy effect" completely (and it wouldn't be problem here since smarter people than me would implement it anyway :) )

    I believe the core problem with "jumpy effect" right now is the fact that:

    1. FCS' parseResults.GetNavigationItems().Declarations seems to return empty list if the file is in not-parseable state (what makes sense)
    2. I don't have control over how often VSCode ask for CodeLenses location [what may or may not be issue in VS, depending on how API looks like]

    I'm pretty sure "jumpy effect" can be eliminated by providing stale results (either with empty CodeLens [it would at least keep position, so editor won't remove those additional lines] or with also stale signatures)

  12. realvictorprm commented on Apr 23, 2017

    @realvictorprm
    Contributor

    I would like to give it a try. I talked with @cloudRoutine about some implementation details which need to be tested. If something works I'll report it here.

  13. 28 remaining items

  14. realvictorprm commented on Apr 26, 2017

    @realvictorprm
    Contributor

    Just for showing other people the progress here too:
    Showcase

    Okay, I'll look into it @vasily-kirichenko There's still some small bugs left in the code lens, e.g. members of types where the signature should be int but is unit -> int (which logically is correctly but we don't apply unit. I guess it's done internal)

  15. vasily-kirichenko commented on Apr 26, 2017

    @vasily-kirichenko
    Contributor

    @realvictorprm Pull my PR please.

  16. realvictorprm commented on Sep 19, 2017

    @realvictorprm
    Contributor

    I consider to change my current PR to add only "sideways" Code-Lens similar to those recently added to Ionide. I think those could work without big problems.

  17. modified the milestones: , on Jun 9, 2018
  18. modified the milestones: , 15.8 on Jun 29, 2018
  19. cartermp commented on Jun 29, 2018

    @cartermp
    Contributor

    This is now implemented, though experimental. Closing for posterity.

  20. erlis commented on Aug 9, 2018

    @erlis

    Is there a way I can test this, even its experimental phase?

  21. cartermp commented on Aug 9, 2018

    @cartermp
    Contributor

    @erlis If you use VS 15.8 Preview, you can turn it on via Settings > Text Editor > F#.

  22. toburger commented on Aug 23, 2018

    @toburger

    Is there a way to disable the F# Language Service logging for this feature? I normally have the output window open (and the option "Show Output window when build starts" set) and it distracts quite a bit when working in the text editor and the logging kicks in.

    Apart from that I like this feature! First it was a bit awkward to have the code lens on the right of the definition and changed it to be on top, but the editor window was jumping around while editing the source code and I changed it back to be on the right.

  23. cartermp commented on Aug 23, 2018

    @cartermp
    Contributor

    @toburger This is done in #5145 and tracked by #5188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions