本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}