Is there an equivalent library for VSCODE plugin like PSI library for Intellij? #2665
Replies: 1 comment 2 replies
-
Hi @akashsivaram , No, there is no equivalent to IntelliJ PSI in VS Code. If you need syntactic or semantic info about a source code, you must develop it in your extension, or rely on others extension providing such info for yours. But, depending on your needs, you may use VS Commands to provide you structured info about the source code, abstracting the programming language. For instance, you may use Something like this would provide you all symbols in a file const docSymbols = await commands.executeCommand(
'vscode.executeDocumentSymbolProvider',
window.activeTextEditor.document.uri
) as DocumentSymbol[] I use this on my Separators extension. Feel free to look at its source code to better understand how it works. Hope this helps |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We are currently developing a VSCODE Plugin to add Open API 3/ Swagger Annotations for Springboot Rest Controllers and associated model classes. We already implemented this for IntelliJ using PSI which was quite seamless, but we are struggling to find a effective way to parse Java Code in VS Code. I have explored various approaches including LSP and different parsers, but most solutions are based on Regex patterns to match Java identifiers and then finding the line number and column position and then inserting the required Annotation at the specific position. What I need is a robust way to do the following,
Parse Java files to identify methods and parameters
Add Open API 3 / Swagger annotations to the code
Support regenerating annotations multiple times without duplication
As mentioned above I was able to do the above seamlessly in IntelliJ without having to worry about which line number or column position my method or parameter is present, this was all abstracted away by the IntelliJ's PSI library. Looking for a similar option in VSCODE, is there something available for VSCODE already that I can make use of?
Beta Was this translation helpful? Give feedback.
All reactions