use of com.puppycrawl.tools.checkstyle.api.DetailNode in project checkstyle by checkstyle.
the class SingleLineJavadocCheck method hasJavadocInlineTags.
/**
* Checks if comment has in-line tags which are not ignored.
*
* @param javadocRoot javadoc root node.
* @return true, if comment has in-line tags which are not ignored.
* @see <a href=
* http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#javadoctags>
* JavadocTags</a>
*/
private boolean hasJavadocInlineTags(DetailNode javadocRoot) {
DetailNode javadocTagSection = JavadocUtils.findFirstToken(javadocRoot, JavadocTokenTypes.JAVADOC_INLINE_TAG);
boolean foundTag = false;
while (javadocTagSection != null) {
if (!isTagIgnored(javadocTagSection)) {
foundTag = true;
break;
}
javadocTagSection = JavadocUtils.getNextSibling(javadocTagSection, JavadocTokenTypes.JAVADOC_INLINE_TAG);
}
return foundTag;
}
use of com.puppycrawl.tools.checkstyle.api.DetailNode in project checkstyle by checkstyle.
the class SummaryJavadocCheck method getFirstSentence.
/**
* Finds and returns first sentence.
* @param ast Javadoc root node.
* @return first sentence.
*/
private static String getFirstSentence(DetailNode ast) {
final StringBuilder result = new StringBuilder();
final String periodSuffix = PERIOD + ' ';
for (DetailNode child : ast.getChildren()) {
final String text = child.getText();
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();
}
use of com.puppycrawl.tools.checkstyle.api.DetailNode in project checkstyle by checkstyle.
the class CodeSelectorPresentationTest method testDetailNodeLeafSelection.
@Test
public void testDetailNodeLeafSelection() {
final DetailNode javadoc = (DetailNode) model.getParseTreeTableModel().getChild(tree.getFirstChild().getNextSibling().getFirstChild(), 0);
final DetailNode javadocLeaf = javadoc.getChildren()[2];
final CodeSelectorPresentation selector = new CodeSelectorPresentation(javadocLeaf, linesToPosition);
selector.findSelectionPositions();
Assert.assertEquals(5, selector.getSelectionStart());
Assert.assertEquals(19, selector.getSelectionEnd());
}
use of com.puppycrawl.tools.checkstyle.api.DetailNode in project checkstyle by checkstyle.
the class ParseTreeTablePresentationTest method testJavadocChild.
@Test
public void testJavadocChild() {
final DetailAST commentContentNode = tree.getFirstChild().getNextSibling().getFirstChild();
final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null);
parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS);
final Object javadoc = parseTree.getChild(commentContentNode, 0);
Assert.assertTrue(javadoc instanceof DetailNode);
Assert.assertEquals(JavadocTokenTypes.JAVADOC, ((DetailNode) javadoc).getType());
final Object javadocChild = parseTree.getChild(javadoc, 2);
Assert.assertTrue(javadocChild instanceof DetailNode);
Assert.assertEquals(JavadocTokenTypes.TEXT, ((DetailNode) javadocChild).getType());
}
use of com.puppycrawl.tools.checkstyle.api.DetailNode in project checkstyle by checkstyle.
the class CodeSelectorPresentationTest method testDetailNodeSelection.
@Test
public void testDetailNodeSelection() {
final DetailNode javadoc = (DetailNode) model.getParseTreeTableModel().getChild(tree.getFirstChild().getNextSibling().getFirstChild(), 0);
final CodeSelectorPresentation selector = new CodeSelectorPresentation(javadoc, linesToPosition);
selector.findSelectionPositions();
Assert.assertEquals(3, selector.getSelectionStart());
Assert.assertEquals(25, selector.getSelectionEnd());
}
Aggregations