I am creating a VS Code extension that supports a small proprietary language. One of the minimal requirements for it is to have a "Go To Definition" functionality for procedures only. Being very new to JavaScript/TypeScript i'm struggling with using VSCode's API to actually solve the problem.
I have a grasp on what is required to make a VS Code extension, i.e the purpose of package.json, activate function in extesnion.ts and a general understanding of TypeScript (coming from Python). I have tried to refer to some open-source code that implements a much more advanced version of my extension (vscode-go), but the code there is overwhelming to go through as a TS beginner.
Essentially my question boils down to: Is there a simple way (may be an abstract set of steps?) to implement a very basic "go-to function definition within the same file" behavior, without resorting to creating a custom language server?
To provide a Go To Definition
feature, just like other extensions, you just have to register and implement a DefinitionProvider
.
You don’t need a language server for that, nor any complex tooling. A simple lazy parser would work just fine :-).
I’ve made a Pascal (https://github.com/alefragnani/vscode-language-pascal) extension that provides some of these features, and don’t use a Language Server. I’m using global/ctags to parse and generate tags for the sources. Then I load and parse its output to identify the symbols.
You are free to take a look (https://github.com/alefragnani/vscode-language-pascal/blob/master/src/providers/definitionProvider.ts). The source code is open and fairly simple, as it was one of the first extensions that I have developed.
Hope this helps