@@ -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()));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,8 +52,8 @@ export function activate(context: ExtensionContext): Thenable<ExtensionAPI> {
|
||||
],
|
||||
checkjvm: (context: ExtensionContext, jvm: commons.JVM) => {
|
||||
let version = jvm.getMajorVersion();
|
||||
if (version < 17) {
|
||||
throw Error(`Spring Tools Language Server requires Java 17 or higher to be launched. Current Java version is ${version}`);
|
||||
if (version < 21) {
|
||||
throw Error(`Spring Tools Language Server requires Java 21 or higher to be launched. Current Java version is ${version}`);
|
||||
}
|
||||
|
||||
if (!jvm.isJdk()) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Event } from "vscode";
|
||||
import { Event, Uri } from "vscode";
|
||||
import { LanguageClient } from "vscode-languageclient/node";
|
||||
import { LiveProcess } from "./notification";
|
||||
import {Location} from "vscode-languageclient";
|
||||
@@ -109,6 +109,7 @@ interface InjectionPoint {
|
||||
|
||||
interface SpringIndex {
|
||||
readonly beans: (params: BeansParams) => Promise<Bean[]>;
|
||||
readonly getBeans: (uri: Uri) => Promise<Bean[]>;
|
||||
readonly onSpringIndexUpdated: Event<void>;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ export class ApiManager {
|
||||
return await commands.executeCommand(COMMAND_LIVEDATA_REFRESH_METRICS, query);
|
||||
}
|
||||
|
||||
const COMMAND_BEANS = "sts/spring-boot/beans";
|
||||
const getBeans: (Uri) => Promise<Bean[]> = async (projectUri: Uri) => await commands.executeCommand(COMMAND_BEANS, projectUri.toString());
|
||||
|
||||
client.onNotification(LiveProcessConnectedNotification.type, (process: LiveProcess) => this.onDidLiveProcessConnectEmitter.fire(process));
|
||||
client.onNotification(LiveProcessDisconnectedNotification.type, (process: LiveProcess) => this.onDidLiveProcessDisconnectEmitter.fire(process));
|
||||
client.onNotification(LiveProcessUpdatedNotification.type, (process: LiveProcess) => this.onDidLiveProcessUpdateEmitter.fire(process));
|
||||
@@ -70,7 +73,8 @@ export class ApiManager {
|
||||
|
||||
const getSpringIndex = () => ({
|
||||
onSpringIndexUpdated,
|
||||
beans
|
||||
beans,
|
||||
getBeans
|
||||
})
|
||||
|
||||
this.api = {
|
||||
|
||||
Reference in New Issue
Block a user