本文整理汇总了Java中org.antlr.v4.runtime.tree.ParseTree.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java ParseTree.getParent方法的具体用法?Java ParseTree.getParent怎么用?Java ParseTree.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.antlr.v4.runtime.tree.ParseTree
的用法示例。
在下文中一共展示了ParseTree.getParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNextSibling
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* Gets next sibling of ParseTree node.
* @param node ParseTree node
* @return next sibling of ParseTree node.
*/
private static ParseTree getNextSibling(ParseTree node) {
ParseTree nextSibling = null;
if (node.getParent() != null) {
final ParseTree parent = node.getParent();
int index = 0;
while (true) {
final ParseTree currentNode = parent.getChild(index);
if (currentNode.equals(node)) {
nextSibling = parent.getChild(index + 1);
break;
}
index++;
}
}
return nextSibling;
}
示例2: visitATTR_OPER_EXPR
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public String visitATTR_OPER_EXPR(ScimFilterParser.ATTR_OPER_EXPRContext ctx) {
logger.info(" FidoDeviceFilterVisitor.visitATTR_OPER_EXPR() ");
ParseTree parent = ctx.getParent();
while (parent != null) {
if (parent.getClass().getSimpleName().equalsIgnoreCase(ScimFilterParser.LBRAC_EXPR_RBRACContext.class.getSimpleName())) {
logger.info("********** PARENT = " + parent.getClass().getSimpleName());
String attrName = ((ScimFilterParser.LBRAC_EXPR_RBRACContext)parent).ATTRNAME() + "." + ctx.ATTRNAME().getText();
return attrOperCriteriaResolver(attrName, visit(ctx.operator()), visit(ctx.expression()));
} else {
parent = parent.getParent();
}
}
return attrOperCriteriaResolver(ctx.ATTRNAME().getText(), visit(ctx.operator()), visit(ctx.expression()));
}
示例3: visitATTR_OPER_CRITERIA
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public String visitATTR_OPER_CRITERIA(ScimFilterParser.ATTR_OPER_CRITERIAContext ctx) {
logger.info(" ScimGroupFilterVisitor.visitATTR_OPER_CRITERIA() ");
ParseTree parent = ctx.getParent();
while (parent != null) {
if (parent.getClass().getSimpleName().equalsIgnoreCase(ScimFilterParser.LBRAC_EXPR_RBRACContext.class.getSimpleName())) {
logger.info("********** PARENT = " + parent.getClass().getSimpleName());
String attrName = ((ScimFilterParser.LBRAC_EXPR_RBRACContext)parent).ATTRNAME() + "." + ctx.ATTRNAME().getText();
return attrOperCriteriaResolver(attrName, visit(ctx.operator()), visit(ctx.criteria()));
} else {
parent = parent.getParent();
}
}
return attrOperCriteriaResolver(ctx.ATTRNAME().getText(), visit(ctx.operator()), visit(ctx.criteria()));
}
示例4: visitATTR_OPER_EXPR
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public String visitATTR_OPER_EXPR(ScimFilterParser.ATTR_OPER_EXPRContext ctx) {
logger.info(" ScimGroupFilterVisitor.visitATTR_OPER_EXPR() ");
ParseTree parent = ctx.getParent();
while (parent != null) {
if (parent.getClass().getSimpleName().equalsIgnoreCase(ScimFilterParser.LBRAC_EXPR_RBRACContext.class.getSimpleName())) {
logger.info("********** PARENT = " + parent.getClass().getSimpleName());
String attrName = ((ScimFilterParser.LBRAC_EXPR_RBRACContext)parent).ATTRNAME() + "." + ctx.ATTRNAME().getText();
return attrOperCriteriaResolver(attrName, visit(ctx.operator()), visit(ctx.expression()));
} else {
parent = parent.getParent();
}
}
return attrOperCriteriaResolver(ctx.ATTRNAME().getText(), visit(ctx.operator()), visit(ctx.expression()));
}
示例5: visitATTR_OPER_CRITERIA
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public String visitATTR_OPER_CRITERIA(ScimFilterParser.ATTR_OPER_CRITERIAContext ctx) {
logger.info(" ScimPersonFilterVisitor.visitATTR_OPER_CRITERIA() ");
ParseTree parent = ctx.getParent();
while (parent != null) {
if (parent.getClass().getSimpleName().equalsIgnoreCase(ScimFilterParser.LBRAC_EXPR_RBRACContext.class.getSimpleName())) {
logger.info("********** PARENT = " + parent.getClass().getSimpleName());
String attrName = ((ScimFilterParser.LBRAC_EXPR_RBRACContext)parent).ATTRNAME() + "." + ctx.ATTRNAME().getText();
return attrOperCriteriaResolver(attrName, visit(ctx.operator()), visit(ctx.criteria()));
} else {
parent = parent.getParent();
}
}
return attrOperCriteriaResolver(ctx.ATTRNAME().getText(), visit(ctx.operator()), visit(ctx.criteria()));
}
示例6: visitATTR_OPER_EXPR
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public String visitATTR_OPER_EXPR(ScimFilterParser.ATTR_OPER_EXPRContext ctx) {
logger.info(" ScimPersonFilterVisitor.visitATTR_OPER_EXPR() ");
ParseTree parent = ctx.getParent();
while (parent != null) {
if (parent.getClass().getSimpleName().equalsIgnoreCase(ScimFilterParser.LBRAC_EXPR_RBRACContext.class.getSimpleName())) {
logger.info("********** PARENT = " + parent.getClass().getSimpleName());
String attrName = ((ScimFilterParser.LBRAC_EXPR_RBRACContext)parent).ATTRNAME() + "." + ctx.ATTRNAME().getText();
return attrOperCriteriaResolver(attrName, visit(ctx.operator()), visit(ctx.expression()));
} else {
parent = parent.getParent();
}
}
return attrOperCriteriaResolver(ctx.ATTRNAME().getText(), visit(ctx.operator()), visit(ctx.expression()));
}
示例7: visitATTR_OPER_CRITERIA
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public String visitATTR_OPER_CRITERIA(ScimFilterParser.ATTR_OPER_CRITERIAContext ctx) {
logger.info(" UserFilterVisitor.visitATTR_OPER_CRITERIA() ");
ParseTree parent = ctx.getParent();
while (parent != null) {
if (parent.getClass().getSimpleName().equalsIgnoreCase(ScimFilterParser.LBRAC_EXPR_RBRACContext.class.getSimpleName())) {
logger.info("********** PARENT = " + parent.getClass().getSimpleName());
String attrName = ((ScimFilterParser.LBRAC_EXPR_RBRACContext)parent).ATTRNAME() + "." + ctx.ATTRNAME().getText();
return attrOperCriteriaResolver(attrName, visit(ctx.operator()), visit(ctx.criteria()));
} else {
parent = parent.getParent();
}
}
return attrOperCriteriaResolver(ctx.ATTRNAME().getText(), visit(ctx.operator()), visit(ctx.criteria()));
}
示例8: visitATTR_OPER_EXPR
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* <p>
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public String visitATTR_OPER_EXPR(ScimFilterParser.ATTR_OPER_EXPRContext ctx) {
logger.info(" UserFilterVisitor.visitATTR_OPER_EXPR() ");
ParseTree parent = ctx.getParent();
while (parent != null) {
if (parent.getClass().getSimpleName().equalsIgnoreCase(ScimFilterParser.LBRAC_EXPR_RBRACContext.class.getSimpleName())) {
logger.info("********** PARENT = " + parent.getClass().getSimpleName());
String attrName = ((ScimFilterParser.LBRAC_EXPR_RBRACContext)parent).ATTRNAME() + "." + ctx.ATTRNAME().getText();
return attrOperCriteriaResolver(attrName, visit(ctx.operator()), visit(ctx.expression()));
} else {
parent = parent.getParent();
}
}
return attrOperCriteriaResolver(ctx.ATTRNAME().getText(), visit(ctx.operator()), visit(ctx.expression()));
}
示例9: closestAncestor
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public static ParseTree closestAncestor(Class nodeType, ParseTree node) {
while(node != null) {
if(nodeType.isInstance(node)) return node;
node = node.getParent();
}
return null;
}
示例10: up
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
protected final ParseTree up(ParseTree tree) {
ParseTree parent = tree.getParent();
// Needed because of the way the ANTLR rules have been defined.
if (parent instanceof UserAgentParser.ProductNameContext ||
parent instanceof UserAgentParser.ProductVersionContext ||
parent instanceof UserAgentParser.ProductVersionWithCommasContext
) {
return up(parent);
}
return parent;
}
示例11: getChildIndexOrListMembership
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
/** Return the index 0..n-1 of t as child of t.parent.
* If t is index 0, always return 0.
* If t is a repeated subtree root and index within
* sibling list > 0, return CHILD_INDEX_LIST_ELEMENT.
* In all other cases, return the actual index of t. That means for a
* sibling list starting at child index 5, the first sibling will return
* 5 but 2nd and beyond in list will return CHILD_INDEX_LIST_ELEMENT.
*/
public static int getChildIndexOrListMembership(ParseTree t) {
if ( t==null ) return -1;
ParseTree parent = t.getParent();
if ( parent==null ) {
return -1;
}
// we know we have a parent now
// check to see if we are 2nd or beyond element in a sibling list
if ( t instanceof ParserRuleContext ) {
List<ParserRuleContext> siblings =
((ParserRuleContext)parent).getRuleContexts(((ParserRuleContext)t).getClass());
if ( siblings.size()>1 && siblings.indexOf(t)>0 ) {
return CHILD_INDEX_REPEATED_ELEMENT;
}
}
// check to see if we are 2nd or beyond repeated token
if ( t instanceof TerminalNode ) {
List<TerminalNode> repeatedTokens =
((ParserRuleContext) parent).getTokens(((TerminalNode) t).getSymbol().getType());
if ( repeatedTokens.size()>1 && repeatedTokens.indexOf(t)>0 ) {
return CHILD_INDEX_REPEATED_ELEMENT;
}
}
return getChildIndex(t);
}
示例12: findNearestAncestorBlock
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public ParseTree findNearestAncestorBlock(ParseTree node) {
boolean isBlock =
node instanceof SwiftParser.Top_levelContext ||
node instanceof SwiftParser.Code_blockContext ||
node instanceof SwiftParser.Closure_expressionContext ||
node instanceof SwiftParser.Explicit_closure_expressionContext ||
isStructureBlock(node);
if(isBlock) return node;
if(node == null || node.getParent() == null || node.getParent() == node) return null;
return findNearestAncestorBlock(node.getParent());
}
示例13: findNearestAncestorFunctionBlock
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
public ParseTree findNearestAncestorFunctionBlock(ParseTree node) {
boolean isBlock =
node instanceof SwiftParser.Top_levelContext ||
node instanceof SwiftParser.Function_bodyContext ||
node instanceof SwiftParser.Initializer_bodyContext;
if(isBlock) return node;
if(node == null || node.getParent() == null || node.getParent() == node) return null;
return findNearestAncestorFunctionBlock(node.getParent());
}
示例14: getControlFlowParent
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
@Override
public IParsedNode getControlFlowParent() {
if (this.item == null) {
return new ParsedNode(null);
}
ParseTree parent1 = item.getParent();
while (parent1 != null) {
if (parent1 instanceof Cfl_statementContext) {
return new ParsedNode(parent1);
}
parent1 = parent1.getParent();
}
return new ParsedNode(null);
}
示例15: findNearestAncestorBlock
import org.antlr.v4.runtime.tree.ParseTree; //导入方法依赖的package包/类
private ParseTree findNearestAncestorBlock(ParseTree node) {
boolean isBlock = node instanceof ECMAScriptParser.ProgramContext || node instanceof ECMAScriptParser.ConciseBodyContext || node instanceof ECMAScriptParser.BlockContext || /*NERVOUS*/node instanceof ECMAScriptParser.CaseClauseContext;
if(isBlock) return node;
if(node == null || node.getParent() == null || node.getParent() == node) return null;
return findNearestAncestorBlock(node.getParent());
}