@Override public void visitRuleset(RulesetTree tree) { if (tree.block().content().isEmpty()) { addIssue(tree); } super.visitRuleset(tree); }
private List<String> missingGradients(RulesetTree tree) { List<String> missingGradients = new ArrayList<>(GRADIENTS); for (PropertyDeclarationTree propertyDeclaration : tree.block().propertyDeclarations()) { for (FunctionTree function : propertyDeclaration.value().valueElementsOfType(FunctionTree.class)) { String functionName = function.function().text().toLowerCase(); if (functionName.matches(GRADIENT_MATCHER)) { missingGradients.removeIf(functionName::matches); } } } return missingGradients; }
@Override public void visitRuleset(RulesetTree tree) { if (tree.block().content().isEmpty()) { addIssue(tree); } super.visitRuleset(tree); }
private List<String> missingGradients(RulesetTree tree) { List<String> missingGradients = new ArrayList<>(GRADIENTS); for (PropertyDeclarationTree propertyDeclaration : tree.block().propertyDeclarations()) { for (FunctionTree function : propertyDeclaration.value().valueElementsOfType(FunctionTree.class)) { String functionName = function.function().text().toLowerCase(); if (functionName.matches(GRADIENT_MATCHER)) { missingGradients.removeIf(functionName::matches); } } } return missingGradients; }
@Override public void visitRuleset(RulesetTree tree) { if (tree.block().content().isEmpty()) { super.visitRuleset(tree); return; } if (tree.block().content().size() < 2 && isOnSameLine(tree.block().openCurlyBrace(), tree.block().closeCurlyBrace())) { super.visitRuleset(tree); return; } if (isOnSameLine(tree.block().openCurlyBrace(), tree.block().content().get(0))) { addPreciseIssue(tree.block().openCurlyBrace(), "Move the code following the opening curly brace to the next line."); } if (tree.selectors() != null && !isOnSameLine(tree.selectors().lastSelector(), tree.block().openCurlyBrace())) { addPreciseIssue(tree.block().openCurlyBrace(), "Move the opening curly brace to the previous line."); } if (isOnSameLine(tree.block().content().get(tree.block().content().size() - 1), tree.block().closeCurlyBrace())) { addPreciseIssue(tree.block().closeCurlyBrace(), "Move the closing curly brace to the next line."); } super.visitRuleset(tree); }
@Override public void visitRuleset(RulesetTree tree) { if (tree.block().content().isEmpty()) { super.visitRuleset(tree); return; } if (tree.block().content().size() < 2 && isOnSameLine(tree.block().openCurlyBrace(), tree.block().closeCurlyBrace())) { super.visitRuleset(tree); return; } if (isOnSameLine(tree.block().openCurlyBrace(), tree.block().content().get(0))) { addPreciseIssue(tree.block().openCurlyBrace(), "Move the code following the opening curly brace to the next line."); } if (tree.selectors() != null && !isOnSameLine(tree.selectors().lastSelector(), tree.block().openCurlyBrace())) { addPreciseIssue(tree.block().openCurlyBrace(), "Move the opening curly brace to the previous line."); } if (isOnSameLine(tree.block().content().get(tree.block().content().size() - 1), tree.block().closeCurlyBrace())) { addPreciseIssue(tree.block().closeCurlyBrace(), "Move the closing curly brace to the next line."); } super.visitRuleset(tree); }
public static Tree rulesetIssueLocation(RulesetTree tree) { return tree.selectors() != null ? tree.selectors() : tree.block().openCurlyBrace(); }
public static Tree rulesetIssueLocation(RulesetTree tree) { return tree.selectors() != null ? tree.selectors() : tree.block().openCurlyBrace(); }
@Override public void visitRuleset(RulesetTree tree) { Set<Combinations> combinations = EnumSet.noneOf(Combinations.class); for (PropertyDeclarationTree propertyDeclarationTree : tree.block().propertyDeclarations()) { PropertyTree propertyTree = propertyDeclarationTree.property(); if (isBoxSizing(propertyTree)) { combinations.clear(); combinations.add(Combinations.IS_BOX_SIZING); } if (!combinations.contains(Combinations.IS_BOX_SIZING)) { if (!combinations.contains(Combinations.WIDTH_FOUND) && isWidth(propertyTree)) { combinations.add(Combinations.WIDTH_FOUND); } else if (!combinations.contains(Combinations.HEIGHT_FOUND) && isHeight(propertyTree)) { combinations.add(Combinations.HEIGHT_FOUND); } if (isWidthSizing(propertyDeclarationTree)) { combinations.add(Combinations.WIDTH_SIZING); } if (isHeightSizing(propertyDeclarationTree)) { combinations.add(Combinations.HEIGHT_SIZING); } } } if (combinations.containsAll(Arrays.asList(Combinations.WIDTH_FOUND, Combinations.WIDTH_SIZING)) || combinations.containsAll(Arrays.asList(Combinations.HEIGHT_FOUND, Combinations.HEIGHT_SIZING))) { addPreciseIssue(CheckUtils.rulesetIssueLocation(tree), "Check this potential box model size issue."); } super.visitRuleset(tree); }
@Override public void visitRuleset(RulesetTree tree) { Set<Combinations> combinations = EnumSet.noneOf(Combinations.class); for (PropertyDeclarationTree propertyDeclarationTree : tree.block().propertyDeclarations()) { PropertyTree propertyTree = propertyDeclarationTree.property(); if (isBoxSizing(propertyTree)) { combinations.clear(); combinations.add(Combinations.IS_BOX_SIZING); } if (!combinations.contains(Combinations.IS_BOX_SIZING)) { if (!combinations.contains(Combinations.WIDTH_FOUND) && isWidth(propertyTree)) { combinations.add(Combinations.WIDTH_FOUND); } else if (!combinations.contains(Combinations.HEIGHT_FOUND) && isHeight(propertyTree)) { combinations.add(Combinations.HEIGHT_FOUND); } if (isWidthSizing(propertyDeclarationTree)) { combinations.add(Combinations.WIDTH_SIZING); } if (isHeightSizing(propertyDeclarationTree)) { combinations.add(Combinations.HEIGHT_SIZING); } } } if (combinations.containsAll(Arrays.asList(Combinations.WIDTH_FOUND, Combinations.WIDTH_SIZING)) || combinations.containsAll(Arrays.asList(Combinations.HEIGHT_FOUND, Combinations.HEIGHT_SIZING))) { addPreciseIssue(CheckUtils.rulesetIssueLocation(tree), "Check this potential box model size issue."); } super.visitRuleset(tree); }