private CommonTree parseParamList(CommonToken paramListToken) { String paramList = paramListToken.getText(); CommonTree root = new CommonTree(); int startIndex = paramListToken.getStartIndex(); int i=0; while (i<paramList.length()) { CommonToken token = getParamListSubToken(paramListToken, paramList, i); root.addChild(new CommonTree(token)); i += token.getText().length(); } if (root.getChildCount() == 0) { return null; } return root; }
private CommonTree buildTree(int type, String text, List<CommonTree> children) { CommonTree root = new CommonTree(new CommonToken(type, text)); for (CommonTree child: children) { root.addChild(child); } return root; }
@Override public Object create(Token payload) { return new CommonTree(payload); }
@Override public Tree dupNode() { return new CommonTree(this); }
@Override public Object create(Token payload) { return new CommonTree(payload); }
@Override public Tree dupNode() { return new CommonTree(this); }
public Object create(Token payload) { return new CommonTree(payload); } };
grammar Text; options { output=AST; } ... chunk : CHUNK+ -> {new CommonTree(new CommonToken(CHUNK, $text))} ; ...
@Override public Tree createNode() { return new CommonTree(new CommonToken(JPA2Lexer.WORD, entityVariableName)); }
private CommonTree createNode(int type) { String text = regularExpressionParser.tokenNames[type]; return new CommonTree(new CommonToken(type, text)); }
public void addDefaultChildren(String fieldPath) { String[] strings = fieldPath.split("\\."); for (String string : strings) { addChild(new CommonTree(new CommonToken(JPA2Lexer.WORD, string))); } }
private Tree getChildList(Tree parent) { // nodes with no token are "nil" nodes in antlr, // which act as lists of children. Tree listNode = new CommonTree(); for (int childIndex = 0; childIndex < parent.getChildCount(); childIndex++) { listNode.addChild(parent.getChild(childIndex)); } return listNode; }
private CommonTree buildTree(int type, String text, List<CommonTree> children) { CommonTree root = new CommonTree(new CommonToken(type, text)); for (CommonTree child: children) { root.addChild(child); } return root; }
private CommonTree buildTree(int type, String text, List<CommonTree> children) { CommonTree root = new CommonTree(new CommonToken(type, text)); for (CommonTree child: children) { root.addChild(child); } return root; }
public void replaceWithSelectId(String idProperty, PathNode pathNode) { if (pathNode != null) { pathNode.addChild(new CommonTree(new CommonToken(JPA2Lexer.WORD, idProperty))); } }
private CommonTree buildTree(int type, String text, List<CommonTree> children) { CommonTree root = new CommonTree(new CommonToken(type, text)); for (CommonTree child: children) { root.addChild(child); } return root; }
protected AggregateExpressionNode createCountNode(Tree tree, boolean distinct) { AggregateExpressionNode result = new AggregateExpressionNode(JPA2Lexer.T_AGGREGATE_EXPR); result.addChild(new CommonTree(new CommonToken(JPA2Lexer.COUNT, "count"))); result.addChild(new CommonTree(new CommonToken(JPA2Lexer.LPAREN, "("))); if (distinct) { result.addChild(new CommonTree(new CommonToken(JPA2Lexer.DISTINCT, "distinct"))); } result.addChild(tree); result.addChild(new CommonTree(new CommonToken(JPA2Lexer.RPAREN, ")"))); return result; }
public void clearInConditions(List<SimpleConditionNode> conditions) { for (SimpleConditionNode condition : conditions) { Tree inToken = condition.getFirstChildWithType(JPA2Lexer.IN); if (inToken != null) { Tree notToken = condition.getFirstChildWithType(JPA2Lexer.NOT); condition.getChildren().clear(); condition.addChild(new CommonTree(new CommonToken(JPA2Lexer.WORD, notToken == null ? "1=0" : "1=1"))); condition.freshenParentAndChildIndexes(); } } }
public void replaceEntityName(String newEntityName, IdentificationVariableNode identificationVariable) { if (identificationVariable != null) { identificationVariable.deleteChild(0); identificationVariable.addChild(new CommonTree(new CommonToken(JPA2Lexer.WORD, newEntityName))); identificationVariable.freshenParentAndChildIndexes(); } }
public void addDistinct() { CommonTree selectedItems = queryTree.getAstSelectedItemsNode(); boolean isDistinct = "distinct".equalsIgnoreCase(selectedItems.getChild(0).getText()); if (!isDistinct) { selectedItems.insertChild(0, new CommonTree(new CommonToken(JPA2Lexer.DISTINCT, "distinct"))); selectedItems.freshenParentAndChildIndexes(); } }