@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2024 Broadcom, Inc.
|
||||
* Copyright (c) 2024, 2025 Broadcom, 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
|
||||
@@ -12,6 +12,8 @@ package org.springframework.ide.vscode.boot.app;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.commands.SpringIndexCommands;
|
||||
import org.springframework.ide.vscode.boot.java.commands.WorkspaceBootExecutableProjects;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
@@ -22,5 +24,10 @@ public class CommandsConfig {
|
||||
@Bean WorkspaceBootExecutableProjects workspaceBootProjects(SimpleLanguageServer server, JavaProjectFinder projectFinder, SpringSymbolIndex symbolIndex) {
|
||||
return new WorkspaceBootExecutableProjects(server, projectFinder, symbolIndex);
|
||||
}
|
||||
|
||||
@Bean SpringIndexCommands springIndexCommands(SimpleLanguageServer server, JavaProjectFinder projectFinder, SpringMetamodelIndex symbolIndex) {
|
||||
return new SpringIndexCommands(server, symbolIndex, projectFinder);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.springframework.ide.vscode.boot.java.commands;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.java.IJavaProject;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
public class SpringIndexCommands {
|
||||
|
||||
private static final String PROJECT_BEANS_CMD = "sts/spring-boot/beans";
|
||||
|
||||
public SpringIndexCommands(SimpleLanguageServer server, SpringMetamodelIndex metamodelIndex, JavaProjectFinder projectFinder) {
|
||||
server.onCommand(PROJECT_BEANS_CMD, params -> {
|
||||
String projectUri = ((JsonElement) params.getArguments().get(0)).getAsString();
|
||||
IJavaProject project = projectFinder.find(new TextDocumentIdentifier(projectUri)).orElse(null);
|
||||
return project == null ? CompletableFuture.completedFuture(List.of())
|
||||
: server.getAsync().execute(() -> metamodelIndex.getBeansOfProject(project.getElementName()));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user