vscode-java
vscode-java copied to clipboard
Imports are not included in the document symbols returned from "getDocumentSymbols" API
Hi
I am writing a vscode extension and I want to get the symbols of a JAVA file.
Environment Operating System: windows 10 Visual Studio Code version: 1.50.0
Steps To Reproduce If I run this sample code :
`const vscodeCDSExtension = extensions.getExtension("redhat.java"); const javaDocParams : DocumentSymbolParams = { textDocument: { uri: Uri.file(filePath).toString() } };
if (vscodeCDSExtension && vscodeCDSExtension.isActive) { const symbols = await vscodeCDSExtension.exports.getDocumentSymbols(javaDocParams); console.log(symbols.length); }`
Current Result The "imports" of the file are not included in the returned symbols (only "package", classes and methods are returned)
Expected Result The "imports" also should be included in the result
The JAVA file is attached
If you look documentSymbol request at the LSP protocol, usually what it asks is the members such as fields, classes, methods. Could you please explain a bit more about your user scenario why "imports" is needed?
@testforstephen I am writing a vscode extension that gives the user an option to generate some methods (according to his selections) and then to add the generated code to a JAVA file. Sometimes those new generated methods require new imports in the JAVA file. So i need to know which imports already exist in the file in order to add the missing ones
You can GoToDefinition on an import's Class part. So you should be able to get that symbol location in this api call.