Don't validate completely empty yaml subdocs in application.yml

See https://github.com/spring-projects/sts4/issues/711
This commit is contained in:
Kris De Volder
2022-06-21 14:40:58 -07:00
parent 24667d6127
commit 7eccab1262
2 changed files with 28 additions and 1 deletions

View File

@@ -58,6 +58,7 @@ import org.springframework.ide.vscode.commons.yaml.ast.NodeUtil;
import org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST;
import org.springframework.ide.vscode.commons.yaml.path.YamlPath;
import org.springframework.ide.vscode.commons.yaml.reconcile.YamlASTReconciler;
import org.springframework.ide.vscode.commons.yaml.util.YamlUtil;
import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.nodes.NodeId;
@@ -95,7 +96,12 @@ public class ApplicationYamlASTReconciler implements YamlASTReconciler {
List<Node> nodes = root.getNodes();
if (nodes!=null && !nodes.isEmpty()) {
for (Node node : nodes) {
reconcile(root, node, nav);
if (!"".equals(NodeUtil.asScalar(node))) {
//^^^ ignore completely empty yaml (sub)documents. Checking them results in
//spurious errors/warnings.
//See https://github.com/spring-projects/sts4/issues/711
reconcile(root, node, nav);
}
}
}
}

View File

@@ -90,6 +90,27 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest {
}
////////////////////////////////////////////////////////////////////////////////////////
@Test public void test_GH_711_error_on_extra_empty_yaml_document() throws Exception {
//https://github.com/spring-projects/sts4/issues/711
defaultTestData();
Editor editor = newEditor(
"spring:\n" +
" application:\n" +
" name: demo\n" +
"---\n" +
"spring:\n" +
" profiles:\n" +
" active: dev\n" +
"services:\n" +
" common:\n" +
" url: https://getguid.azurewebsites.net\n" +
"---\n"
);
editor.assertProblems(
"services|Unknown"
);
}
@Test public void test_GH_615_deprecated_spring_profiles() throws Exception {
IJavaProject p = createPredefinedMavenProject("empty-boot-2.4.4-app");