当前位置: 首页>>代码示例>>Java>>正文


Java ParseTree.getParent方法代码示例

本文整理汇总了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;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:23,代码来源:JavadocDetailNodeParser.java

示例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()));
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:31,代码来源:FidoDeviceFilterVisitor.java

示例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()));
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:31,代码来源:ScimGroupFilterVisitor.java

示例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()));
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:31,代码来源:ScimGroupFilterVisitor.java

示例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()));
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:31,代码来源:ScimPersonFilterVisitor.java

示例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()));
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:31,代码来源:ScimPersonFilterVisitor.java

示例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()));
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:31,代码来源:UserFilterVisitor.java

示例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()));
}
 
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:31,代码来源:UserFilterVisitor.java

示例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;
}
 
开发者ID:marcelganczak,项目名称:ts-swift-transpiler,代码行数:8,代码来源:WalkerUtil.java

示例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;
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:13,代码来源:Step.java

示例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);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:35,代码来源:Trainer.java

示例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());
}
 
开发者ID:marcelganczak,项目名称:swift-js-transpiler,代码行数:12,代码来源:Cache.java

示例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());
}
 
开发者ID:marcelganczak,项目名称:swift-js-transpiler,代码行数:10,代码来源:Cache.java

示例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);
}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:15,代码来源:ParsedNode.java

示例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());
}
 
开发者ID:marcelganczak,项目名称:ts-swift-transpiler,代码行数:7,代码来源:EntityCache.java


注:本文中的org.antlr.v4.runtime.tree.ParseTree.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。