@Override @SuppressWarnings("unchecked") public List<IDsqlNode> getChildren() { return (List<IDsqlNode>) super.getChildren(); } }
public AST setNextSibling(AST sibling) { if (parent != null && sibling != null) { parent.getChildren().add(this.childIndex, sibling); } return this; }
public boolean hasChildren() { @SuppressWarnings("rawtypes") List children = super.getChildren(); return children!=null && !children.isEmpty(); }
@Override public List<AST> getChildren() { List<AST> children = super.getChildren(); if (children == null) return Collections.emptyList(); else return children; }
public AST(CommonTree commontree) { super(commontree); if (commontree.getChildren() != null) { for (Object child : commontree.getChildren()) { addChild((CommonTree)child); } } }
@SuppressWarnings("unchecked") protected <T> Stream<T> generateChildrenByClass(CommonTree commonTree, Class<T> clazz) { return commonTree.getChildren().stream() .filter(o -> clazz.isAssignableFrom(o.getClass())) .map(o -> (T) o); } }
public static List<CommonTree> getModifierChildren(CommonTree ct) { //return (CommonTree) ct.getChild(MODIFIERS_CHILD_INDEX); return ((List<?>) ((CommonTree) ct.getChild(MODIFIERS_CHILD_INDEX)).getChildren()).stream() .map((c) -> (CommonTree) c).collect(Collectors.toList()); }
@SuppressWarnings("unchecked") private Choice convertChoice(CommonTree node) throws SyntaxError { List<CommonTree> childNodes = node.getChildren(); List<Object> childPatterns = new ArrayList<Object>(); if (childNodes != null) for (CommonTree childNode : childNodes) childPatterns.add(convertNode(childNode)); return new Choice(childPatterns.toArray()); }
@SuppressWarnings("unchecked") private Sequence convertSequence(CommonTree tree) throws SyntaxError { List<CommonTree> childNodes = tree.getChildren(); List<Object> children = new ArrayList<Object>(); if (childNodes != null) for (Object child : childNodes) children.add(convertNode((CommonTree) child)); return new Sequence(children.toArray()); }
public static final List<CommonTree> getParamDeclChildren(CommonTree ct) { return (ct.getChildCount() == 0) ? Collections.emptyList() : AntlrToScribParserUtil.toCommonTreeList(ct.getChildren()); } }
public static List<CommonTree> getInteractionChildren(CommonTree ct) { return (ct.getChildCount() == 0) ? Collections.emptyList() : AntlrToScribParserUtil.toCommonTreeList(ct.getChildren()); } }
public static List<CommonTree> getMessageChildren(CommonTree ct) { return AntlrToScribParserUtil.toCommonTreeList(ct.getChildren().subList(MESSAGE_CHILDREN_START_INDEX, ct.getChildCount())); } }
@SuppressWarnings("unchecked") private static Quantifier convertExplicitQuantifier(CommonTree tree) { int min = 0; Integer max = null; List<CommonTree> children = tree.getChildren(); min = convertInt(children.get(0)); if (children.size() > 1) max = convertInt(children.get(1)); Quantifier result = new Quantifier(min, max); return result; }
@SuppressWarnings("unchecked") private Choice convertChoice(CommonTree node) throws SyntaxError { List<CommonTree> childNodes = node.getChildren(); List<RegexPart> childPatterns = new ArrayList<RegexPart>(); if (childNodes != null) for (CommonTree childNode : childNodes) childPatterns.add(convertRegexPart(childNode)); return new Choice(CollectionUtil.toArray(childPatterns, RegexPart.class)); }
@SuppressWarnings("unchecked") private Group convertGroup(CommonTree node) throws SyntaxError { List<CommonTree> childNodes = node.getChildren(); Assert.equals(1, childNodes.size(), "Group is expected to have exactly one child node"); return new Group(convertNode(childNodes.get(0))); }
@SuppressWarnings("unchecked") private Sequence convertSequence(CommonTree tree) throws SyntaxError { List<CommonTree> childNodes = tree.getChildren(); List<RegexPart> children = new ArrayList<RegexPart>(); if (childNodes != null) for (CommonTree child : childNodes) children.add(convertRegexPart((CommonTree) child)); return new Sequence(CollectionUtil.toArray(children, RegexPart.class)); }
@SuppressWarnings("unchecked") private Factor convertFactor(CommonTree tree) throws SyntaxError { List<CommonTree> children = tree.getChildren(); RegexPart subPattern = convertRegexPart(children.get(0)); Quantifier quantifier = null; if (children.size() > 1) quantifier = convertQuantifier(children.get(1)); else quantifier = new Quantifier(1, 1); return new Factor(subPattern, quantifier); }
@SuppressWarnings("unchecked") private Factor convertFactor(CommonTree tree) throws SyntaxError { List<CommonTree> children = tree.getChildren(); Object subPattern = convertNode(children.get(0)); Quantifier quantifier = null; if (children.size() > 1) quantifier = convertQuantifier(children.get(1)); else quantifier = new Quantifier(1, 1); return new Factor(subPattern, quantifier); }
@SuppressWarnings("unchecked") private Object convertRange(CommonTree node) throws SyntaxError { List<CommonTree> children = node.getChildren(); CommonTree fromNode = children.get(0); char from = (Character) convertNode(fromNode); CommonTree toNode = children.get(1); char to = (Character) convertNode(toNode); return new CharSet(fromNode.getText() + "-" + toNode.getText(), from, to); }
@SuppressWarnings("unchecked") private RegexCharClass convertRange(CommonTree node) throws SyntaxError { List<CommonTree> children = node.getChildren(); CommonTree fromNode = children.get(0); char from = ((RegexChar) convertRegexPart(fromNode)).getChar(); CommonTree toNode = children.get(1); char to = ((RegexChar) convertRegexPart(toNode)).getChar(); return new CharRange(fromNode.getText() + "-" + toNode.getText(), from, to); }