Skip to content

LS API usability issues #2105

@clausreinke

Description

@clausreinke

It looks as if the LS API is written with a very limited set of use cases in mind (probably modeled after one of its clients;-). While that set of use cases is well supported, many desirable use cases beyond the target set are made unnecessarily difficult. In other words, the LS API is too tightly coupled to one set of use cases.

Examples:

  1. getQuickInfoAtPosition tries to compute symbol at position (used to be called fullSymbolName in earlier iterations, I think) and type of symbol at position, but exposes neither (unless one is willing to extract those pieces of information from displayParts)

    (I tried to get the information from the underlying program and typechecker, but kept ending up with symbols that lacked some flags that seemed needed for further processing; but, really, I think these are reasonable bits of info to ask for at the LS API level - perhaps I should be using other methods?)

  2. I often find myself wanting to explore the type of the thing under the cursor. When writing code, I can abuse completion for this, but when reading code, that feels unnatural.

    Now, I can jump to the definition of the thing under cursor, but that isn't what I want, and if the program relies on type inference, there may not be any explicit type info at the definition site, either.

    Next idea would be to infer the type the type by other means (which runs into 1 above) and then to jump to the definition site of that type - only that one cannot use the LS API to jump to the definition of anything that doesn't happen to be at the cursor position..

It seems the abstraction level is slightly wrong, and the LS is trying to do too much for the client: the LS should provide the info, the LS clients should process that info. Also, LS/client interactions are slightly too coarse-grained: some of the LS/client interactions could be more flexible by splitting them into smaller parts (such as A. finding the thing under the cursor and B. finding information about a given thing, where the thing might come from A or might be created in place).

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in codeSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions