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

Navtree - report function properties so that they can be identified as functions #25062

Closed
mjbvz opened this issue Jun 18, 2018 · 5 comments
Closed
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jun 18, 2018

microsoft/vscode#51988

TypeScript Version: 3.0.0-dev.20180616

Search Terms:

  • navtree
  • method, function, property

Code
For the code:

class K {
    p = 1
    f = () => {}
    m() {}
}

Run a navtree request

Expected behavior:
Some way to identify that f is a function

Actual behavior:
Both p and f are reported the same way, as properties.

Result: {
    "text": "<global>",
    "kind": "script",
    "kindModifiers": "",
    "spans": [
        {
            "start": {
                "line": 1,
                "offset": 1
            },
            "end": {
                "line": 5,
                "offset": 3
            }
        }
    ],
    "childItems": [
        {
            "text": "K",
            "kind": "class",
            "kindModifiers": "",
            "spans": [
                {
                    "start": {
                        "line": 1,
                        "offset": 1
                    },
                    "end": {
                        "line": 5,
                        "offset": 2
                    }
                }
            ],
            "nameSpan": {
                "start": {
                    "line": 1,
                    "offset": 7
                },
                "end": {
                    "line": 1,
                    "offset": 8
                }
            },
            "childItems": [
                {
                    "text": "f",
                    "kind": "property",
                    "kindModifiers": "",
                    "spans": [
                        {
                            "start": {
                                "line": 3,
                                "offset": 5
                            },
                            "end": {
                                "line": 3,
                                "offset": 17
                            }
                        }
                    ],
                    "nameSpan": {
                        "start": {
                            "line": 3,
                            "offset": 5
                        },
                        "end": {
                            "line": 3,
                            "offset": 6
                        }
                    }
                },
                {
                    "text": "m",
                    "kind": "method",
                    "kindModifiers": "",
                    "spans": [
                        {
                            "start": {
                                "line": 4,
                                "offset": 5
                            },
                            "end": {
                                "line": 4,
                                "offset": 11
                            }
                        }
                    ],
                    "nameSpan": {
                        "start": {
                            "line": 4,
                            "offset": 5
                        },
                        "end": {
                            "line": 4,
                            "offset": 6
                        }
                    }
                },
                {
                    "text": "p",
                    "kind": "property",
                    "kindModifiers": "",
                    "spans": [
                        {
                            "start": {
                                "line": 2,
                                "offset": 5
                            },
                            "end": {
                                "line": 2,
                                "offset": 10
                            }
                        }
                    ],
                    "nameSpan": {
                        "start": {
                            "line": 2,
                            "offset": 5
                        },
                        "end": {
                            "line": 2,
                            "offset": 6
                        }
                    }
                }
            ]
        }
    ]
}

Related Issues:

@mhegazy
Copy link
Contributor

mhegazy commented Jun 19, 2018

@andy-ms we did try this in the past. i can not remember what were the issues we ran into.. do you recall?

@ghost
Copy link

ghost commented Jun 19, 2018

I don't remember trying this before. One caveat navTree doesn't use the type checker so we would have to specifically be looking for an arrow function node, rather than supporting any callable type. But if you prefer it, we could report f as a method instead of a property, or add a new ScriptElementKindModifier.callable.

@mhegazy
Copy link
Contributor

mhegazy commented Jun 19, 2018

i think that was the issue... sometimes we would report it as a functions and sometimes we would not..

@mhegazy
Copy link
Contributor

mhegazy commented Jun 19, 2018

I think we are better off keeping it consistent.

@mhegazy mhegazy added Working as Intended The behavior described is the intended behavior; this is not a bug and removed VS Code Tracked There is a VS Code equivalent to this issue labels Jun 19, 2018
@mjbvz
Copy link
Contributor Author

mjbvz commented Jun 19, 2018

Sounds good. We can always revisit this if we start hearing about this more often

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants