From 24424c2b57a07fe719d6f53d409e76b18838da49 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Tue, 22 Nov 2016 14:10:14 -0800 Subject: [PATCH 1/2] Support for healt-check-type attribute in manifest.yml editor --- .../vscode/commons/util/EnumValueParser.java | 2 +- .../manifest/yaml/ManifestYmlSchema.java | 5 ++++- .../health-check-type.html | 9 ++++++++ .../health-check-type.md | 9 ++++++++ .../manifest/yaml/ManifestYamlEditorTest.java | 21 ++++++++++++++++--- .../manifest/yaml/ManifestYmlSchemaTest.java | 2 ++ 6 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 vscode-extensions/vscode-manifest-yaml/src/main/resources/description-by-prop-name/health-check-type.html create mode 100644 vscode-extensions/vscode-manifest-yaml/src/main/resources/description-by-prop-name/health-check-type.md diff --git a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/EnumValueParser.java b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/EnumValueParser.java index 212a3c5e8..97827e0c0 100644 --- a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/EnumValueParser.java +++ b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/EnumValueParser.java @@ -38,7 +38,7 @@ public class EnumValueParser implements ValueParser { if (values.contains(str)) { return str; } else { - throw new IllegalArgumentException("'"+str+"' is not valid for Enum '"+typeName+"'"); + throw new IllegalArgumentException("'"+str+"' is not valid for Enum '"+typeName+"'. Valid values are: "+values); } } diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java index a13fe80ca..6f826fa6e 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java +++ b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchema.java @@ -63,6 +63,8 @@ public class ManifestYmlSchema implements YamlSchema { YAtomicType t_memory = f.yatomic("Memory"); t_memory.addHints("256M", "512M", "1024M"); t_memory.parseWith(ManifestYmlValueParsers.MEMORY); + + YAtomicType t_health_check_type = f.yenum("Health Check Type", "none", "port"); YAtomicType t_strictly_pos_integer = f.yatomic("Strictly Positive Integer"); t_strictly_pos_integer.parseWith(ManifestYmlValueParsers.integerAtLeast(1)); @@ -94,7 +96,8 @@ public class ManifestYmlSchema implements YamlSchema { f.yprop("random-route", t_boolean), f.yprop("services", t_strings), f.yprop("stack", t_string), - f.yprop("timeout", t_pos_integer) + f.yprop("timeout", t_pos_integer), + f.yprop("health-check-type", t_health_check_type) }; for (YTypedPropertyImpl prop : props) { diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/resources/description-by-prop-name/health-check-type.html b/vscode-extensions/vscode-manifest-yaml/src/main/resources/description-by-prop-name/health-check-type.html new file mode 100644 index 000000000..30be9affb --- /dev/null +++ b/vscode-extensions/vscode-manifest-yaml/src/main/resources/description-by-prop-name/health-check-type.html @@ -0,0 +1,9 @@ +

Use the health-check-type attribute to set the health_check_type +flag to either port or none. If you do not provide +a health-check-type attribute, it defaults to port.

+ +
+---
+  ...
+  health-check-type: none
+
\ No newline at end of file diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/resources/description-by-prop-name/health-check-type.md b/vscode-extensions/vscode-manifest-yaml/src/main/resources/description-by-prop-name/health-check-type.md new file mode 100644 index 000000000..fac9be7d7 --- /dev/null +++ b/vscode-extensions/vscode-manifest-yaml/src/main/resources/description-by-prop-name/health-check-type.md @@ -0,0 +1,9 @@ +Use the `health-check-type` attribute to set the `health_check_type` +flag to either `port` or `none`. If you do not provide a `health-check-type` +attribute, it defaults to `port`. + +``` +--- + ... + health-check-type: none +``` 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 c305344a2..ab1cb793c 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 @@ -145,13 +145,15 @@ public class ManifestYamlEditorTest { " instances: not a number\n" + " no-route: notBool\n"+ " memory: 1024\n" + - " disk_quota: 2048\n" + " disk_quota: 2048\n" + + " health-check-type: unhealthy" ); editor.assertProblems( "not a number|Positive Integer", "notBool|boolean", "1024|Memory", - "2048|Memory" + "2048|Memory", + "unhealthy|Health Check Type" ); //check for 'range' errors: @@ -232,6 +234,8 @@ public class ManifestYamlEditorTest { "env:\n"+ " <*>", // --------------- + "health-check-type: <*>", + // --------------- // "host: <*>", // --------------- // "hosts: \n"+ @@ -297,6 +301,9 @@ public class ManifestYamlEditorTest { " <*>", // --------------- "applications:\n" + + "- health-check-type: <*>", + // --------------- + "applications:\n" + "- host: <*>", // --------------- "applications:\n" + @@ -360,6 +367,11 @@ public class ManifestYamlEditorTest { "random-route: false<*>", "random-route: true<*>" ); + + assertCompletions("health-check-type: <*>", + "health-check-type: none<*>", + "health-check-type: port<*>" + ); } @Test @@ -392,7 +404,8 @@ public class ManifestYamlEditorTest { " - instance_ABC\n" + " - instance_XYZ\n" + " stack: cflinuxfs2\n" + - " timeout: 80\n" + " timeout: 80\n" + + " health-check-type: none\n" ); editor.assertIsHoverRegion("memory"); editor.assertIsHoverRegion("inherit"); @@ -414,6 +427,7 @@ public class ManifestYamlEditorTest { editor.assertIsHoverRegion("services"); editor.assertIsHoverRegion("stack"); editor.assertIsHoverRegion("timeout"); + editor.assertIsHoverRegion("health-check-type"); editor.assertHoverContains("memory", "Use the `memory` attribute to specify the memory limit"); editor.assertHoverContains("1G", "Use the `memory` attribute to specify the memory limit"); @@ -435,6 +449,7 @@ public class ManifestYamlEditorTest { editor.assertHoverContains("services", "The `services` block consists of a heading, then one or more service instance names"); editor.assertHoverContains("stack", "Use the `stack` attribute to specify which stack to deploy your application to."); editor.assertHoverContains("timeout", "The `timeout` attribute defines the number of seconds Cloud Foundry allocates for starting your application"); + editor.assertHoverContains("health-check-type", "Use the `health-check-type` attribute to"); } ////////////////////////////////////////////////////////////////////////////// diff --git a/vscode-extensions/vscode-manifest-yaml/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchemaTest.java b/vscode-extensions/vscode-manifest-yaml/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchemaTest.java index 97ec0d2b1..b2d59e0b6 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchemaTest.java +++ b/vscode-extensions/vscode-manifest-yaml/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYmlSchemaTest.java @@ -42,6 +42,7 @@ public class ManifestYmlSchemaTest { "domain", "domains", "env", + "health-check-type", "host", "hosts", // "inherit", @@ -65,6 +66,7 @@ public class ManifestYmlSchemaTest { "domain", "domains", "env", + "health-check-type", // "host", // "hosts", "inherit", From b4b148f6335ba04a914546d78034e6f62026d723 Mon Sep 17 00:00:00 2001 From: Kris De Volder Date: Tue, 22 Nov 2016 17:00:33 -0800 Subject: [PATCH 2/2] Avoid errors in vscode about invalid hovers. --- .../languageserver/util/SimpleTextDocumentService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vscode-extensions/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java b/vscode-extensions/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java index 27c990dd0..4871ec786 100644 --- a/vscode-extensions/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java +++ b/vscode-extensions/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/util/SimpleTextDocumentService.java @@ -44,6 +44,8 @@ import org.eclipse.lsp4j.services.TextDocumentService; import org.springframework.ide.vscode.commons.util.Assert; import org.springframework.ide.vscode.commons.util.Futures; +import com.google.common.collect.ImmutableList; + public class SimpleTextDocumentService implements TextDocumentService { private static final Logger LOG = Logger.getLogger(SimpleTextDocumentService.class.getName()); @@ -167,7 +169,7 @@ public class SimpleTextDocumentService implements TextDocumentService { public final static CompletableFuture NO_COMPLETIONS = Futures.of( new CompletionList(false, Collections.emptyList())); - public final static CompletableFuture NO_HOVER = Futures.of(null); + public final static CompletableFuture NO_HOVER = Futures.of(new Hover(ImmutableList.of(), null)); @Override