/** * Checks if the specified line is a single-line comment without code. * @param lineNo the line number to check * @return if the specified line consists of only a single line comment * without code. **/ public boolean lineIsComment(int lineNo) { return MATCH_SINGLELINE_COMMENT.matcher(line(lineNo)).matches(); }
/** * Returns the specified block comment as a String array. * @param startLineNo the starting line number * @param startColNo the starting column number * @param endLineNo the ending line number * @param endColNo the ending column number * @return block comment as an array **/ private String[] extractBlockComment(int startLineNo, int startColNo, int endLineNo, int endColNo) { final String[] returnValue; if (startLineNo == endLineNo) { returnValue = new String[1]; returnValue[0] = line(startLineNo - 1).substring(startColNo, endColNo + 1); } else { returnValue = new String[endLineNo - startLineNo + 1]; returnValue[0] = line(startLineNo - 1).substring(startColNo); for (int i = startLineNo; i < endLineNo; i++) { returnValue[i - startLineNo + 1] = line(i); } returnValue[returnValue.length - 1] = line(endLineNo - 1).substring(0, endColNo + 1); } return returnValue; }
/** * Report the location of a single line comment. * @param startLineNo the starting line number * @param startColNo the starting column number **/ public void reportSingleLineComment(int startLineNo, int startColNo) { final String line = line(startLineNo - 1); final String[] txt = {line.substring(startColNo)}; final Comment comment = new Comment(txt, startColNo, startLineNo, line.length() - 1); cppComments.put(startLineNo, comment); }
/** * Checks if the specified line is blank. * @param lineNo the line number to check * @return if the specified line consists only of tabs and spaces. **/ public boolean lineIsBlank(int lineNo) { return CommonUtil.isBlank(line(lineNo)); }
/** * Report the location of a block comment. * @param startLineNo the starting line number * @param startColNo the starting column number * @param endLineNo the ending line number * @param endColNo the ending column number **/ private void reportBlockComment(int startLineNo, int startColNo, int endLineNo, int endColNo) { final String[] cComment = extractBlockComment(startLineNo, startColNo, endLineNo, endColNo); final Comment comment = new Comment(cComment, startColNo, endLineNo, endColNo); // save the comment if (clangComments.containsKey(startLineNo)) { final List<TextBlock> entries = clangComments.get(startLineNo); entries.add(comment); } else { final List<TextBlock> entries = new ArrayList<>(); entries.add(comment); clangComments.put(startLineNo, entries); } // Remember if possible Javadoc comment final String firstLine = line(startLineNo - 1); if (firstLine.contains("/**") && !firstLine.contains("/**/")) { javadocComments.put(endLineNo - 1, comment); } }
/** * Checks if the specified line is a single-line comment without code. * @param lineNo the line number to check * @return if the specified line consists of only a single line comment * without code. **/ public boolean lineIsComment(int lineNo) { return MATCH_SINGLELINE_COMMENT.matcher(line(lineNo)).matches(); }
/** * Returns the specified block comment as a String array. * @param startLineNo the starting line number * @param startColNo the starting column number * @param endLineNo the ending line number * @param endColNo the ending column number * @return block comment as an array **/ private String[] extractBlockComment(int startLineNo, int startColNo, int endLineNo, int endColNo) { final String[] returnValue; if (startLineNo == endLineNo) { returnValue = new String[1]; returnValue[0] = line(startLineNo - 1).substring(startColNo, endColNo + 1); } else { returnValue = new String[endLineNo - startLineNo + 1]; returnValue[0] = line(startLineNo - 1).substring(startColNo); for (int i = startLineNo; i < endLineNo; i++) { returnValue[i - startLineNo + 1] = line(i); } returnValue[returnValue.length - 1] = line(endLineNo - 1).substring(0, endColNo + 1); } return returnValue; }
/** * Report the location of a single line comment. * @param startLineNo the starting line number * @param startColNo the starting column number **/ public void reportSingleLineComment(int startLineNo, int startColNo) { final String line = line(startLineNo - 1); final String[] txt = {line.substring(startColNo)}; final Comment comment = new Comment(txt, startColNo, startLineNo, line.length() - 1); cppComments.put(startLineNo, comment); }
/** * Checks if the specified line is blank. * @param lineNo the line number to check * @return if the specified line consists only of tabs and spaces. **/ public boolean lineIsBlank(int lineNo) { return CommonUtil.isBlank(line(lineNo)); }
/** * Report the location of a block comment. * @param startLineNo the starting line number * @param startColNo the starting column number * @param endLineNo the ending line number * @param endColNo the ending column number **/ private void reportBlockComment(int startLineNo, int startColNo, int endLineNo, int endColNo) { final String[] cComment = extractBlockComment(startLineNo, startColNo, endLineNo, endColNo); final Comment comment = new Comment(cComment, startColNo, endLineNo, endColNo); // save the comment if (clangComments.containsKey(startLineNo)) { final List<TextBlock> entries = clangComments.get(startLineNo); entries.add(comment); } else { final List<TextBlock> entries = new ArrayList<>(); entries.add(comment); clangComments.put(startLineNo, entries); } // Remember if possible Javadoc comment final String firstLine = line(startLineNo - 1); if (firstLine.contains("/**") && !firstLine.contains("/**/")) { javadocComments.put(endLineNo - 1, comment); } }