From 71d68bb58a4d182c8a0b079c2b0058a8bd5f7ea2 Mon Sep 17 00:00:00 2001 From: nsingh Date: Mon, 23 Jan 2017 11:04:47 -0800 Subject: [PATCH] Allow CF Client Params provider to be set into language server This is to allow the params provider to be mocked or to support any other type of params provider in the language server --- .../vscode/manifest/yaml/ManifestYamlLanguageServer.java | 8 +++++--- .../ide/vscode/manifest/yaml/ManifestYamlEditorTest.java | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) 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 a262ed989..f1fe59da7 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 @@ -50,13 +50,15 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer { private YamlSchema schema; private CFTargetCache cfTargetCache; private final CloudFoundryClientFactory cfClientFactory; + private final ClientParamsProvider cfParamsProvider; public ManifestYamlLanguageServer() { - this(DefaultCloudFoundryClientFactoryV2.INSTANCE); + this(DefaultCloudFoundryClientFactoryV2.INSTANCE, new CfCliParamsProvider()); } - public ManifestYamlLanguageServer(CloudFoundryClientFactory cfClientFactory) { + public ManifestYamlLanguageServer(CloudFoundryClientFactory cfClientFactory, ClientParamsProvider cfParamsProvider) { this.cfClientFactory = cfClientFactory; + this.cfParamsProvider=cfParamsProvider; SimpleTextDocumentService documents = getTextDocumentService(); YamlASTProvider parser = new YamlParser(yaml); @@ -98,7 +100,7 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer { private CFTargetCache getCfTargetCache() { if (cfTargetCache == null) { - ClientParamsProvider paramsProvider = new CfCliParamsProvider(); + ClientParamsProvider paramsProvider = cfParamsProvider; CloudFoundryClientFactory clientFactory = cfClientFactory; cfTargetCache = new CFTargetCache(paramsProvider, clientFactory, new ClientTimeouts()); } diff --git a/vscode-extensions/vscode-manifest-yaml/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java b/vscode-extensions/vscode-manifest-yaml/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java index a71260db8..21f1f81e1 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java +++ b/vscode-extensions/vscode-manifest-yaml/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java @@ -19,6 +19,8 @@ import org.eclipse.lsp4j.Diagnostic; import org.junit.Before; import org.junit.Test; import org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests; +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.languageserver.testharness.Editor; import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness; @@ -26,9 +28,10 @@ public class ManifestYamlEditorTest { LanguageServerHarness harness; MockCloudfoundry cfClientFactory = new MockCloudfoundry(); + ClientParamsProvider cfParamsProvider = new CfCliParamsProvider(); @Before public void setup() throws Exception { - harness = new LanguageServerHarness(()-> new ManifestYamlLanguageServer(cfClientFactory)); + harness = new LanguageServerHarness(()-> new ManifestYamlLanguageServer(cfClientFactory, cfParamsProvider)); harness.intialize(null); }