private static boolean isSuspiciousToken(SyntaxToken firstToken) { return SUSPICIOUS_TOKEN_VALUES.contains(firstToken.text()); } }
@Override public void visitToken(SyntaxToken syntaxToken) { executableLines.add(syntaxToken.line()); } }
@Override public void visitToken(SyntaxToken syntaxToken) { for (SyntaxTrivia trivia : syntaxToken.trivias()) { if (seenFirstToken) { handleCommentsForTrivia(trivia); } else { seenFirstToken = true; } } seenFirstToken = true; }
private void checkForReport(StatementTree statement, Tree startTree, Tree endTree, String name) { if (!(statement.is(Tree.Kind.BLOCK) || statement.firstToken().column() > startTree.firstToken().column())) { context.reportIssue(this, startTree, endTree, "Use indentation to denote the code conditionally executed by this \"" + name + "\".", Collections.singletonList(new JavaFileScannerContext.Location("", statement)), null); } } }
private static boolean containsDefaultCase(List<CaseLabelTree> labels) { for (CaseLabelTree caseLabel : labels) { if ("default".equals(caseLabel.caseOrDefaultKeyword().text())) { return true; } } return false; }
@Override public void visitToken(SyntaxToken syntaxToken) { executableLines.add(syntaxToken.line()); } }
private static boolean containsComment(BlockTree block) { return !block.closeBraceToken().trivias().isEmpty(); }
private void checkForReport(StatementTree statement, Tree startTree, Tree endTree, String name) { if (!(statement.is(Tree.Kind.BLOCK) || statement.firstToken().column() > startTree.firstToken().column())) { context.reportIssue(this, startTree, endTree, "Use indentation to denote the code conditionally executed by this \"" + name + "\".", Collections.singletonList(new JavaFileScannerContext.Location("", statement)), null); } } }
private static String getMessage(SyntaxToken expressionFirstToken, AssignmentExpressionTree aeTree) { if (isSingleNegationAssignment(expressionFirstToken, aeTree)) { return "Add a space between \"=\" and \"!\" to avoid confusion."; } return "Was \"" + expressionFirstToken.text() + "=\" meant instead?"; }
private List<? extends Tree> visitMethod(MethodTree tree) { BlockTree methodBody = tree.block(); if(methodBody != null) { // get the last TypeTree returnType = tree.returnType(); if(returnType == null || "void".equals(returnType.firstToken().text())) { executableLines.add(methodBody.closeBraceToken().line()); } return methodBody.body(); } return Collections.emptyList(); }