本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.DetailNode.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java DetailNode.getParent方法的具体用法?Java DetailNode.getParent怎么用?Java DetailNode.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.puppycrawl.tools.checkstyle.api.DetailNode
的用法示例。
在下文中一共展示了DetailNode.getParent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: containsInBranch
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Checks whether node contains any node of specified type among children on any deep level.
*
* @param node DetailNode
* @param type token type
* @return true if node contains any node of type type among children on any deep level.
*/
public static boolean containsInBranch(DetailNode node, int type) {
boolean result = true;
DetailNode curNode = node;
while (type != curNode.getType()) {
DetailNode toVisit = getFirstChild(curNode);
while (curNode != null && toVisit == null) {
toVisit = getNextSibling(curNode);
if (toVisit == null) {
curNode = curNode.getParent();
}
}
if (curNode == toVisit) {
result = false;
break;
}
curNode = toVisit;
}
return result;
}
示例2: walk
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Processes a node calling Check at interested nodes.
* @param root
* the root of tree for process
*/
private void walk(DetailNode root) {
DetailNode curNode = root;
while (curNode != null) {
boolean waitsForProcessing = shouldBeProcessed(curNode);
if (waitsForProcessing) {
visitJavadocToken(curNode);
}
DetailNode toVisit = JavadocUtils.getFirstChild(curNode);
while (curNode != null && toVisit == null) {
if (waitsForProcessing) {
leaveJavadocToken(curNode);
}
toVisit = JavadocUtils.getNextSibling(curNode);
if (toVisit == null) {
curNode = curNode.getParent();
if (curNode != null) {
waitsForProcessing = shouldBeProcessed(curNode);
}
}
}
curNode = toVisit;
}
}
示例3: walk
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Processes a node calling Check at interested nodes.
* @param root
* the root of tree for process
*/
private void walk(DetailNode root) {
DetailNode curNode = root;
while (curNode != null) {
boolean waitsForProcessing = shouldBeProcessed(curNode);
if (waitsForProcessing) {
visitJavadocToken(curNode);
}
DetailNode toVisit = JavadocUtils.getFirstChild(curNode);
while (curNode != null && toVisit == null) {
if (waitsForProcessing) {
leaveJavadocToken(curNode);
}
toVisit = JavadocUtils.getNextSibling(curNode);
if (toVisit == null) {
curNode = curNode.getParent();
if (curNode != null) {
waitsForProcessing = shouldBeProcessed(curNode);
}
}
}
curNode = toVisit;
}
}
示例4: isInlineDescription
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Checks, if description node is a description of in-line tag.
* @param description DESCRIPTION node.
* @return true, if description node is a description of in-line tag.
*/
private static boolean isInlineDescription(DetailNode description) {
boolean isInline = false;
DetailNode inlineTag = description.getParent();
while (inlineTag != null) {
if (inlineTag.getType() == JavadocTokenTypes.JAVADOC_INLINE_TAG) {
isInline = true;
break;
}
inlineTag = inlineTag.getParent();
}
return isInline;
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:JavadocTagContinuationIndentationCheck.java
示例5: getIndentation
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Get indentation for a node.
* @param node the DetailNode to get the indentation for.
* @return the indentation in String format.
*/
private static String getIndentation(DetailNode node) {
final boolean isLastChild = JavadocUtils.getNextSibling(node) == null;
DetailNode currentNode = node;
final StringBuilder indentation = new StringBuilder(1024);
while (currentNode.getParent() != null) {
currentNode = currentNode.getParent();
if (currentNode.getParent() == null) {
if (isLastChild) {
// only ASCII symbols must be used due to
// problems with running tests on Windows
indentation.append("`--");
}
else {
indentation.append("|--");
}
}
else {
if (JavadocUtils.getNextSibling(currentNode) == null) {
indentation.insert(0, " ");
}
else {
indentation.insert(0, "| ");
}
}
}
return indentation.toString();
}
示例6: getNextSibling
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Gets next sibling of specified node.
*
* @param node DetailNode
* @return next sibling.
*/
public static DetailNode getNextSibling(DetailNode node) {
DetailNode nextSibling = null;
final DetailNode parent = node.getParent();
if (parent != null) {
final int nextSiblingIndex = node.getIndex() + 1;
final DetailNode[] children = parent.getChildren();
if (nextSiblingIndex <= children.length - 1) {
nextSibling = children[nextSiblingIndex];
}
}
return nextSibling;
}
示例7: getPreviousSibling
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Gets previous sibling of specified node.
* @param node DetailNode
* @return previous sibling
*/
public static DetailNode getPreviousSibling(DetailNode node) {
DetailNode previousSibling = null;
final int previousSiblingIndex = node.getIndex() - 1;
if (previousSiblingIndex >= 0) {
final DetailNode parent = node.getParent();
final DetailNode[] children = parent.getChildren();
previousSibling = children[previousSiblingIndex];
}
return previousSibling;
}
示例8: getLevel
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
private static String getLevel(DetailNode aNode)
{
DetailNode parent = aNode;
String level = "";
while (parent.getParent() != null) {
parent = parent.getParent();
if (parent.getParent() != null) {
level = level + " ";
}
else {
level = level + PREFIX;
}
}
return level;
}