langium icon indicating copy to clipboard operation
langium copied to clipboard

Use 'Go to type definition' to switch to the generated AST type declaration

Open Lotes opened this issue 2 years ago • 4 comments

When you are in the grammar and want to know how the type looks like in the ast.ts file, we could use Go to implementation of the LSP.

Especially when you need to know inferred types or maybe container information, this could be nice.

We can simply search for a line starting with export interface ABC or export type ABC in ast.ts.

Go to implementation seems to be the best match. But if there is a better action for this idea, choose the better one.

Lotes avatar Feb 07 '23 09:02 Lotes

@Lotes If one want to re-use one of LSP services, maybe Goto Type Definition would match your case better?

dhuebner avatar Feb 07 '23 09:02 dhuebner

True, I was not aware of this action.

Lotes avatar Feb 07 '23 09:02 Lotes

Rethinking about this... When doing "Go to type definition" on a grammar rule (definition or usage), I would expect the editor to navigate to either the rule definition if the type is inferred or the type declaration. But we could say something similar about "Go to implementation": If you do that on a type, one could expect the editor to navigate to a grammar rule that uses that type. So maybe a custom command is the better choice to avoid confusion.

spoenemann avatar Feb 09 '23 15:02 spoenemann

Shamelessly voting for this ... I spend an embarrassingly large amount of time jumping between usage, definition and then searching the ast.

snarkipus avatar Feb 13 '23 13:02 snarkipus