/** * Checks if given comment is legal (single-line and matches to the * pattern). * @param comment comment to check. * @return true if the comment if legal. */ private boolean isLegalComment(final TextBlock comment) { final boolean legal; // multi-line comment can not be legal if (legalComment == null || comment.getStartLineNo() != comment.getEndLineNo()) { legal = false; } else { String commentText = comment.getText()[0]; // remove chars which start comment commentText = commentText.substring(2); // if this is a C-style comment we need to remove its end if (commentText.endsWith("*/")) { commentText = commentText.substring(0, commentText.length() - 2); } commentText = commentText.trim(); legal = legalComment.matcher(commentText).find(); } return legal; }
/** * Checks that the Javadoc is not empty. * * @param comment the source lines that make up the Javadoc comment. */ private void checkJavadocIsNotEmpty(TextBlock comment) { final String commentText = getCommentText(comment.getText()); if (commentText.isEmpty()) { log(comment.getStartLineNo(), MSG_EMPTY); } }
/** * Checks that the first sentence ends with proper punctuation. This method * uses a regular expression that checks for the presence of a period, * question mark, or exclamation mark followed either by whitespace, an * HTML element, or the end of string. This method ignores {_AT_inheritDoc} * comments for TokenTypes that are valid for {_AT_inheritDoc}. * * @param ast the current node * @param comment the source lines that make up the Javadoc comment. */ private void checkFirstSentenceEnding(final DetailAST ast, TextBlock comment) { final String commentText = getCommentText(comment.getText()); if (!commentText.isEmpty() && !endOfSentenceFormat.matcher(commentText).find() && !(commentText.startsWith("{@inheritDoc}") && JavadocTagInfo.INHERIT_DOC.isValidOn(ast))) { log(comment.getStartLineNo(), MSG_NO_PERIOD); } }
if (javadoc != null) { final String[] lines = javadoc.getText(); int currentLine = javadoc.getStartLineNo() - 1;
/** * Appends the suppressions in a collection of comments to the full * set of suppression tags. * @param comments the set of comments. */ private void tagSuppressions(Collection<TextBlock> comments) { for (final TextBlock comment : comments) { final int startLineNo = comment.getStartLineNo(); final String[] text = comment.getText(); tagCommentLine(text[0], startLineNo); for (int i = 1; i < text.length; i++) { tagCommentLine(text[i], startLineNo + i); } } }
final String[] lines = comment.getText(); final List<JavadocTag> tags = new ArrayList<>(); int currentLine = comment.getStartLineNo() - 1; final int startColumnNumber = comment.getStartColNo();
/** * Appends the suppressions in a collection of comments to the full * set of suppression tags. * @param comments the set of comments. */ private void tagSuppressions(Collection<TextBlock> comments) { for (TextBlock comment : comments) { final int startLineNo = comment.getStartLineNo(); final String[] text = comment.getText(); tagCommentLine(text[0], startLineNo, comment.getStartColNo()); for (int i = 1; i < text.length; i++) { tagCommentLine(text[i], startLineNo + i, 0); } } }
content = content.substring(0, content.length() - 2); final int line = aCmt.getStartLineNo() + i; int col = blockTagMatcher.start(1) - 1; if (i == 0) { final String tagName = tagMatcher.group(1); final String tagValue = tagMatcher.group(2).trim(); final int line = aCmt.getStartLineNo() + i; int col = commentOffset + (tagMatcher.start(1) - 1); if (i == 0) {
final int line = textBlock.getStartLineNo() + tag.getPosition().getLine() - 1;
final int lineNo = comment.getStartLineNo(); final Deque<HtmlTag> htmlStack = new ArrayDeque<>(); final String[] text = comment.getText();
private void checkParamTags(TextBlock javadoc) { String[] text = javadoc.getText(); for (int i = 0; i < text.length; i++) { for (Pattern pattern : PATTERNS) { Matcher matcher = pattern.matcher(text[i]); if (matcher.find()) { String description = matcher.group(1).trim(); if (startsWithUppercase(description)) { log(javadoc.getStartLineNo() + i, text[i].length() - description.length(), "javadoc.badCase"); } } } } }
/** * Checks if given comment is legal (single-line and matches to the * pattern). * @param comment comment to check. * @return true if the comment if legal. */ private boolean isLegalComment(final TextBlock comment) { final boolean legal; // multi-line comment can not be legal if (legalComment == null || comment.getStartLineNo() != comment.getEndLineNo()) { legal = false; } else { String commentText = comment.getText()[0]; // remove chars which start comment commentText = commentText.substring(2); // if this is a C-style comment we need to remove its end if (commentText.endsWith("*/")) { commentText = commentText.substring(0, commentText.length() - 2); } commentText = commentText.trim(); legal = legalComment.matcher(commentText).find(); } return legal; }
/** * Checks that the Javadoc is not empty. * * @param comment the source lines that make up the Javadoc comment. */ private void checkJavadocIsNotEmpty(TextBlock comment) { final String commentText = getCommentText(comment.getText()); if (commentText.isEmpty()) { log(comment.getStartLineNo(), MSG_EMPTY); } }
/** * Checks that the first sentence ends with proper punctuation. This method * uses a regular expression that checks for the presence of a period, * question mark, or exclamation mark followed either by whitespace, an * HTML element, or the end of string. This method ignores {_AT_inheritDoc} * comments for TokenTypes that are valid for {_AT_inheritDoc}. * * @param ast the current node * @param comment the source lines that make up the Javadoc comment. */ private void checkFirstSentenceEnding(final DetailAST ast, TextBlock comment) { final String commentText = getCommentText(comment.getText()); if (!commentText.isEmpty() && !endOfSentenceFormat.matcher(commentText).find() && !(commentText.startsWith("{@inheritDoc}") && JavadocTagInfo.INHERIT_DOC.isValidOn(ast))) { log(comment.getStartLineNo(), MSG_NO_PERIOD); } }
if (javadoc != null) { final String[] lines = javadoc.getText(); int currentLine = javadoc.getStartLineNo() - 1;
/** * Appends the suppressions in a collection of comments to the full * set of suppression tags. * @param comments the set of comments. */ private void tagSuppressions(Collection<TextBlock> comments) { for (final TextBlock comment : comments) { final int startLineNo = comment.getStartLineNo(); final String[] text = comment.getText(); tagCommentLine(text[0], startLineNo); for (int i = 1; i < text.length; i++) { tagCommentLine(text[i], startLineNo + i); } } }
final String[] lines = comment.getText(); final List<JavadocTag> tags = new ArrayList<>(); int currentLine = comment.getStartLineNo() - 1; final int startColumnNumber = comment.getStartColNo();
final String[] lines = comment.getText(); final List<JavadocTag> tags = new LinkedList<>(); int current = comment.getStartLineNo() - 1; final int start = comment.getStartColNo(); for (int line = 0; line < lines.length; line = line + 1) {
/** * Appends the suppressions in a collection of comments to the full * set of suppression tags. * @param comments the set of comments. */ private void tagSuppressions(Collection<TextBlock> comments) { for (TextBlock comment : comments) { final int startLineNo = comment.getStartLineNo(); final String[] text = comment.getText(); tagCommentLine(text[0], startLineNo, comment.getStartColNo()); for (int i = 1; i < text.length; i++) { tagCommentLine(text[i], startLineNo + i, 0); } } }
final int line = textBlock.getStartLineNo() + tag.getPosition().getLine() - 1;