@Override public Object dupTree(Object t, Object parent) { // Overriden to copy start index / end index, that is needed through optimization, // e.g., for masking/filtering ASTNode astNode = (ASTNode) t; ASTNode astNodeCopy = (ASTNode) super.dupTree(t, parent); astNodeCopy.setTokenStartIndex(astNode.getTokenStartIndex()); astNodeCopy.setTokenStopIndex(astNode.getTokenStopIndex()); return astNodeCopy; }
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
@Override public GrammarAST create(int tokenType, Token fromToken, String text) { return (GrammarAST)super.create(tokenType, fromToken, text); }
@Override public Object errorNode(TokenStream input, Token start, Token stop, RecognitionException e) { if (e instanceof NoViableAltException) { NoViableAltException noAlt = (NoViableAltException) e; String description = noAlt.grammarDecisionDescription; int position = noAlt.index; errorMessages.add(description + ":" + position); } return super.errorNode(input, start, stop, e); }
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
@Override public GrammarAST create(int tokenType, Token fromToken) { return (GrammarAST)super.create(tokenType, fromToken); }
@Override public Object errorNode(TokenStream ts, Token t1, Token t2, RecognitionException rex) { ProvaErrorNode pen = new ProvaErrorNode(null); pen.setErrorNode((CommonErrorNode) super.errorNode(ts, t1, t2, rex)); return pen; } };
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
/** * Create a DroolsTree and keeps the char offset info. */ public Object create( int tokenType, Token fromToken, String text ) { if ( fromToken instanceof DroolsToken ) { DroolsTree result = (DroolsTree) super.create( tokenType, fromToken, text ); result .setStartCharOffset( ((DroolsToken) fromToken) .getStartIndex() ); if ( text == null ) { result.setEndCharOffset( ((DroolsToken) fromToken) .getStopIndex() ); } else { result.setEndCharOffset( result.getStartCharOffset() + text.length() ); } return result; } return super.create( tokenType, fromToken, text ); }
List<ASTNode> subQueriesInOriginalTree = SubQueryUtils.findSubQueries(searchCond); ASTNode clonedSearchCond = (ASTNode) SubQueryUtils.adaptor.dupTree(searchCond); List<ASTNode> subQueries = SubQueryUtils.findSubQueries(clonedSearchCond); for(int i=0; i<subQueriesInOriginalTree.size(); i++){
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
@Override /** Make sure even imaginary nodes know the input stream */ public Object create(int tokenType, String text) { GrammarAST t; if ( tokenType==ANTLRParser.RULE ) { // needed by TreeWizard to make RULE tree t = new RuleAST(new CommonToken(tokenType, text)); } else if ( tokenType==ANTLRParser.STRING_LITERAL ) { // implicit lexer construction done with wizard; needs this node type // whereas grammar ANTLRParser.g can use token option to spec node type t = new TerminalAST(new CommonToken(tokenType, text)); } else { t = (GrammarAST)super.create(tokenType, text); } t.token.setInputStream(input); return t; }
List<ASTNode> subQueriesInOriginalTree = SubQueryUtils.findSubQueries(searchCond); ASTNode clonedSearchCond = (ASTNode) SubQueryUtils.adaptor.dupTree(searchCond); List<ASTNode> subQueries = SubQueryUtils.findSubQueries(clonedSearchCond); for(int i=0; i<subQueriesInOriginalTree.size(); i++){
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
@Override /** Make sure even imaginary nodes know the input stream */ public Object create(int tokenType, String text) { GrammarAST t; if ( tokenType==ANTLRParser.RULE ) { // needed by TreeWizard to make RULE tree t = new RuleAST(new CommonToken(tokenType, text)); } else if ( tokenType==ANTLRParser.STRING_LITERAL ) { // implicit lexer construction done with wizard; needs this node type // whereas grammar ANTLRParser.g can use token option to spec node type t = new TerminalAST(new CommonToken(tokenType, text)); } else { t = (GrammarAST)super.create(tokenType, text); } t.token.setInputStream(input); return t; }
ASTNode clonedSearchCond = (ASTNode) SubQueryUtils.adaptor.dupTree(searchCond); List<ASTNode> subQueries = SubQueryUtils.findSubQueries(clonedSearchCond);
public JTreeASTModel(Object root) { this.adaptor = new CommonTreeAdaptor(); this.root = root; }
@Override /** Make sure even imaginary nodes know the input stream */ public Object create(int tokenType, String text) { GrammarAST t; if ( tokenType==ANTLRParser.RULE ) { // needed by TreeWizard to make RULE tree t = new RuleAST(new CommonToken(tokenType, text)); } else if ( tokenType==ANTLRParser.STRING_LITERAL ) { // implicit lexer construction done with wizard; needs this node type // whereas grammar ANTLRParser.g can use token option to spec node type t = new TerminalAST(new CommonToken(tokenType, text)); } else { t = (GrammarAST)super.create(tokenType, text); } t.token.setInputStream(input); return t; }
ASTNode clonedSearchCond = (ASTNode) SubQueryUtils.adaptor.dupTree(searchCond); List<ASTNode> subQueries = SubQueryUtils.findSubQueries(clonedSearchCond);
public BufferedTreeNodeStream(Object tree) { this(new CommonTreeAdaptor(), tree); }