Search in sources :

Example 1 with Type

use of io.confluent.ksql.test.parser.TestDirective.Type in project ksql by confluentinc.

the class DirectiveParser method parse.

public static TestDirective parse(final Token comment) {
    final NodeLocation loc = new NodeLocation(comment.getLine(), comment.getCharPositionInLine());
    final Matcher matcher = DIRECTIVE_REGEX.matcher(comment.getText().trim());
    if (!matcher.find()) {
        throw new ParsingException("Expected directive matching pattern " + DIRECTIVE_REGEX + " but got " + comment, null, loc.getLineNumber(), loc.getColumnNumber());
    }
    final Type type = Type.from(matcher.group("type").toLowerCase());
    final String contents = matcher.group("contents");
    return new TestDirective(type, contents, loc);
}
Also used : Type(io.confluent.ksql.test.parser.TestDirective.Type) NodeLocation(io.confluent.ksql.parser.NodeLocation) Matcher(java.util.regex.Matcher) ParsingException(io.confluent.ksql.parser.ParsingException)

Aggregations

NodeLocation (io.confluent.ksql.parser.NodeLocation)1 ParsingException (io.confluent.ksql.parser.ParsingException)1 Type (io.confluent.ksql.test.parser.TestDirective.Type)1 Matcher (java.util.regex.Matcher)1