private static AnalyzerMessage.TextSpan textSpanBetween(SyntaxToken firstSyntaxToken, SyntaxToken lastSyntaxToken) { AnalyzerMessage.TextSpan location = new AnalyzerMessage.TextSpan( firstSyntaxToken.line(), firstSyntaxToken.column(), lastSyntaxToken.line(), lastSyntaxToken.column() + lastSyntaxToken.text().length() ); Preconditions.checkState(!location.isEmpty(), "Invalid issue location: Text span is empty when trying reporting on (l:%s, c:%s).", firstSyntaxToken.line(), firstSyntaxToken.column()); return location; }
private static AnalyzerMessage.TextSpan textSpanBetween(SyntaxToken firstSyntaxToken, SyntaxToken lastSyntaxToken) { AnalyzerMessage.TextSpan location = new AnalyzerMessage.TextSpan( firstSyntaxToken.line(), firstSyntaxToken.column(), lastSyntaxToken.line(), lastSyntaxToken.column() + lastSyntaxToken.text().length() ); Preconditions.checkState(!location.isEmpty(), "Invalid issue location: Text span is empty when trying reporting on (l:%s, c:%s).", firstSyntaxToken.line(), firstSyntaxToken.column()); return location; }
private static boolean isAlignedWith(SyntaxToken operatorToken, Tree other) { SyntaxToken otherOperator = operatorToken(other); return otherOperator.text().equals(operatorToken.text()) && operatorToken.column() == otherOperator.column() // less than 2 lines distance && Math.abs(operatorToken.line() - otherOperator.line()) < 2; }
private static boolean isAlignedWith(SyntaxToken operatorToken, Tree other) { SyntaxToken otherOperator = operatorToken(other); return otherOperator.text().equals(operatorToken.text()) && operatorToken.column() == otherOperator.column() // less than 2 lines distance && Math.abs(operatorToken.line() - otherOperator.line()) < 2; }
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 void createSymbol(IdentifierTree declaration, List<IdentifierTree> usages) { SyntaxToken syntaxToken = declaration.identifierToken(); NewSymbol newSymbol = newSymbolTable.newSymbol(syntaxToken.line(), syntaxToken.column(), syntaxToken.line(), syntaxToken.text().length() + syntaxToken.column()); for (IdentifierTree usage : usages) { syntaxToken = usage.identifierToken(); newSymbol.newReference(syntaxToken.line(), syntaxToken.column(), syntaxToken.line(), syntaxToken.text().length() + syntaxToken.column()); } }
private void createSymbol(IdentifierTree declaration, List<IdentifierTree> usages) { SyntaxToken syntaxToken = declaration.identifierToken(); NewSymbol newSymbol = newSymbolTable.newSymbol(syntaxToken.line(), syntaxToken.column(), syntaxToken.line(), syntaxToken.text().length() + syntaxToken.column()); for (IdentifierTree usage : usages) { syntaxToken = usage.identifierToken(); newSymbol.newReference(syntaxToken.line(), syntaxToken.column(), syntaxToken.line(), syntaxToken.text().length() + syntaxToken.column()); } }
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); } } }