Yaml reconcile, detect 'missing anchor' reference

This commit is contained in:
Kris De Volder
2019-02-05 14:36:31 -08:00
parent 7d47662094
commit 5026fdc412
2 changed files with 19 additions and 5 deletions

View File

@@ -19,7 +19,9 @@ import org.springframework.ide.vscode.commons.languageserver.reconcile.Reconcile
import org.springframework.ide.vscode.commons.util.text.IDocument;
import org.springframework.ide.vscode.commons.yaml.ast.YamlASTProvider;
import org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST;
import org.yaml.snakeyaml.composer.ComposerException;
import org.yaml.snakeyaml.error.Mark;
import org.yaml.snakeyaml.error.MarkedYAMLException;
import org.yaml.snakeyaml.parser.ParserException;
import org.yaml.snakeyaml.scanner.ScannerException;
@@ -45,11 +47,7 @@ public abstract class YamlReconcileEngine implements IReconcileEngine {
if (reconciler!=null) {
reconciler.reconcile(ast);
}
} catch (ParserException e) {
String msg = e.getProblem();
Mark mark = e.getProblemMark();
problemCollector.accept(syntaxError(msg, mark.getIndex(), 1));
} catch (ScannerException e) {
} catch (MarkedYAMLException e) {
String msg = e.getProblem();
Mark mark = e.getProblemMark();
problemCollector.accept(syntaxError(msg, mark.getIndex(), 1));

View File

@@ -4928,6 +4928,22 @@ public class ConcourseEditorTest {
);
}
@Test
public void referenceToMissingAnchor() throws Exception {
Editor editor = harness.newEditor(
"repo-dflts: &repo-dflts\n" +
" bogus: bar\n" +
"resources:\n" +
"- name: foo\n" +
" type: git\n" +
" source:\n" +
" <<: *TYPO\n"
);
editor.assertProblems(
"*|undefined alias TYPO"
);
}
@Test
public void anchorsAndReferenceSample_1() throws Exception {
Editor editor = harness.newEditor(