I want my extension to be able to read the Java AST of a .java file to further save the Node name (for instance, "ClassDeclaration") of a selected piece of code. For example if you select "public", the AST tells you it is a "modifier", and then I want to save the Node name "modifier" as a String in a variable.
First I need the Java AST.
I first looked at the VSCode marketplace, but there is no AST extension available for Java (but you find some for other languages like TypeScript). What I got as a result though was the Java Extension Pack that contains many helpful Java extensions, but none of them is explicitly about the AST. Since there is a debugger and the Language Support from Red Hat, I'm pretty sure that they use the AST to make their extension work, so I looked at their source trying to find this without success. The only thing I'm aware is that they reference to the Eclipse JDT "packages", but I don't understand how. The answer might be right there, but the code is complex to me.
Another approach I tried was taking the source code from a TypeScript AST (git link: https://github.com/krizzdewizz/vscode-typescript-ast-explorer) and try to write my own Java AST Extension (in TypeScript of course), but I quickly realized that he uses TypeScript specific node_modules. I went to look for one for Java and came up with this npm package: https://www.npmjs.com/package/java-ast. I'm not sure if this is useful or not, but I don't know how to use it either (yes, there is an example and I tried, but I'm very new to this as you can tell).
If someone could help me further I would appreciate a lot.