Renamed CF client targets
This commit is contained in:
@@ -17,7 +17,7 @@ import java.util.logging.Logger;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.ClientRequests;
|
||||
|
||||
public class CFClientTarget {
|
||||
public class CFTarget {
|
||||
|
||||
private final CFClientParams params;
|
||||
private final ClientRequests requests;
|
||||
@@ -27,9 +27,9 @@ public class CFClientTarget {
|
||||
* Cached information
|
||||
*/
|
||||
private List<CFBuildpack> buildpacks;
|
||||
private final static Logger logger = Logger.getLogger(CFClientTarget.class.getName());
|
||||
private final static Logger logger = Logger.getLogger(CFTarget.class.getName());
|
||||
|
||||
public CFClientTarget(CFClientParams params, ClientRequests requests, String targetName) {
|
||||
public CFTarget(CFClientParams params, ClientRequests requests, String targetName) {
|
||||
this.params = params;
|
||||
this.requests = requests;
|
||||
this.targetName = targetName;
|
||||
@@ -21,24 +21,24 @@ import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.DefaultClou
|
||||
* Creates targets given a client parameters factory and a client factory.
|
||||
*
|
||||
*/
|
||||
public class CFClientTargets {
|
||||
public class CFTargets {
|
||||
|
||||
private final CFClientParamsFactory paramsFactory;
|
||||
private final CloudFoundryClientFactory clientFactory;
|
||||
|
||||
public CFClientTargets(CFClientParamsFactory paramsFactory, CloudFoundryClientFactory clientFactory) {
|
||||
public CFTargets(CFClientParamsFactory paramsFactory, CloudFoundryClientFactory clientFactory) {
|
||||
this.paramsFactory = paramsFactory;
|
||||
this.clientFactory = clientFactory;
|
||||
}
|
||||
|
||||
public List<CFClientTarget> getTargets() throws Exception {
|
||||
public List<CFTarget> getTargets() throws Exception {
|
||||
List<CFClientParams> allParams = paramsFactory.getParams();
|
||||
List<CFClientTarget> targets = new ArrayList<>();
|
||||
List<CFTarget> targets = new ArrayList<>();
|
||||
if (allParams != null) {
|
||||
for (CFClientParams parameters : allParams) {
|
||||
ClientRequests requests = clientFactory.getClient(parameters);
|
||||
if (requests != null) {
|
||||
targets.add(new CFClientTarget(parameters, requests, getTargetName(parameters)));
|
||||
targets.add(new CFTarget(parameters, requests, getTargetName(parameters)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,10 +59,10 @@ public class CFClientTargets {
|
||||
}
|
||||
}
|
||||
|
||||
public static CFClientTargets createDefaultV2ClientTargets() {
|
||||
public static CFTargets createDefaultV2Targets() {
|
||||
CFClientParamsFactory paramsFactory = CFClientParamsFactory.INSTANCE;
|
||||
CloudFoundryClientFactory clientFactory = DefaultCloudFoundryClientFactoryV2.INSTANCE;
|
||||
return new CFClientTargets(paramsFactory, clientFactory);
|
||||
return new CFTargets(paramsFactory, clientFactory);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,8 +17,8 @@ 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.CFClientTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFClientTargets;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargets;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.CloudFoundryClientFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.DefaultCloudFoundryClientFactoryV2;
|
||||
|
||||
@@ -31,8 +31,8 @@ public class CFClientTest {
|
||||
CFClientParamsFactory paramsFactory = CFClientParamsFactory.INSTANCE;
|
||||
CloudFoundryClientFactory clientFactory = DefaultCloudFoundryClientFactoryV2.INSTANCE;
|
||||
|
||||
CFClientTargets targets = new CFClientTargets(paramsFactory, clientFactory);
|
||||
CFClientTarget target = targets.getTargets().get(0);
|
||||
CFTargets targets = new CFTargets(paramsFactory, clientFactory);
|
||||
CFTarget target = targets.getTargets().get(0);
|
||||
|
||||
List<CFBuildpack> buildPacks = target.getBuildpacks();
|
||||
assertTrue(!buildPacks.isEmpty());
|
||||
|
||||
@@ -19,17 +19,17 @@ import java.util.logging.Logger;
|
||||
import javax.inject.Provider;
|
||||
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFClientTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.BasicYValueHint;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
|
||||
|
||||
public class ManifestYamlCFBuildpacksProvider implements Provider<Collection<YValueHint>> {
|
||||
|
||||
private final List<CFClientTarget> targets;
|
||||
private final List<CFTarget> targets;
|
||||
private static final Logger logger = Logger.getLogger(ManifestYamlCFBuildpacksProvider.class.getName());
|
||||
|
||||
|
||||
public ManifestYamlCFBuildpacksProvider(List<CFClientTarget> targets) {
|
||||
public ManifestYamlCFBuildpacksProvider(List<CFTarget> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
@@ -39,15 +39,15 @@ public class ManifestYamlCFBuildpacksProvider implements Provider<Collection<YVa
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
|
||||
if (targets != null) {
|
||||
for (CFClientTarget cfClientTarget : targets) {
|
||||
for (CFTarget cfTarget : targets) {
|
||||
|
||||
List<CFBuildpack> buildpacks;
|
||||
try {
|
||||
buildpacks = cfClientTarget.getBuildpacks();
|
||||
buildpacks = cfTarget.getBuildpacks();
|
||||
if (buildpacks != null) {
|
||||
for (CFBuildpack buildpack : buildpacks) {
|
||||
String name = buildpack.getName();
|
||||
String label = getBuildpackLabel(cfClientTarget, buildpack);
|
||||
String label = getBuildpackLabel(cfTarget, buildpack);
|
||||
YValueHint hint = new BasicYValueHint(name, label);
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint);
|
||||
@@ -62,7 +62,7 @@ public class ManifestYamlCFBuildpacksProvider implements Provider<Collection<YVa
|
||||
return hints;
|
||||
}
|
||||
|
||||
protected String getBuildpackLabel(CFClientTarget target, CFBuildpack buildpack) {
|
||||
protected String getBuildpackLabel(CFTarget target, CFBuildpack buildpack) {
|
||||
return buildpack.getName() + " (" + target.getName() + ")";
|
||||
}
|
||||
|
||||
|
||||
@@ -19,17 +19,17 @@ import java.util.logging.Logger;
|
||||
import javax.inject.Provider;
|
||||
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFClientTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.BasicYValueHint;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
|
||||
|
||||
public class ManifestYamlCFServicesProvider implements Provider<Collection<YValueHint>> {
|
||||
|
||||
private final List<CFClientTarget> targets;
|
||||
private final List<CFTarget> targets;
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ManifestYamlCFServicesProvider.class.getName());
|
||||
|
||||
public ManifestYamlCFServicesProvider(List<CFClientTarget> targets) {
|
||||
public ManifestYamlCFServicesProvider(List<CFTarget> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ public class ManifestYamlCFServicesProvider implements Provider<Collection<YValu
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
|
||||
if (targets != null) {
|
||||
for (CFClientTarget cfClientTarget : targets) {
|
||||
for (CFTarget cfTarget : targets) {
|
||||
|
||||
try {
|
||||
List<CFServiceInstance> services = cfClientTarget.getClientRequests().getServices();
|
||||
List<CFServiceInstance> services = cfTarget.getClientRequests().getServices();
|
||||
if (services != null) {
|
||||
for (CFServiceInstance service : services) {
|
||||
String name = service.getName();
|
||||
String label = getServiceLabel(cfClientTarget, service);
|
||||
String label = getServiceLabel(cfTarget, service);
|
||||
YValueHint hint = new BasicYValueHint(name, label);
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint);
|
||||
@@ -60,7 +60,7 @@ public class ManifestYamlCFServicesProvider implements Provider<Collection<YValu
|
||||
return hints;
|
||||
}
|
||||
|
||||
private String getServiceLabel(CFClientTarget cfClientTarget, CFServiceInstance service) {
|
||||
private String getServiceLabel(CFTarget cfClientTarget, CFServiceInstance service) {
|
||||
return service.getName() + " - " + service.getPlan() + " (" + cfClientTarget.getParams().getOrgName() + " - "
|
||||
+ cfClientTarget.getParams().getSpaceName() + ")";
|
||||
}
|
||||
|
||||
@@ -10,11 +10,8 @@ import javax.inject.Provider;
|
||||
import org.eclipse.lsp4j.CompletionOptions;
|
||||
import org.eclipse.lsp4j.ServerCapabilities;
|
||||
import org.eclipse.lsp4j.TextDocumentSyncKind;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFClientParamsFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFClientTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFClientTargets;
|
||||
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.cftarget.CFTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargets;
|
||||
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;
|
||||
@@ -45,7 +42,7 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
|
||||
|
||||
private Yaml yaml = new Yaml();
|
||||
private YamlSchema schema;
|
||||
private CFClientTargets cfClientTargets;
|
||||
private CFTargets cfTargets;
|
||||
|
||||
|
||||
public ManifestYamlLanguageServer() {
|
||||
@@ -53,7 +50,7 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
|
||||
|
||||
YamlASTProvider parser = new YamlParser(yaml);
|
||||
|
||||
CFClientTargets cfTargets = getCFTargets();
|
||||
CFTargets cfTargets = getCFTargets();
|
||||
|
||||
Provider<Collection<YValueHint>> buildPacksProvider = getBuildpacksProvider(cfTargets);
|
||||
Provider<Collection<YValueHint>> servicesProvider = getServicesProvider(cfTargets);
|
||||
@@ -90,18 +87,19 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
|
||||
documents.onHover(hoverEngine ::getHover);
|
||||
}
|
||||
|
||||
private CFClientTargets getCFTargets() {
|
||||
if (cfClientTargets == null) {
|
||||
cfClientTargets = CFClientTargets.createDefaultV2ClientTargets();
|
||||
private CFTargets getCFTargets() {
|
||||
// TODO: probably shouldn't be cached as targets can change during a language server session
|
||||
if (cfTargets == null) {
|
||||
cfTargets = CFTargets.createDefaultV2Targets();
|
||||
}
|
||||
return cfClientTargets;
|
||||
return cfTargets;
|
||||
}
|
||||
|
||||
private Provider<Collection<YValueHint>> getBuildpacksProvider(CFClientTargets targets) {
|
||||
private Provider<Collection<YValueHint>> getBuildpacksProvider(CFTargets targets) {
|
||||
|
||||
try {
|
||||
if (targets != null) {
|
||||
List<CFClientTarget> cfTargets = targets.getTargets();
|
||||
List<CFTarget> cfTargets = targets.getTargets();
|
||||
if (cfTargets != null && !cfTargets.isEmpty()) {;
|
||||
return new ManifestYamlCFBuildpacksProvider(cfTargets);
|
||||
}
|
||||
@@ -113,11 +111,11 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
|
||||
return NO_PROVIDER;
|
||||
}
|
||||
|
||||
private Provider<Collection<YValueHint>> getServicesProvider(CFClientTargets targets) {
|
||||
private Provider<Collection<YValueHint>> getServicesProvider(CFTargets targets) {
|
||||
|
||||
try {
|
||||
if (targets != null) {
|
||||
List<CFClientTarget> cfTargets = targets.getTargets();
|
||||
List<CFTarget> cfTargets = targets.getTargets();
|
||||
if (cfTargets != null && !cfTargets.isEmpty()) {
|
||||
return new ManifestYamlCFServicesProvider(cfTargets);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user