本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.DetailNode.getType方法的典型用法代码示例。如果您正苦于以下问题:Java DetailNode.getType方法的具体用法?Java DetailNode.getType怎么用?Java DetailNode.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.puppycrawl.tools.checkstyle.api.DetailNode
的用法示例。
在下文中一共展示了DetailNode.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startsWithInheritDoc
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Checks if the node starts with an {@inheritDoc}.
* @param root The root node to examine.
* @return {@code true} if the javadoc starts with an {@inheritDoc}.
*/
private static boolean startsWithInheritDoc(DetailNode root) {
boolean found = false;
final DetailNode[] children = root.getChildren();
for (int i = 0; !found && i < children.length - 1; i++) {
final DetailNode child = children[i];
if (child.getType() == JavadocTokenTypes.JAVADOC_INLINE_TAG
&& child.getChildren()[1].getType() == JavadocTokenTypes.INHERIT_DOC_LITERAL) {
found = true;
}
else if (child.getType() != JavadocTokenTypes.LEADING_ASTERISK
&& !CommonUtils.isBlank(child.getText())) {
break;
}
}
return found;
}
示例2: getSummarySentence
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Checks if period is at the end of sentence.
* @param ast Javadoc root node.
* @return error string
*/
private static String getSummarySentence(DetailNode ast) {
boolean flag = true;
final StringBuilder result = new StringBuilder(256);
for (DetailNode child : ast.getChildren()) {
if (ALLOWED_TYPES.contains(child.getType())) {
result.append(child.getText());
}
else if (child.getType() == JavadocTokenTypes.HTML_ELEMENT
&& CommonUtils.isBlank(result.toString().trim())) {
result.append(getStringInsideTag(result.toString(),
child.getChildren()[0].getChildren()[0]));
}
else if (child.getType() == JavadocTokenTypes.JAVADOC_TAG) {
flag = false;
}
if (!flag) {
break;
}
}
return result.toString().trim();
}
示例3: getFirstSentence
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Finds and returns first sentence.
* @param ast Javadoc root node.
* @return first sentence.
*/
private static String getFirstSentence(DetailNode ast) {
final StringBuilder result = new StringBuilder(256);
final String periodSuffix = PERIOD + ' ';
for (DetailNode child : ast.getChildren()) {
final String text;
if (child.getChildren().length == 0) {
text = child.getText();
}
else {
text = getFirstSentence(child);
}
if (child.getType() != JavadocTokenTypes.JAVADOC_INLINE_TAG
&& text.contains(periodSuffix)) {
result.append(text.substring(0, text.indexOf(periodSuffix) + 1));
break;
}
else {
result.append(text);
}
}
return result.toString();
}
示例4: checkOrderInTagSection
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Checks order of atclauses in tag section node.
* @param javadoc Javadoc root node.
*/
private void checkOrderInTagSection(DetailNode javadoc) {
int maxIndexOfPreviousTag = 0;
for (DetailNode node : javadoc.getChildren()) {
if (node.getType() == JavadocTokenTypes.JAVADOC_TAG) {
final String tagText = JavadocUtils.getFirstChild(node).getText();
final int indexOfCurrentTag = tagOrder.indexOf(tagText);
if (indexOfCurrentTag != -1) {
if (indexOfCurrentTag < maxIndexOfPreviousTag) {
log(node.getLineNumber(), MSG_KEY, tagOrder.toString());
}
else {
maxIndexOfPreviousTag = indexOfCurrentTag;
}
}
}
}
}
示例5: isFirstParagraph
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Determines whether or not the line with paragraph tag is first line in javadoc.
* @param paragraphTag paragraph tag.
* @return true, if line with paragraph tag is first line in javadoc.
*/
private static boolean isFirstParagraph(DetailNode paragraphTag) {
boolean result = true;
DetailNode previousNode = JavadocUtils.getPreviousSibling(paragraphTag);
while (previousNode != null) {
if (previousNode.getType() == JavadocTokenTypes.TEXT
&& !CommonUtils.isBlank(previousNode.getText())
|| previousNode.getType() != JavadocTokenTypes.LEADING_ASTERISK
&& previousNode.getType() != JavadocTokenTypes.NEWLINE
&& previousNode.getType() != JavadocTokenTypes.TEXT) {
result = false;
break;
}
previousNode = JavadocUtils.getPreviousSibling(previousNode);
}
return result;
}
示例6: visitJavadocToken
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
@Override
public void visitJavadocToken(DetailNode ast) {
if (!isInlineDescription(ast)) {
final List<DetailNode> textNodes = getAllNewlineNodes(ast);
for (DetailNode newlineNode : textNodes) {
final DetailNode textNode = JavadocUtils.getNextSibling(JavadocUtils
.getNextSibling(newlineNode));
if (textNode != null && textNode.getType() == JavadocTokenTypes.TEXT) {
final String text = textNode.getText();
if (!CommonUtils.isBlank(text.trim())
&& (text.length() <= offset
|| !text.substring(1, offset + 1).trim().isEmpty())) {
log(textNode.getLineNumber(), MSG_KEY, offset);
}
}
}
}
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:JavadocTagContinuationIndentationCheck.java
示例7: printTree
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Print AST.
* @param ast the root AST node.
* @param rootPrefix prefix for the root node
* @param prefix prefix for other nodes
* @return string AST.
*/
public static String printTree(DetailNode ast, String rootPrefix, String prefix) {
final StringBuilder messageBuilder = new StringBuilder(1024);
DetailNode node = ast;
while (node != null) {
if (node.getType() == JavadocTokenTypes.JAVADOC) {
messageBuilder.append(rootPrefix);
}
else {
messageBuilder.append(prefix);
}
messageBuilder.append(getIndentation(node))
.append(JavadocUtils.getTokenName(node.getType())).append(" -> ")
.append(JavadocUtils.escapeAllControlChars(node.getText())).append(" [")
.append(node.getLineNumber()).append(':').append(node.getColumnNumber())
.append(']').append(LINE_SEPARATOR)
.append(printTree(JavadocUtils.getFirstChild(node), rootPrefix, prefix));
node = JavadocUtils.getNextSibling(node);
}
return messageBuilder.toString();
}
示例8: 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;
}
示例9: printTree
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
public static void printTree(DetailNode aRoot)
{
if (aRoot.getChildren().length != 0) {
for (DetailNode node : aRoot.getChildren()) {
System.out.println(getLevel(node) + node.toString()
+ " : ["
+ node.getText().replaceAll("\n", "\\\\n").replaceAll("\r", "\\\\r")
.replaceAll("\t", "\\\\t")
+ "]");
if (node.getType() == JavadocTokenTypes.TEXT) {
continue;
}
printTree(node);
}
}
}
示例10: getStringInsideTag
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Concatenates string within text of html tags.
* @param result javadoc string
* @param detailNode javadoc tag node
* @return java doc tag content appended in result
*/
private static String getStringInsideTag(String result, DetailNode detailNode) {
final StringBuilder contents = new StringBuilder(result);
DetailNode tempNode = detailNode;
while (tempNode != null) {
if (tempNode.getType() == JavadocTokenTypes.TEXT) {
contents.append(tempNode.getText());
}
tempNode = JavadocUtils.getNextSibling(tempNode);
}
return contents.toString();
}
示例11: visitJavadocToken
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
@Override
public void visitJavadocToken(DetailNode ast) {
if (ast.getType() == JavadocTokenTypes.NEWLINE && isEmptyLine(ast)) {
checkEmptyLine(ast);
}
else if (ast.getType() == JavadocTokenTypes.HTML_ELEMENT
&& JavadocUtils.getFirstChild(ast).getType() == JavadocTokenTypes.P_TAG_START) {
checkParagraphTag(ast);
}
}
示例12: checkEmptyLine
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Determines whether or not the next line after empty line has paragraph tag in the beginning.
* @param newline NEWLINE node.
*/
private void checkEmptyLine(DetailNode newline) {
final DetailNode nearestToken = getNearestNode(newline);
if (!isLastEmptyLine(newline) && nearestToken.getType() == JavadocTokenTypes.TEXT
&& !CommonUtils.isBlank(nearestToken.getText())) {
log(newline.getLineNumber(), MSG_TAG_AFTER);
}
}
示例13: getNearestNode
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Returns nearest node.
* @param node DetailNode node.
* @return nearest node.
*/
private static DetailNode getNearestNode(DetailNode node) {
DetailNode tag = JavadocUtils.getNextSibling(node);
while (tag.getType() == JavadocTokenTypes.LEADING_ASTERISK
|| tag.getType() == JavadocTokenTypes.NEWLINE) {
tag = JavadocUtils.getNextSibling(tag);
}
return tag;
}
示例14: isEmptyLine
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Determines whether or not the line is empty line.
* @param newLine NEWLINE node.
* @return true, if line is empty line.
*/
private static boolean isEmptyLine(DetailNode newLine) {
boolean result = false;
DetailNode previousSibling = JavadocUtils.getPreviousSibling(newLine);
if (previousSibling != null
&& previousSibling.getParent().getType() == JavadocTokenTypes.JAVADOC) {
if (previousSibling.getType() == JavadocTokenTypes.TEXT
&& CommonUtils.isBlank(previousSibling.getText())) {
previousSibling = JavadocUtils.getPreviousSibling(previousSibling);
}
result = previousSibling != null
&& previousSibling.getType() == JavadocTokenTypes.LEADING_ASTERISK;
}
return result;
}
示例15: getNearestEmptyLine
import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
* Finds and returns nearest empty line in javadoc.
* @param node DetailNode node.
* @return Some nearest empty line in javadoc.
*/
private static DetailNode getNearestEmptyLine(DetailNode node) {
DetailNode newLine = JavadocUtils.getPreviousSibling(node);
while (newLine != null) {
final DetailNode previousSibling = JavadocUtils.getPreviousSibling(newLine);
if (newLine.getType() == JavadocTokenTypes.NEWLINE && isEmptyLine(newLine)) {
break;
}
newLine = previousSibling;
}
return newLine;
}