Skip to content

Commit

Permalink
feat(AST): add support for YAML AST errors
Browse files Browse the repository at this point in the history
Refs #1
  • Loading branch information
char0n committed Oct 1, 2020
1 parent ddd7d63 commit a72f5a5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apidom/packages/apidom-ast/src/transformers/tree-sitter-yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { YamlStyle, YamlStyleGroup } from '../nodes/yaml/YamlStyle';
import ParseResult from '../ParseResult';
import Position, { Point } from '../Position';
import Literal from '../Literal';
import Error from '../Error';
import { isNode, visit } from '../visitor';

export const keyMap = {
Expand All @@ -25,6 +26,7 @@ export const keyMap = {
mapping: ['children'],
keyValuePair: ['children'],
sequence: ['children'],
error: ['children'],
};

const Visitor = stampit({
Expand Down Expand Up @@ -405,6 +407,18 @@ const Visitor = stampit({
return YamlComment({ content: node.text });
},
};

this.ERROR = function ERROR(node: SyntaxNode) {
const position = toPosition(node);

return Error({
children: node.children,
position,
isUnexpected: !node.hasError(),
isMissing: node.isMissing(),
value: node.text,
});
};
},
});

Expand Down

0 comments on commit a72f5a5

Please sign in to comment.