From 2cbca3304bb1487222687ec80281b7af57eeef0c Mon Sep 17 00:00:00 2001 From: nsingh Date: Wed, 11 Jan 2017 15:51:25 -0800 Subject: [PATCH] Code cleanup for CF support in vscode --- .../cftarget/CFClientParamsFactory.java | 63 ----------------- .../client/cftarget/CFTargetsFactory.java | 25 +++---- .../client/cftarget/CfCliParamsProvider.java | 23 +++++-- .../client/cftarget/ClientParamsProvider.java | 21 ++++++ .../client/v2/DefaultClientRequestsV2.java | 2 +- .../cloudfoundry/client/CFClientTest.java | 18 +++-- .../vscode/commons/util/ExceptionUtil.java | 3 +- .../yaml/AbstractCFHintsProvider.java | 67 ++++++++++++------- .../ManifestYamlCFBuildpacksProvider.java | 40 +++-------- .../yaml/ManifestYamlCFServicesProvider.java | 44 ++++-------- .../yaml/ManifestYamlLanguageServer.java | 8 ++- 11 files changed, 137 insertions(+), 177 deletions(-) delete mode 100644 vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CFClientParamsFactory.java create mode 100644 vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/ClientParamsProvider.java diff --git a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CFClientParamsFactory.java b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CFClientParamsFactory.java deleted file mode 100644 index d4804cc27..000000000 --- a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CFClientParamsFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Provider; - -/** - * Resolves Cloud Foundry client parameters from params providers (for example, - * a provider would be a cf CLI config parser that parses params from the CLI - * config.json file) - * - */ -public class CFClientParamsFactory { - - public static final CFClientParamsFactory INSTANCE = new CFClientParamsFactory(); - - private List>> providers = new ArrayList<>(); - - private CFClientParamsFactory() { - // For now, only support cf CLI. - // Maybe in the future other ways of retrieving client params can be - // supported - // in addition to the cf CLI config. - addProvider(new CfCliParamsProvider()); - } - - /** - * Adds provider to the front of the registered providers such that it would - * be called first when a request is made for CF client params - * - * @param provider - */ - public void addProvider(Provider> provider) { - if (provider != null) { - providers.add(provider); - } - } - - public List getParams() { - - // Start from the last provider, which is the highest priority - for (int i = providers.size() - 1; i >= 0; i--) { - List params = providers.get(i).get(); - if (params != null && !params.isEmpty()) { - return params; - } - } - return null; - - } - -} diff --git a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CFTargetsFactory.java b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CFTargetsFactory.java index 4e67f4853..e88e50cf3 100644 --- a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CFTargetsFactory.java +++ b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CFTargetsFactory.java @@ -14,23 +14,22 @@ import java.util.ArrayList; import java.util.List; import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.ClientRequests; -import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.CloudFoundryClientFactory; -import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.DefaultCloudFoundryClientFactoryV2; import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.ClientTimeouts; +import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.CloudFoundryClientFactory; /** - * Creates targets given a client parameters factory and a client factory. + * Creates targets given a client parameters provider and a client factory. * */ public class CFTargetsFactory { private final CloudFoundryClientFactory clientFactory; - private final CFClientParamsFactory paramsFactory; + private final ClientParamsProvider paramsProvider; private final ClientTimeouts timeouts; - public CFTargetsFactory(CFClientParamsFactory paramsFactory, CloudFoundryClientFactory clientFactory, ClientTimeouts timeouts) { + public CFTargetsFactory(ClientParamsProvider paramsProvider, CloudFoundryClientFactory clientFactory, ClientTimeouts timeouts) { this.clientFactory = clientFactory; - this.paramsFactory = paramsFactory; + this.paramsProvider = paramsProvider; this.timeouts = timeouts; } @@ -40,7 +39,7 @@ public class CFTargetsFactory { * @throws Exception */ public List getTargets() throws Exception { - List allParams = paramsFactory.getParams(); + List allParams = paramsProvider.getParams(); List targets = new ArrayList<>(); if (allParams != null) { for (CFClientParams parameters : allParams) { @@ -52,6 +51,10 @@ public class CFTargetsFactory { } return targets; } + + public String noTargetsMessage() { + return paramsProvider.noParamsAvailableMessage(); + } protected String getTargetName(CFClientParams params) { return labelFromCfApi(params.getApiUrl()); @@ -66,12 +69,4 @@ public class CFTargetsFactory { return cfApiUrl; } } - - public static CFTargetsFactory createDefaultV2TargetsFactory(ClientTimeouts timeouts) { - CloudFoundryClientFactory clientFactory = DefaultCloudFoundryClientFactoryV2.INSTANCE; - CFClientParamsFactory paramsFactory = CFClientParamsFactory.INSTANCE; - - return new CFTargetsFactory(paramsFactory, clientFactory, timeouts); - } - } diff --git a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CfCliParamsProvider.java b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CfCliParamsProvider.java index c07af9bae..2d1770505 100644 --- a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CfCliParamsProvider.java +++ b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/CfCliParamsProvider.java @@ -18,8 +18,6 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import javax.inject.Provider; - import org.springframework.ide.vscode.commons.util.ExternalCommand; import org.springframework.ide.vscode.commons.util.ExternalProcess; @@ -31,7 +29,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; * * */ -public class CfCliParamsProvider implements Provider> { +public class CfCliParamsProvider implements ClientParamsProvider { public static final String TARGET = "Target"; public static final String REFRESH_TOKEN = "RefreshToken"; @@ -42,8 +40,14 @@ public class CfCliParamsProvider implements Provider> { private static Logger logger = Logger.getLogger(CfCliParamsProvider.class.getName()); + /* + * (non-Javadoc) + * + * @see org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget. + * ClientParamsProvider#getParams() + */ @Override - public List get() { + public List getParams() { try { File file = getConfigJsonFile(); if (file != null) { @@ -76,6 +80,17 @@ public class CfCliParamsProvider implements Provider> { return null; } + /* + * (non-Javadoc) + * + * @see org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget. + * ClientParamsProvider#noParamsAvailableMessage() + */ + @Override + public String noParamsAvailableMessage() { + return "No Cloud Foundry targets. Please use cf CLI to configure and login to a Cloud Foundry target."; + } + private File getConfigJsonFile() throws IOException, InterruptedException { // Support Unix systems for now if (!System.getProperty("os.name").toLowerCase().startsWith("win")) { diff --git a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/ClientParamsProvider.java b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/ClientParamsProvider.java new file mode 100644 index 000000000..ea58c2d3d --- /dev/null +++ b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/cftarget/ClientParamsProvider.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2017 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Pivotal, Inc. - initial API and implementation + *******************************************************************************/ +package org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget; + +import java.util.List; + +public interface ClientParamsProvider { + + List getParams(); + + String noParamsAvailableMessage(); + +} \ No newline at end of file diff --git a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/v2/DefaultClientRequestsV2.java b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/v2/DefaultClientRequestsV2.java index 7387eb290..ab7cfb0a0 100644 --- a/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/v2/DefaultClientRequestsV2.java +++ b/vscode-extensions/commons/commons-cf/src/main/java/org/springframework/ide/vscode/commons/cloudfoundry/client/v2/DefaultClientRequestsV2.java @@ -650,7 +650,7 @@ public class DefaultClientRequestsV2 implements ClientRequests { // ? stopApp(appName) // : restartApp(appName) // ); - throw new Error("Application push not currently supported in CF vscode"); + throw ExceptionUtil.notImplemented("Application push not currently supported in CF vscode"); } // private DefaultClientRequestsV1 v1() throws Exception { diff --git a/vscode-extensions/commons/commons-cf/src/test/java/org/springframework/ide/vscode/commons/cloudfoundry/client/CFClientTest.java b/vscode-extensions/commons/commons-cf/src/test/java/org/springframework/ide/vscode/commons/cloudfoundry/client/CFClientTest.java index 66818226b..1f24e3595 100644 --- a/vscode-extensions/commons/commons-cf/src/test/java/org/springframework/ide/vscode/commons/cloudfoundry/client/CFClientTest.java +++ b/vscode-extensions/commons/commons-cf/src/test/java/org/springframework/ide/vscode/commons/cloudfoundry/client/CFClientTest.java @@ -16,23 +16,29 @@ import java.util.List; import org.junit.Ignore; import org.junit.Test; -import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFClientParamsFactory; import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget; import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargetsFactory; +import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfCliParamsProvider; +import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider; import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.ClientTimeouts; import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.CloudFoundryClientFactory; import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.DefaultCloudFoundryClientFactoryV2; public class CFClientTest { + /* + * Not meant to be run in a build yet as there is no CF harness to read CF + * params. Just keeping this tests for local development. + */ + @Ignore + @Test + public void testGetBuildpacksFromCliParamsTarget() throws Exception { - - @Ignore @Test public void testGetBuildpacksFromCliParamsTarget() throws Exception { - - CFClientParamsFactory paramsFactory = CFClientParamsFactory.INSTANCE; + ClientParamsProvider cliProvider = new CfCliParamsProvider(); CloudFoundryClientFactory clientFactory = DefaultCloudFoundryClientFactoryV2.INSTANCE; + ClientTimeouts timeouts = ClientTimeouts.DEFAULT_TIMEOUTS; - CFTargetsFactory targets = new CFTargetsFactory(paramsFactory, clientFactory, ClientTimeouts.DEFAULT_TIMEOUTS); + CFTargetsFactory targets = new CFTargetsFactory(cliProvider, clientFactory, timeouts); CFTarget target = targets.getTargets().get(0); List buildPacks = target.getBuildpacks(); diff --git a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ExceptionUtil.java b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ExceptionUtil.java index ce0b380d1..57c260eff 100644 --- a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ExceptionUtil.java +++ b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ExceptionUtil.java @@ -76,7 +76,7 @@ public class ExceptionUtil { return new ExecutionException(cause); } - public static Object exception(String message, Throwable error) { + public static Exception exception(String message, Throwable error) { if (message != null) { // Wrap only if there is an additional message return new ExecutionException(message, error); @@ -84,5 +84,4 @@ public class ExceptionUtil { return exception(error); } } - } diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java index e2072f479..551e9db43 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java +++ b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java @@ -10,50 +10,67 @@ *******************************************************************************/ package org.springframework.ide.vscode.manifest.yaml; +import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.inject.Provider; import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget; import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargetsFactory; +import org.springframework.ide.vscode.commons.util.Assert; +import org.springframework.ide.vscode.commons.util.ExceptionUtil; import org.springframework.ide.vscode.commons.yaml.schema.BasicYValueHint; import org.springframework.ide.vscode.commons.yaml.schema.YValueHint; -import com.google.common.collect.Lists; - public abstract class AbstractCFHintsProvider implements Provider> { - private final CFTargetsFactory targetsFactory; + public static final String EMPTY_VALUE = ""; + protected final CFTargetsFactory targetsFactory; - /* - * TODO: This is probably a very wrong way of handling "No connections available" - */ - public static final YValueHint NO_CF_TARGET_HINT = new BasicYValueHint("", - "No valid Cloud Foundry target found. Please ensure that you are connected to Cloud Foundry and try again."); + private static final Logger logger = Logger.getLogger(AbstractCFHintsProvider.class.getName()); public AbstractCFHintsProvider(CFTargetsFactory targetsFactory) { + Assert.isNotNull(targetsFactory); this.targetsFactory = targetsFactory; } + @Override + public Collection get() { + Collection hints = new ArrayList<>(); + List targets = null; + try { + targets = targetsFactory.getTargets(); + } catch (Throwable e) { + // Don't throw exception. Just log, and instead show a "no targets" + // hint below + logger.log(Level.SEVERE, e.getMessage(), e); + } + + if (targets == null || targets.isEmpty()) { + // TODO: Probably a wrong thing to do, but for now show that + // there are + // no targets as a "hint" so that it appears + // in CA UI + hints.add(new BasicYValueHint(EMPTY_VALUE, targetsFactory.noTargetsMessage())); + } else { + try { + Collection resolvedHints = getHints(targets); + hints.addAll(resolvedHints); + } catch (Exception e) { + throw ExceptionUtil.unchecked(e); + } + } + + return hints; + } + /** * - * @return non-null list of targets. May be empty if no targets available. - * @throws Exception - * if error when creating the targets + * @return non-null list of hints. Return empty if no hints available */ - protected List getUpdatedCFTargets() throws Exception { - if (targetsFactory != null) { - // Do not cache the targets. They may change (e.g. if using cf - // CLI config, if CLI targets another API or org/space, the list - // of targets fetched from the factory also - // needs to be up-to-date) - List updatedTargets = targetsFactory.getTargets(); - if (updatedTargets != null) { - return Lists.newArrayList(updatedTargets.iterator()); - } - } - return Collections.emptyList(); - } + abstract protected Collection getHints(List targets) throws Exception; + } diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFBuildpacksProvider.java b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFBuildpacksProvider.java index ccfda3a23..fed914478 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFBuildpacksProvider.java +++ b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFBuildpacksProvider.java @@ -13,8 +13,6 @@ package org.springframework.ide.vscode.manifest.yaml; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack; import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget; @@ -24,43 +22,26 @@ import org.springframework.ide.vscode.commons.yaml.schema.YValueHint; public class ManifestYamlCFBuildpacksProvider extends AbstractCFHintsProvider { - private static final Logger logger = Logger.getLogger(ManifestYamlCFBuildpacksProvider.class.getName()); - public ManifestYamlCFBuildpacksProvider(CFTargetsFactory targetsFactory) { super(targetsFactory); } @Override - public Collection get() { + public Collection getHints(List targets) throws Exception { List hints = new ArrayList<>(); - try { - // Do not cache the targets. They may change (e.g. if using cf - // CLI config, if CLI targets another API or org/space, the list - // of targets fetched from the factory also - // needs to be up-to-date) - List targets = getUpdatedCFTargets(); - for (CFTarget cfTarget : targets) { + for (CFTarget cfTarget : targets) { - List buildpacks = cfTarget.getBuildpacks(); - if (buildpacks != null) { - for (CFBuildpack buildpack : buildpacks) { - String name = buildpack.getName(); - String label = getBuildpackLabel(cfTarget, buildpack); - YValueHint hint = new BasicYValueHint(name, label); - if (!hints.contains(hint)) { - hints.add(hint); - } + List buildpacks = cfTarget.getBuildpacks(); + if (buildpacks != null) { + for (CFBuildpack buildpack : buildpacks) { + String name = buildpack.getName(); + String label = getBuildpackLabel(cfTarget, buildpack); + YValueHint hint = new BasicYValueHint(name, label); + if (!hints.contains(hint)) { + hints.add(hint); } } } - } catch (Exception e) { - logger.log(Level.SEVERE, e.getMessage(), e); - } - - // TODO: probably a very bad thing to do, but for now a workaround to notify the user via the CA UI that there are no - // CF targets available. - if (hints.isEmpty()) { - hints.add(NO_CF_TARGET_HINT); } return hints; } @@ -68,5 +49,4 @@ public class ManifestYamlCFBuildpacksProvider extends AbstractCFHintsProvider { protected String getBuildpackLabel(CFTarget target, CFBuildpack buildpack) { return buildpack.getName() + " (" + target.getName() + ")"; } - } diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFServicesProvider.java b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFServicesProvider.java index 119bb8b58..bdcd5f58e 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFServicesProvider.java +++ b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlCFServicesProvider.java @@ -13,8 +13,6 @@ package org.springframework.ide.vscode.manifest.yaml; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; import org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance; import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget; @@ -22,47 +20,33 @@ import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTar import org.springframework.ide.vscode.commons.yaml.schema.BasicYValueHint; import org.springframework.ide.vscode.commons.yaml.schema.YValueHint; -public class ManifestYamlCFServicesProvider extends AbstractCFHintsProvider { - - - private static final Logger logger = Logger.getLogger(ManifestYamlCFServicesProvider.class.getName()); +public class ManifestYamlCFServicesProvider extends AbstractCFHintsProvider { public ManifestYamlCFServicesProvider(CFTargetsFactory targetsFactory) { super(targetsFactory); } @Override - public Collection get() { + public Collection getHints(List targets) throws Exception { List hints = new ArrayList<>(); - - try { - - List targets = getUpdatedCFTargets(); - for (CFTarget cfTarget : targets) { - List services = cfTarget.getClientRequests().getServices(); - if (services != null) { - for (CFServiceInstance service : services) { - String name = service.getName(); - String label = getServiceLabel(cfTarget, service); - YValueHint hint = new BasicYValueHint(name, label); - if (!hints.contains(hint)) { - hints.add(hint); - } + for (CFTarget cfTarget : targets) { + List services = cfTarget.getClientRequests().getServices(); + if (services != null) { + for (CFServiceInstance service : services) { + String name = service.getName(); + String label = getServiceLabel(cfTarget, service); + YValueHint hint = new BasicYValueHint(name, label); + if (!hints.contains(hint)) { + hints.add(hint); } } } - - } catch (Exception e) { - logger.log(Level.SEVERE, e.getMessage(), e); - } - - // TODO: probably a very bad thing to do, but for now a workaround to notify the user via the CA UI that there are no - // CF targets available. - if (hints.isEmpty()) { - hints.add(NO_CF_TARGET_HINT); } + if (hints.isEmpty()) { + hints.add(new BasicYValueHint(EMPTY_VALUE, "No Cloud Foundry service instances available")); + } return hints; } diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServer.java b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServer.java index 6d19ad923..64aec10c3 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServer.java +++ b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlLanguageServer.java @@ -19,7 +19,11 @@ import org.eclipse.lsp4j.CompletionOptions; import org.eclipse.lsp4j.ServerCapabilities; import org.eclipse.lsp4j.TextDocumentSyncKind; import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargetsFactory; +import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfCliParamsProvider; +import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider; import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.ClientTimeouts; +import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.CloudFoundryClientFactory; +import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.DefaultCloudFoundryClientFactoryV2; import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngine; import org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter; import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfoProvider; @@ -101,7 +105,9 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer { private CFTargetsFactory getCFTargetsFactory() { if (cfTargetsFactory == null) { - cfTargetsFactory = CFTargetsFactory.createDefaultV2TargetsFactory(VSCODE_CF_CLIENT_TIMEOUTS); + ClientParamsProvider paramsProvider = new CfCliParamsProvider(); + CloudFoundryClientFactory clientFactory = DefaultCloudFoundryClientFactoryV2.INSTANCE; + cfTargetsFactory = new CFTargetsFactory(paramsProvider, clientFactory, VSCODE_CF_CLIENT_TIMEOUTS); } return cfTargetsFactory; }