Turn RunningAppProvider into a bean
This commit is contained in:
@@ -154,7 +154,7 @@ public class LanguageServerHarness {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public static final Duration HIGHLIGHTS_TIMEOUT = Duration.ofMillis(15000000000L); //Why so long?
|
||||
public static final Duration HIGHLIGHTS_TIMEOUT = Duration.ofMillis(10_000L); //Why so long?
|
||||
|
||||
// public static LanguageServerHarness<SimpleLanguageServer> create(String extensionId, LanguageServerInitializer initializer) throws Exception {
|
||||
// Callable<SimpleLanguageServer> factory = () -> {
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClas
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory;
|
||||
import org.springframework.ide.vscode.boot.common.RelaxedNameConfig;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.DefaultJavaElementLocationProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.EclipseJavaDocumentUriProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider;
|
||||
@@ -76,6 +77,12 @@ public class BootLanguagServerBootApp {
|
||||
}
|
||||
}
|
||||
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
@Bean
|
||||
RunningAppProvider runningAppProvider(SimpleLanguageServer server) {
|
||||
return RunningAppProvider.createDefault(server);
|
||||
}
|
||||
|
||||
@ConditionalOnMissingClass("org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness")
|
||||
@Bean AdHocSpringPropertyIndexProvider adHocProperties(BootLanguageServerParams params, FileObserver fileObserver, DocumentEventListenerManager documentEvents) {
|
||||
return new AdHocSpringPropertyIndexProvider(params.projectFinder, params.projectObserver, fileObserver, documentEvents);
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaElementLocationProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.CompilationUnitCache;
|
||||
@@ -50,6 +51,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
@Autowired SymbolCache symbolCache;
|
||||
@Autowired BootJavaConfig config;
|
||||
@Autowired SpringSymbolIndex springIndexer;
|
||||
@Autowired RunningAppProvider runningAppProvider;
|
||||
|
||||
@Qualifier("adHocProperties") @Autowired ProjectBasedPropertyIndexProvider adHocProperties;
|
||||
|
||||
@@ -75,7 +77,7 @@ public class BootLanguageServerInitializer implements InitializingBean {
|
||||
// some server intialization code. Migrate that code and get rid of the ComposableLanguageServer class
|
||||
CompositeLanguageServerComponents.Builder builder = new CompositeLanguageServerComponents.Builder();
|
||||
builder.add(new BootPropertiesLanguageServerComponents(server, params, javaElementLocationProvider, parser, yamlStructureProvider, yamlAssistContextProvider, sourceLinks));
|
||||
builder.add(new BootJavaLanguageServerComponents(server, params, sourceLinks, cuCache, adHocProperties, symbolCache, config, springIndexer));
|
||||
builder.add(new BootJavaLanguageServerComponents(server, params, sourceLinks, cuCache, adHocProperties, symbolCache, config, springIndexer, runningAppProvider));
|
||||
components = builder.build(server);
|
||||
params.projectObserver.addListener(reconcileOpenDocuments(server, components));
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class BootLanguageServerParams {
|
||||
public final TypeUtilProvider typeUtilProvider;
|
||||
|
||||
//Boot Java
|
||||
public final RunningAppProvider runningAppProvider;
|
||||
//public final RunningAppProvider runningAppProvider;
|
||||
public final Duration watchDogInterval;
|
||||
|
||||
public BootLanguageServerParams(
|
||||
@@ -84,7 +84,6 @@ public class BootLanguageServerParams {
|
||||
ProjectObserver projectObserver,
|
||||
SpringPropertyIndexProvider indexProvider,
|
||||
TypeUtilProvider typeUtilProvider,
|
||||
RunningAppProvider runningAppProvider,
|
||||
Duration watchDogInterval
|
||||
) {
|
||||
super();
|
||||
@@ -93,7 +92,6 @@ public class BootLanguageServerParams {
|
||||
this.projectObserver = projectObserver;
|
||||
this.indexProvider = indexProvider;
|
||||
this.typeUtilProvider = typeUtilProvider;
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
this.watchDogInterval = watchDogInterval;
|
||||
}
|
||||
|
||||
@@ -114,7 +112,6 @@ public class BootLanguageServerParams {
|
||||
jdtProjectCache,
|
||||
indexProvider,
|
||||
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, jdtProjectCache.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
RunningAppProvider.createDefault(server),
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
);
|
||||
}
|
||||
@@ -182,7 +179,6 @@ public class BootLanguageServerParams {
|
||||
projectObserver,
|
||||
indexProvider,
|
||||
(SourceLinks sourceLinks, IDocument doc) -> new TypeUtil(sourceLinks, javaProjectFinder.find(new TextDocumentIdentifier(doc.getUri()))),
|
||||
RunningAppProvider.NULL,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,6 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
|
||||
private final SimpleLanguageServer server;
|
||||
private final BootLanguageServerParams serverParams;
|
||||
// private final SpringSymbolIndex indexer;
|
||||
private final SpringPropertyIndexProvider propertyIndexProvider;
|
||||
private final ProjectBasedPropertyIndexProvider adHocPropertyIndexProvider;
|
||||
private final SpringLiveHoverWatchdog liveHoverWatchdog;
|
||||
@@ -119,7 +118,8 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
ProjectBasedPropertyIndexProvider adHocIndexProvider,
|
||||
SymbolCache symbolCache,
|
||||
BootJavaConfig config,
|
||||
SpringSymbolIndex indexer
|
||||
SpringSymbolIndex indexer,
|
||||
RunningAppProvider runningAppProvider
|
||||
) {
|
||||
this.server = server;
|
||||
this.serverParams = serverParams;
|
||||
@@ -140,14 +140,14 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
|
||||
documents.onDocumentSymbol(new BootJavaDocumentSymbolHandler(indexer));
|
||||
workspaceService.onWorkspaceSymbol(new BootJavaWorkspaceSymbolHandler(indexer,
|
||||
new LiveAppURLSymbolProvider(serverParams.runningAppProvider)));
|
||||
new LiveAppURLSymbolProvider(runningAppProvider)));
|
||||
|
||||
// BootJavaCodeLensEngine codeLensHandler = createCodeLensEngine(server, projectFinder);
|
||||
// documents.onCodeLens(codeLensHandler::createCodeLenses);
|
||||
// documents.onCodeLensResolve(codeLensHandler::resolveCodeLens);
|
||||
|
||||
hoverProvider = createHoverHandler(projectFinder, serverParams.runningAppProvider, sourceLinks);
|
||||
liveHoverWatchdog = new SpringLiveHoverWatchdog(server, hoverProvider, serverParams.runningAppProvider,
|
||||
hoverProvider = createHoverHandler(projectFinder, runningAppProvider, sourceLinks);
|
||||
liveHoverWatchdog = new SpringLiveHoverWatchdog(server, hoverProvider, runningAppProvider,
|
||||
projectFinder, projectObserver, serverParams.watchDogInterval);
|
||||
documents.onDidChangeContent(params -> {
|
||||
TextDocument doc = params.getDocument();
|
||||
@@ -178,7 +178,7 @@ public class BootJavaLanguageServerComponents implements LanguageServerComponent
|
||||
this,
|
||||
server,
|
||||
serverParams.projectObserver,
|
||||
serverParams.runningAppProvider,
|
||||
runningAppProvider,
|
||||
projectFinder,
|
||||
serverParams.watchDogInterval,
|
||||
sourceLinks);
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
|
||||
@@ -44,6 +45,10 @@ public class HoverTestConf {
|
||||
return new MockRunningAppProvider();
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider(MockRunningAppProvider mockApps) {
|
||||
return mockApps.provider;
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerHarness harness(SimpleLanguageServer server, BootLanguageServerParams serverParams, PropertyIndexHarness indexHarness, JavaProjectFinder projectFinder) throws Exception {
|
||||
return new BootLanguageServerHarness(server, serverParams, indexHarness, projectFinder, LanguageId.JAVA, ".java");
|
||||
}
|
||||
@@ -59,7 +64,6 @@ public class HoverTestConf {
|
||||
testDefaults.projectObserver,
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
mockAppsHarness().provider,
|
||||
watchDogInterval()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.JavaDocumentUriProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
@@ -52,6 +53,10 @@ public class PropertyEditorTestConf {
|
||||
return new MockRunningAppProvider();
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider(MockRunningAppProvider mockApps) {
|
||||
return mockApps.provider;
|
||||
}
|
||||
|
||||
@Bean BootLanguageServerHarness harness(
|
||||
SimpleLanguageServer server,
|
||||
BootLanguageServerParams serverParams,
|
||||
@@ -72,7 +77,6 @@ public class PropertyEditorTestConf {
|
||||
ProjectObserver.NULL,
|
||||
indexHarness.getIndexProvider(),
|
||||
typeUtilProvider,
|
||||
mockAppsHarness().provider,
|
||||
SpringLiveHoverWatchdog.DEFAULT_INTERVAL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.springframework.ide.vscode.boot.app.BootLanguageServerParams;
|
||||
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
|
||||
import org.springframework.ide.vscode.boot.editor.harness.PropertyIndexHarness;
|
||||
import org.springframework.ide.vscode.boot.java.BootJavaLanguageServerComponents;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory;
|
||||
import org.springframework.ide.vscode.boot.java.links.SourceLinks;
|
||||
import org.springframework.ide.vscode.boot.java.utils.SymbolCache;
|
||||
@@ -60,4 +61,8 @@ public class SymbolProviderTestConf {
|
||||
@Bean SourceLinks sourceLinks() {
|
||||
return SourceLinkFactory.NO_SOURCE_LINKS;
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider() {
|
||||
return RunningAppProvider.NULL;
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -92,6 +93,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -129,6 +131,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -166,6 +169,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -203,6 +207,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -239,6 +244,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -275,6 +281,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -312,6 +319,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -349,6 +357,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -386,6 +395,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -425,6 +435,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
@@ -460,6 +471,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("1111")
|
||||
.processId("22022")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.contextPath("/mockedpath")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
@@ -493,6 +505,7 @@ public class RequestMappingLiveHoverTestWithContextPath {
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.urlScheme("https")
|
||||
.contextPath("/mockedpath")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
|
||||
@@ -83,6 +83,10 @@ public class CompilationUnitCacheTest {
|
||||
return new PropertyIndexHarness(valueProviders);
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider() {
|
||||
return RunningAppProvider.NULL;
|
||||
}
|
||||
|
||||
@Bean JavaProjectFinder projectFinder(BootLanguageServerParams serverParams) {
|
||||
return serverParams.projectFinder;
|
||||
}
|
||||
@@ -102,7 +106,6 @@ public class CompilationUnitCacheTest {
|
||||
projectObserver,
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@ public class ValueCompletionTest {
|
||||
ProjectObserver.NULL,
|
||||
indexHarness.getIndexProvider(),
|
||||
testDefaults.typeUtilProvider,
|
||||
RunningAppProvider.NULL,
|
||||
null
|
||||
);
|
||||
}
|
||||
@@ -131,6 +130,9 @@ public class ValueCompletionTest {
|
||||
return SourceLinkFactory.NO_SOURCE_LINKS;
|
||||
}
|
||||
|
||||
@Bean RunningAppProvider runningAppProvider() {
|
||||
return RunningAppProvider.NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
@@ -15,13 +15,18 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.ContextPath;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.LiveConditional;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.LocalSpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.liveproperties.LiveProperties;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.liveproperties.LivePropertiesJsonParser;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMapping;
|
||||
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
|
||||
@@ -53,7 +58,7 @@ public class MockRunningAppProvider {
|
||||
Mockito.reset(provider);
|
||||
}
|
||||
|
||||
public MockAppBuilder builder() {
|
||||
public MockAppBuilder builder() throws Exception {
|
||||
return new MockAppBuilder(this);
|
||||
}
|
||||
|
||||
@@ -63,8 +68,9 @@ public class MockRunningAppProvider {
|
||||
private String processId;
|
||||
private String processName;
|
||||
|
||||
public MockAppBuilder(MockRunningAppProvider runningAppProvider) {
|
||||
public MockAppBuilder(MockRunningAppProvider runningAppProvider) throws Exception {
|
||||
this.runningAppProvider = runningAppProvider;
|
||||
when(app.getUrlScheme()).thenReturn("http");
|
||||
}
|
||||
|
||||
public MockAppBuilder beans(String beans) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user