Ionide-vscode-fsharp: CodeLens for non-function values

Created on 4 Oct 2016  路  16Comments  路  Source: ionide/ionide-vscode-fsharp

New codelens support (2.6) for functions is awesome. Having this also for non-function values would be great as well though. Perhaps having this optional via some setting would be needed though as it might not be for everyone.

enhancement language services up for grabs

Most helpful comment

OK, now it looks like this:

image

So we have class's internal let binding code lensed, too. Is it OK?

All 16 comments

There are some problems on FSAC / FCS side of things with it (current method of getting symbols in file used by CodeLens and Ctrl + Shfit + O doesn't return value bindings. ) which makes adding this more complex than expected. It's something I'd want, but not super high priority.

This also applies to vals that are functions.
screen shot 2016-10-04 at 22 35 00

Sweet feature. Issue also applies to pattern matching function

codelens

Worth noticing that if value is uppercase it will work.

afaik ServiceNavigation was never put into production so its a just one of its limitations. The good news is you can get all the info you want from the symbol api. If theres bugs in that then its my fault as I added it some of it. :-)

OK, I've added SynPat.Named to navigable items here https://github.com/vasily-kirichenko/FSharp.Compiler.Service/blob/add-module-values-to-navigable-items/src/fsharp/vs/ServiceNavigation.fs#L136-L137

Now for

module Test1

let foo x = x

let intVal = 1

let stringVal = "foo"

[<EntryPoint>]
let main argv =
    printfn "%A" argv
    0

declarations returns the following:

[
    {
        "Declaration": {
            "UniqueName": "Test1_1_of_1",
            "Name": "Test1",
            "Glyph": "Module",
            "GlyphChar": "N",
            "IsTopLevel": true,
            "Range": {
                "StartColumn": 1,
                "StartLine": 1,
                "EndColumn": 6,
                "EndLine": 12
            },
            "BodyRange": {
                "StartColumn": 13,
                "StartLine": 1,
                "EndColumn": 6,
                "EndLine": 12
            },
            "File": "e:\\github\\Test1\\Test1\\Test1.fs"
        },
        "Nested": [
            {
                "UniqueName": "Test1_1_of_1",
                "Name": "foo",
                "Glyph": "Field",
                "GlyphChar": "F",
                "IsTopLevel": false,
                "Range": {
                    "StartColumn": 5,
                    "StartLine": 3,
                    "EndColumn": 14,
                    "EndLine": 3
                },
                "BodyRange": {
                    "StartColumn": 5,
                    "StartLine": 3,
                    "EndColumn": 14,
                    "EndLine": 3
                },
                "File": "e:\\github\\Test1\\Test1\\Test1.fs"
            },
            {
                "UniqueName": "Test1_1_of_1",
                "Name": "intVal",
                "Glyph": "Field",
                "GlyphChar": "F",
                "IsTopLevel": false,
                "Range": {
                    "StartColumn": 5,
                    "StartLine": 5,
                    "EndColumn": 11,
                    "EndLine": 5
                },
                "BodyRange": {
                    "StartColumn": 5,
                    "StartLine": 5,
                    "EndColumn": 11,
                    "EndLine": 5
                },
                "File": "e:\\github\\Test1\\Test1\\Test1.fs"
            },
            {
                "UniqueName": "Test1_1_of_1",
                "Name": "main",
                "Glyph": "Field",
                "GlyphChar": "F",
                "IsTopLevel": false,
                "Range": {
                    "StartColumn": 5,
                    "StartLine": 10,
                    "EndColumn": 6,
                    "EndLine": 12
                },
                "BodyRange": {
                    "StartColumn": 5,
                    "StartLine": 10,
                    "EndColumn": 6,
                    "EndLine": 12
                },
                "File": "e:\\github\\Test1\\Test1\\Test1.fs"
            },
            {
                "UniqueName": "Test1_1_of_1",
                "Name": "stringVal",
                "Glyph": "Field",
                "GlyphChar": "F",
                "IsTopLevel": false,
                "Range": {
                    "StartColumn": 5,
                    "StartLine": 7,
                    "EndColumn": 14,
                    "EndLine": 7
                },
                "BodyRange": {
                    "StartColumn": 5,
                    "StartLine": 7,
                    "EndColumn": 14,
                    "EndLine": 7
                },
                "File": "e:\\github\\Test1\\Test1\\Test1.fs"
            }
        ]
    }
]

result:

image

I think there are no code lens because F nested declarations are filtered out here https://github.com/ionide/ionide-vscode-fsharp/blob/master/src/Components/CodeLens.fs#L25

I cannot run experimental Code instance, so I cannot fix / test the ionide part.

OK, now it looks like this:

image

So we have class's internal let binding code lensed, too. Is it OK?

Why not? At least I like it!

:) @sergey-tihon what do you think about not showing code lens on interface members as it duplicates signature 1:1?

Interesting idea... but i think that it probably should work on virtual methods...

type IPrintable =
   abstract Print : unit -> unit // do not show here
   default __.Print () = () // but show here

in this case you can visually check that they are equal.

Current status:

image

I've no idea why it does not show signatures for default method implementations.

aha, it seems to relate to tooltip parsing on Code side:

image

Released in 2.6.10

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cloudRoutine picture cloudRoutine  路  5Comments

MangelMaxime picture MangelMaxime  路  4Comments

MikaelUmaN picture MikaelUmaN  路  5Comments

isaacabraham picture isaacabraham  路  5Comments

sergey-tihon picture sergey-tihon  路  6Comments