/** * Returns the line associated with the tree. * @param index index of the line * @return the line from the file contents */ public final String getLine(int index) { return context.get().fileContents.getLine(index); }
/** * Returns the line associated with the tree. * @param index index of the line * @return the line from the file contents */ public final String getLine(int index) { return context.get().fileContents.getLine(index); }
/** * Determines the number semicolons in a method excluding those in * comments. * @param method Method to count * @return The number of semicolons in the method as an int */ private int countSemiColons(final DetailAST method) { final DetailAST openingbrace = method.findFirstToken(TokenTypes.SLIST); int count = 0; if (openingbrace != null) { final DetailAST closingbrace = openingbrace.findFirstToken(TokenTypes.RCURLY); final int lastline = closingbrace.getLineNo(); final int firstline = openingbrace.getLineNo(); final FileContents contents = this.getFileContents(); for (int line = firstline - 1; line < lastline; line += 1) { if (!contents.lineIsBlank(line) && !contents.lineIsComment(line) && contents.getLine(line).contains(";")) { count += 1; } } } return count; } }
/** * Determines the number semicolons in a method excluding those in * comments. * @param method Method to count * @return The number of semicolons in the method as an int */ private int countSemiColons(final DetailAST method) { final DetailAST openingbrace = method.findFirstToken(TokenTypes.SLIST); int count = 0; if (openingbrace != null) { final DetailAST closingbrace = openingbrace.findFirstToken(TokenTypes.RCURLY); final int lastline = closingbrace.getLineNo(); final int firstline = openingbrace.getLineNo(); final FileContents contents = this.getFileContents(); for (int line = firstline - 1; line < lastline; line += 1) { if (!contents.lineIsBlank(line) && !contents.lineIsComment(line) && contents.getLine(line).contains(";")) { count += 1; } } } return count; } }