Do not attempt to look for symbols in non-interesting language files

This commit is contained in:
BoykoAlex
2022-02-22 18:48:40 -05:00
parent 68fc3a0d6f
commit 3f6e23ae5a
3 changed files with 18 additions and 5 deletions

View File

@@ -548,7 +548,7 @@ public class SpringSymbolIndex implements InitializingBean {
try {
URI uri = URI.create(docURI);
CompletableFuture<Void> projectInitialized = futureProjectFinder.findFuture(uri).thenCompose(project -> projectInitializedFuture(project));
projectInitialized.get(60, TimeUnit.SECONDS);
projectInitialized.get(15, TimeUnit.SECONDS);
List<EnhancedSymbolInformation> docSymbols = this.symbolsByDoc.get(docURI);
if (docSymbols != null) {
synchronized (docSymbols) {

View File

@@ -177,7 +177,7 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
//
documents.onDocumentSymbol(new BootJavaDocumentSymbolHandler(indexer));
documents.onDocumentSymbol(new BootJavaDocumentSymbolHandler(this, indexer));
workspaceService.onWorkspaceSymbol(new BootJavaWorkspaceSymbolHandler(indexer,
new LiveAppURLSymbolProvider(liveDataProvider)));

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* Copyright (c) 2017, 2022 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,12 +10,16 @@
*******************************************************************************/
package org.springframework.ide.vscode.boot.java.handlers;
import java.util.Collections;
import java.util.List;
import org.eclipse.lsp4j.DocumentSymbolParams;
import org.eclipse.lsp4j.SymbolInformation;
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
import org.springframework.ide.vscode.commons.languageserver.util.DocumentSymbolHandler;
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
import org.springframework.ide.vscode.commons.util.text.TextDocument;
/**
* @author Martin Lippert
@@ -23,14 +27,23 @@ import org.springframework.ide.vscode.commons.languageserver.util.DocumentSymbol
public class BootJavaDocumentSymbolHandler implements DocumentSymbolHandler {
private SpringSymbolIndex indexer;
private BootJavaLanguageServerComponents server;
public BootJavaDocumentSymbolHandler(SpringSymbolIndex indexer) {
public BootJavaDocumentSymbolHandler(BootJavaLanguageServerComponents server, SpringSymbolIndex indexer) {
this.server = server;
this.indexer = indexer;
}
@Override
public List<? extends SymbolInformation> handle(DocumentSymbolParams params) {
return indexer.getSymbols(params.getTextDocument().getUri());
SimpleTextDocumentService documents = server.getTextDocumentService();
TextDocument doc = documents.getLatestSnapshot(params.getTextDocument().getUri());
if (server.getInterestingLanguages().contains(doc.getLanguageId())) {
return indexer.getSymbols(params.getTextDocument().getUri());
}
return Collections.emptyList();
}
}