Never reconcile place holder nodes (fixes PT-152918825)

This commit is contained in:
Kris De Volder
2017-11-23 13:17:01 -08:00
parent 062af41a02
commit d676ca411c
2 changed files with 31 additions and 6 deletions

View File

@@ -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.
* <p>
* 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) {

View File

@@ -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 {