public int startLine() { return firstToken.line(); }
public int startLine() { return firstToken.line(); }
private boolean isOnSameLine(Tree... trees) { Preconditions.checkArgument(trees.length > 1); int lineRef; if (trees[0] instanceof TreeImpl) { lineRef = ((TreeImpl) trees[0]).getLastToken().line(); } else { lineRef = ((SyntaxToken) trees[0]).line(); } for (int i = 1; i < trees.length; i++) { if (trees[i] instanceof TreeImpl && ((TreeImpl) trees[i]).getFirstToken().line() != lineRef || trees[i] instanceof SyntaxToken && ((SyntaxToken) trees[i]).line() != lineRef) { return false; } } return true; }
private boolean isOnSameLine(Tree... trees) { Preconditions.checkArgument(trees.length > 1); int lineRef; if (trees[0] instanceof TreeImpl) { lineRef = ((TreeImpl) trees[0]).getLastToken().line(); } else { lineRef = ((SyntaxToken) trees[0]).line(); } for (int i = 1; i < trees.length; i++) { if (trees[i] instanceof TreeImpl && ((TreeImpl) trees[i]).getFirstToken().line() != lineRef || trees[i] instanceof SyntaxToken && ((SyntaxToken) trees[i]).line() != lineRef) { return false; } } return true; }
@Override public int getLine() { return getFirstToken().line(); }
@Override public int getLine() { return getFirstToken().line(); }
private boolean isFirst(SyntaxToken atSymbol) { return atSymbol.line() == 1 && atSymbol.column() == 0; }
private boolean isFirst(SyntaxToken atSymbol) { return atSymbol.line() == 1 && atSymbol.column() == 0; }
@Override public void visitStatementBlock(StatementBlockTree tree) { List<DeclarationTree> allDeclarations = tree.allDeclarations(); for (int i = 1; i < allDeclarations.size(); i++) { if (allDeclarations.get(i).colon().line() == allDeclarations.get(i - 1).colon().line()) { addPreciseIssue(allDeclarations.get(i), "Define this declaration on a separate line."); } } super.visitStatementBlock(tree); }
@Override public void visitStatementBlock(StatementBlockTree tree) { List<DeclarationTree> allDeclarations = tree.allDeclarations(); for (int i = 1; i < allDeclarations.size(); i++) { if (allDeclarations.get(i).colon().line() == allDeclarations.get(i - 1).colon().line()) { addPreciseIssue(allDeclarations.get(i), "Define this declaration on a separate line."); } } super.visitStatementBlock(tree); }
@Override public void visitStyleSheet(StyleSheetTree tree) { Comparator<Usage> byLine = Comparator.comparing(u -> u.identifierTree().value().line()); Comparator<Usage> byColumn = Comparator.comparing(u -> u.identifierTree().value().column()); for (Scope scope : getContext().getSymbolModel().getScopes()) { for (Symbol symbol : scope.getSymbols(Symbol.Kind.LESS_VARIABLE)) { List<Usage> usages = symbol.usages() .stream() .filter(u -> u.is(Usage.Kind.DECLARATION)) .sorted(byLine.thenComparing(byColumn)) .collect(Collectors.toList()); if (usages.size() > 1) { createIssue(usages); } } } }
@Override public void visitStyleSheet(StyleSheetTree tree) { Comparator<Usage> byLine = Comparator.comparing(u -> u.identifierTree().value().line()); Comparator<Usage> byColumn = Comparator.comparing(u -> u.identifierTree().value().column()); for (Scope scope : getContext().getSymbolModel().getScopes()) { for (Symbol symbol : scope.getSymbols(Symbol.Kind.LESS_VARIABLE)) { List<Usage> usages = symbol.usages() .stream() .filter(u -> u.is(Usage.Kind.DECLARATION)) .sorted(byLine.thenComparing(byColumn)) .collect(Collectors.toList()); if (usages.size() > 1) { createIssue(usages); } } } }
protected void highlight(SyntaxToken token, TypeOfText type) { highlighting.highlight(token.line(), token.column(), token.endLine(), token.endColumn(), type); }
protected void highlight(SyntaxToken token, TypeOfText type) { highlighting.highlight(token.line(), token.column(), token.endLine(), token.endColumn(), type); }
@Override public void visitNode(Tree tree) { if (((InternalSyntaxToken) tree).isEOF()) { return; } if (((InternalSyntaxToken) tree).isBOM()) { return; } SyntaxToken token = (SyntaxToken) tree; TextRange range = inputFile.newRange(token.line(), token.column(), token.endLine(), token.endColumn()); cpdTokens.addToken(range, token.text()); }
@Override public void visitNode(Tree tree) { if (((InternalSyntaxToken) tree).isEOF()) { return; } if (((InternalSyntaxToken) tree).isBOM()) { return; } SyntaxToken token = (SyntaxToken) tree; TextRange range = inputFile.newRange(token.line(), token.column(), token.endLine(), token.endColumn()); cpdTokens.addToken(range, token.text()); }