diff --git a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java index 14fcd34a3..6a70e86c1 100644 --- a/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java +++ b/headless-services/commons/commons-yaml/src/main/java/org/springframework/ide/vscode/commons/yaml/reconcile/SchemaBasedYamlASTReconciler.java @@ -139,7 +139,7 @@ public class SchemaBasedYamlASTReconciler implements YamlASTReconciler { private void reconcile(YamlFileAST ast, YamlPath path, Node parent, Node node, YType _type) { // IDocument doc = ast.getDocument(); - if (_type!=null) { + if (_type!=null && !skipReconciling(node)) { DynamicSchemaContext schemaContext = new ASTDynamicSchemaContext(ast, path, node); YType type = typeUtil.inferMoreSpecificType(_type, schemaContext); if (typeCollector!=null) { @@ -341,16 +341,15 @@ public class SchemaBasedYamlASTReconciler implements YamlASTReconciler { protected NodeId getNodeId(Node node) { NodeId id = node.getNodeId(); - if (id==NodeId.mapping && isMoustacheVar(node)) { - return NodeId.scalar; - } +// if (id==NodeId.mapping && isMoustacheVar(node)) { +// return NodeId.scalar; +// } return id; } /** * 'Moustache' variables look like `{{name}}` and unfortuately when - * parsed these will parse as a kind of map. But since these vars are meant to be replaced - * with some kind of string we should treat them as scalar instead. + * parsed these will parse as a kind of weird map node. *
* This function recognizes a mapping node that actually is moustache var pattern. */ @@ -358,6 +357,16 @@ public class SchemaBasedYamlASTReconciler implements YamlASTReconciler { return NodeUtil.asScalar(debrace(debrace(node))) != null; } + private boolean isParensPlaceHolder(Node node) { + String scalar = NodeUtil.asScalar(node); + return scalar != null && scalar.startsWith("((") && scalar.endsWith("))"); + } + + protected boolean skipReconciling(Node node) { + return isMoustacheVar(node) || isParensPlaceHolder(node); + } + + private Node debrace(Node _node) { MappingNode node = NodeUtil.asMapping(_node); if (node!=null && node.getFlowStyle() && node.getValue().size()==1) { diff --git a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java index 542c997cb..daf08c4ce 100644 --- a/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java +++ b/headless-services/concourse-language-server/src/test/java/org/springframework/ide/vscode/concourse/ConcourseEditorTest.java @@ -4062,6 +4062,22 @@ public class ConcourseEditorTest { editor.assertHoverContains("environment_variables", "Environment variables"); } + @Test public void bug_152918825_no_reconciling_for_double_parens_placeholders() throws Exception { + //https://www.pivotaltracker.com/story/show/152918825 + Editor editor = harness.newEditor( + "resources:\n" + + "- name: image-XXX\n" + + " type: docker-image\n" + + " source:\n" + + " repository: ((DOCKER_IMAGE))\n" + + " insecure_registries: ((DOCKER_INSECURE_REGISTRIES))\n" + + " tag: latest" + ); + editor.assertProblems( + "image-XXX|Unused 'Resource'" + ); + } + ////////////////////////////////////////////////////////////////////////////// private void assertContextualCompletions(String conText, String textBefore, String... textAfter) throws Exception {