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


Java DetailAST.equals方法代码示例

本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.DetailAST.equals方法的典型用法代码示例。如果您正苦于以下问题:Java DetailAST.equals方法的具体用法?Java DetailAST.equals怎么用?Java DetailAST.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.puppycrawl.tools.checkstyle.api.DetailAST的用法示例。


在下文中一共展示了DetailAST.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAllTokensOfType

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Collects all tokens of specific type starting with the current ast node.
 * @param ast ast node.
 * @param tokenType token type.
 * @return a set of all tokens of specific type starting with the current ast node.
 */
private static Set<DetailAST> getAllTokensOfType(DetailAST ast, int tokenType) {
    DetailAST vertex = ast;
    final Set<DetailAST> result = new HashSet<DetailAST>();
    final Deque<DetailAST> stack = new ArrayDeque<DetailAST>();
    while (vertex != null || !stack.isEmpty()) {
        if (!stack.isEmpty()) {
            vertex = stack.pop();
        }
        while (vertex != null) {
            if (vertex.getType() == tokenType && !vertex.equals(ast)) {
                result.add(vertex);
            }
            if (vertex.getNextSibling() != null) {
                stack.push(vertex.getNextSibling());
            }
            vertex = vertex.getFirstChild();
        }
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:27,代码来源:DeclarationOrderCheck.java

示例2: getAllTokensWhichAreEqualToCurrent

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Collects all tokens which are equal to current token starting with the current ast node and
 * which line number is lower or equal to the end line number.
 * @param ast ast node.
 * @param token token.
 * @param endLineNumber end line number.
 * @return a set of tokens which are equal to current token starting with the current ast node
 *         and which line number is lower or equal to the end line number.
 */
private static Set<DetailAST> getAllTokensWhichAreEqualToCurrent(DetailAST ast, DetailAST token,
                                                                 int endLineNumber) {
    DetailAST vertex = ast;
    final Set<DetailAST> result = new HashSet<DetailAST>();
    final Deque<DetailAST> stack = new ArrayDeque<DetailAST>();
    while (vertex != null || !stack.isEmpty()) {
        if (!stack.isEmpty()) {
            vertex = stack.pop();
        }
        while (vertex != null) {
            if (token.equals(vertex)
                    && vertex.getLineNo() <= endLineNumber) {
                result.add(vertex);
            }
            if (vertex.getNextSibling() != null) {
                stack.push(vertex.getNextSibling());
            }
            vertex = vertex.getFirstChild();
        }
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:32,代码来源:RequireThisCheck.java

示例3: isEndOfScope

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Checks line for end of scope.  Handles occurrences of close braces and close parenthesis on
 * the same line.
 *
 * @param lastAnnotationNode the last node of the annotation
 * @param node the node indicating where to begin checking
 * @return true if all the nodes up to the last annotation node are end of scope nodes
 *         false otherwise
 */
private static boolean isEndOfScope(final DetailAST lastAnnotationNode, final DetailAST node) {
    DetailAST checkNode = node;
    boolean endOfScope = true;
    while (endOfScope && !checkNode.equals(lastAnnotationNode)) {
        switch (checkNode.getType()) {
            case TokenTypes.RCURLY:
            case TokenTypes.RBRACK:
                while (checkNode.getNextSibling() == null) {
                    checkNode = checkNode.getParent();
                }
                checkNode = checkNode.getNextSibling();
                break;
            default:
                endOfScope = false;

        }

    }
    return endOfScope;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:30,代码来源:LineWrappingHandler.java

示例4: hasFinalField

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Checks whether given instance member has final modifier.
 * @param instanceMember an instance member of a class.
 * @return true if given instance member has final modifier.
 */
public boolean hasFinalField(final DetailAST instanceMember) {
    boolean result = false;
    for (DetailAST member : instanceMembers) {
        final DetailAST mods = member.getParent().findFirstToken(TokenTypes.MODIFIERS);
        final boolean finalMod = mods.findFirstToken(TokenTypes.FINAL) != null;
        if (finalMod && member.equals(instanceMember)) {
            result = true;
            break;
        }
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:RequireThisCheck.java


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