created lsp client and server extension for spring model access
This commit is contained in:
@@ -621,4 +621,8 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
|
||||
public void liveProcessMemoryMetricsDataUpdated(LiveProcessSummary arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modelUpdated() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ import org.eclipse.lsp4j.Registration;
|
||||
import org.eclipse.lsp4j.RegistrationParams;
|
||||
import org.eclipse.lsp4j.ServerCapabilities;
|
||||
import org.eclipse.lsp4j.SetTraceParams;
|
||||
import org.eclipse.lsp4j.ShowDocumentParams;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextDocumentSyncKind;
|
||||
import org.eclipse.lsp4j.WorkDoneProgressBegin;
|
||||
@@ -98,6 +97,8 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.IProblemC
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.IReconcileEngine;
|
||||
import org.springframework.ide.vscode.commons.languageserver.reconcile.ReconcileProblem;
|
||||
import org.springframework.ide.vscode.commons.protocol.STS4LanguageClient;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.SpringModelLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.SpringModelService;
|
||||
import org.springframework.ide.vscode.commons.util.Assert;
|
||||
import org.springframework.ide.vscode.commons.util.AsyncRunner;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
@@ -105,7 +106,6 @@ import org.springframework.ide.vscode.commons.util.CollectionUtil;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -121,7 +121,7 @@ import reactor.core.scheduler.Schedulers;
|
||||
* with apis to register various callbacks so that language server implementor
|
||||
* can attach their own 'handlers' for whatever the functionality they want to implement.
|
||||
*/
|
||||
public final class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientAware, ServiceNotificationsClient, SimpleLanguageServerWrapper {
|
||||
public final class SimpleLanguageServer implements Sts4LanguageServer, SpringModelLanguageServer, LanguageClientAware, ServiceNotificationsClient, SimpleLanguageServerWrapper {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(SimpleLanguageServer.class);
|
||||
|
||||
@@ -923,4 +923,9 @@ public final class SimpleLanguageServer implements Sts4LanguageServer, LanguageC
|
||||
return parentProcessId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpringModelService getSpringModelService() {
|
||||
return (SpringModelService) appContext.getBean(SpringModelService.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019, 2022 Pivotal, Inc.
|
||||
* Copyright (c) 2019, 2023 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
|
||||
@@ -28,14 +28,14 @@ import org.springframework.ide.vscode.commons.protocol.java.JavaSearchParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.JavaTypeHierarchyParams;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.TypeData;
|
||||
import org.springframework.ide.vscode.commons.protocol.java.TypeDescriptorData;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.SpringModelLanguageClient;
|
||||
|
||||
/**
|
||||
* Some 'custom' extensions to standard LSP {@link LanguageClient}.
|
||||
*
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public interface STS4LanguageClient extends LanguageClient {
|
||||
|
||||
public interface STS4LanguageClient extends LanguageClient, SpringModelLanguageClient {
|
||||
|
||||
@JsonNotification("sts/liveprocess/connected")
|
||||
void liveProcessConnected(LiveProcessSummary processKey);
|
||||
@@ -92,6 +92,5 @@ public interface STS4LanguageClient extends LanguageClient {
|
||||
|
||||
@JsonRequest("sts/javaCodeComplete")
|
||||
CompletableFuture<List<JavaCodeCompleteData>> javaCodeComplete(JavaCodeCompleteParams params);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Contributors:
|
||||
* VMware, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.index;
|
||||
package org.springframework.ide.vscode.commons.protocol.spring;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -8,7 +8,7 @@
|
||||
* Contributors:
|
||||
* VMware, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.index;
|
||||
package org.springframework.ide.vscode.commons.protocol.spring;
|
||||
|
||||
import org.eclipse.lsp4j.Location;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 VMware, 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* VMware, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.protocol.spring;
|
||||
|
||||
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification;
|
||||
import org.eclipse.lsp4j.services.LanguageClient;
|
||||
|
||||
public interface SpringModelLanguageClient extends LanguageClient {
|
||||
|
||||
@JsonNotification("spring/model/updated")
|
||||
void modelUpdated();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 VMware, 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* VMware, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.protocol.spring;
|
||||
|
||||
import org.eclipse.lsp4j.jsonrpc.services.JsonDelegate;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
|
||||
public interface SpringModelLanguageServer extends LanguageServer {
|
||||
|
||||
/**
|
||||
* Provides access to the spring model services.
|
||||
*/
|
||||
@JsonDelegate
|
||||
SpringModelService getSpringModelService();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2023 VMware, 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
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* VMware, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.protocol.spring;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest;
|
||||
|
||||
public interface SpringModelService {
|
||||
|
||||
@JsonRequest
|
||||
default CompletableFuture<List<Bean>> beans(String project) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -281,19 +281,15 @@ public class LanguageServerHarness {
|
||||
((LanguageClientAware) getServer()).connect(new STS4LanguageClient() {
|
||||
@Override
|
||||
public void telemetryEvent(Object object) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<MessageActionItem> showMessageRequest(ShowMessageRequestParams requestParams) {
|
||||
// TODO Auto-generated method stub
|
||||
return CompletableFuture.completedFuture(new MessageActionItem("Some Message Request Answer"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(MessageParams messageParams) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -308,8 +304,6 @@ public class LanguageServerHarness {
|
||||
|
||||
@Override
|
||||
public void logMessage(MessageParams message) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -423,6 +417,10 @@ public class LanguageServerHarness {
|
||||
public void liveProcessGcPausesMetricsDataUpdated(LiveProcessSummary processKey) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modelUpdated() {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -12,17 +12,26 @@ package org.springframework.ide.vscode.boot.index;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.InjectionPoint;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.SpringModelService;
|
||||
|
||||
public class SpringMetamodelIndex {
|
||||
public class SpringMetamodelIndex implements SpringModelService {
|
||||
|
||||
private List<Bean> beans;
|
||||
|
||||
public SpringMetamodelIndex() {
|
||||
this.beans = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<List<Bean>> beans(String project) {
|
||||
return CompletableFuture.completedFuture(beans);
|
||||
}
|
||||
|
||||
public Bean[] getBeans(String name) {
|
||||
return this.beans.stream().filter(bean -> bean.getName().equals(name)).collect(Collectors.toList()).toArray(new Bean[0]);
|
||||
|
||||
@@ -114,9 +114,7 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
|
||||
private SpringProcessTracker liveProcessTracker;
|
||||
|
||||
public BootJavaLanguageServerComponents(
|
||||
ApplicationContext appContext
|
||||
) {
|
||||
public BootJavaLanguageServerComponents(ApplicationContext appContext) {
|
||||
this.server = appContext.getBean(SimpleLanguageServer.class);
|
||||
this.serverParams = appContext.getBean(BootLanguageServerParams.class);
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.index.InjectionPoint;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.AbstractSymbolProvider;
|
||||
@@ -41,6 +40,7 @@ import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
|
||||
import org.springframework.ide.vscode.boot.java.utils.FunctionUtils;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaContext;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.InjectionPoint;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.index.InjectionPoint;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.AbstractSymbolProvider;
|
||||
@@ -33,6 +32,7 @@ import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaContext;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.InjectionPoint;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.eclipse.lsp4j.WorkspaceSymbol;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.index.InjectionPoint;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeanUtils;
|
||||
import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformation;
|
||||
@@ -31,6 +30,7 @@ import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
|
||||
import org.springframework.ide.vscode.boot.java.utils.ASTUtils;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CachedSymbol;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SpringIndexerJavaContext;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.InjectionPoint;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
|
||||
@@ -44,10 +44,10 @@ import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.boot.index.InjectionPoint;
|
||||
import org.springframework.ide.vscode.boot.java.Annotations;
|
||||
import org.springframework.ide.vscode.boot.java.jdt.imports.ImportRewrite;
|
||||
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.InjectionPoint;
|
||||
import org.springframework.ide.vscode.commons.util.BadLocationException;
|
||||
import org.springframework.ide.vscode.commons.util.CollectorUtil;
|
||||
import org.springframework.ide.vscode.commons.util.text.DocumentRegion;
|
||||
|
||||
@@ -31,10 +31,10 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest;
|
||||
import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
|
||||
import org.springframework.ide.vscode.boot.index.Bean;
|
||||
import org.springframework.ide.vscode.boot.index.InjectionPoint;
|
||||
import org.springframework.ide.vscode.boot.index.SpringMetamodelIndex;
|
||||
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.Bean;
|
||||
import org.springframework.ide.vscode.commons.protocol.spring.InjectionPoint;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
|
||||
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
@@ -49,12 +49,15 @@ public class SpringMetamodelIndexerBeansTest {
|
||||
|
||||
@Autowired
|
||||
private BootLanguageServerHarness harness;
|
||||
|
||||
@Autowired
|
||||
private JavaProjectFinder projectFinder;
|
||||
|
||||
private File directory;
|
||||
|
||||
@Autowired
|
||||
private SpringMetamodelIndex springIndex;
|
||||
|
||||
@Autowired
|
||||
private SpringSymbolIndex indexer;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user