I'm new to this subject, so there's a good chance I've gotten some keyterms wrong. I'd like to parse a typescript file into its component symbols. To give a very crude example of what I'd imagine coming out, see below:
// some ts file
export function yell(output: string) {
alert(output + "!!");
}
would create something like this:
{
symbols: [
{ type: "comment", text: "// some ts file" },
"\n",
{ type: "module", text: "export" },
" ",
{ type: "function", symbols: [
{ type: "name", text: "yell" },
... it goes on
]}
]
}
I'm pretty certain this symbolization/tokenization is part of the initialize phase of a language server, trying to glean from this issue (https://github.com/Microsoft/language-server-protocol/issues/33).
But I read through the docs on initialize (https://microsoft.github.io/language-server-protocol/specification#initialize) and I couldn't find (ctrl-f) anything about symbols or tokens being returned.
A while back I worked with Monaco, and I know that the point of language servers is largely to standardize the tokenization and linking/navigating of code, so I'm pretty sure this is the right tool for it. But the docs are pretty dense, and seem to be far more focused on code interactions than code parsing.
How can I parse TS to symbols using a Language Server Protocol?
EDIT: good to mention, in case this is a project unto itself: I'm not looking for the full code for this or anything. Just some sort of crude overview of what goes on, and maybe a few links/exerpts to relevant docs.
EDIT 2: I found a really similar question here (TypeScript: get syntax tree), but it makes no mention of Language Servers, and appears to have come from a time before them.
EDIT 3: It appears the proper term I was looking for is AST. Found a really cool tool online for TypeScript (https://ts-ast-viewer.com/)