ppisl commented on a change in pull request #3525:
URL: https://github.com/apache/netbeans/pull/3525#discussion_r806083325
##########
File path:
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java
##########
@@ -813,97 +814,61 @@ protected void process(CompilationInfo arg0, Document
arg1, SchedulerEvent arg2)
@Override
public CompletableFuture<List<Either<SymbolInformation, DocumentSymbol>>>
documentSymbol(DocumentSymbolParams params) {
return server.openedProjects().thenCompose(projects -> {
- JavaSource js = getJavaSource(params.getTextDocument().getUri());
- if (js == null) {
+ List<Either<SymbolInformation, DocumentSymbol>> result = new
ArrayList<>();
+
+ String uri = params.getTextDocument().getUri();
+ FileObject file = fromURI(uri);
+ Document doc = server.getOpenedDocuments().getDocument(uri);
+ if (file == null || !(doc instanceof LineDocument)) {
return
CompletableFuture.completedFuture(Collections.emptyList());
}
- List<Either<SymbolInformation, DocumentSymbol>> result = new
ArrayList<>();
- try {
- js.runUserActionTask(cc -> {
- cc.toPhase(JavaSource.Phase.RESOLVED);
- Trees trees = cc.getTrees();
- CompilationUnitTree cu = cc.getCompilationUnit();
- if (cu.getPackage() != null) {
- TreePath tp = trees.getPath(cu, cu.getPackage());
- Element el = trees.getElement(tp);
- if (el != null && el.getKind() == ElementKind.PACKAGE)
{
- String name = Utils.label(cc, el, true);
- SymbolKind kind =
Utils.elementKind2SymbolKind(el.getKind());
- Range range = Utils.treeRange(cc, tp.getLeaf());
- result.add(Either.forRight(new
DocumentSymbol(name, kind, range, range)));
- }
- }
- for (Element tel : cc.getTopLevelElements()) {
- DocumentSymbol ds = element2DocumentSymbol(cc, tel);
- if (ds != null)
+ StructureProvider structureProvider =
MimeLookup.getLookup(DocumentUtilities.getMimeType(doc)).lookup(StructureProvider.class);
+ if (structureProvider != null) {
+ return
structureProvider.getStructure(doc).thenApply(structureElements -> {
Review comment:
I have put it into the Background taks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists