private List<UriTree> getAllUriTrees(List<PropertyDeclarationTree> declarations) { List<UriTree> uris = new ArrayList<>(); declarations.stream() .filter(d -> d.property().standardProperty() instanceof Src) .forEach(d -> uris.addAll( d.value().valueElementsOfType(UriTree.class).stream() .collect(Collectors.toList()))); return uris; }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (!isOnSameLine(tree.property(), tree.colon(), tree.value())) { addPreciseIssue(tree, "Move the property, colon and value to the same line."); } if (isOnSameLine(tree.property(), tree.colon()) && nbWhitespacesBetween(tree.property(), tree.colon()) > 0) { addPreciseIssue(tree.colon(), "Remove the whitespaces between the property and the colon."); } if (isOnSameLine(tree.colon(), tree.value())) { if (nbWhitespacesBetween(tree.colon(), tree.value()) == 0) { addPreciseIssue(tree.colon(), "Add one whitespace between the colon and the value."); } else if (nbWhitespacesBetween(tree.colon(), tree.value()) > 1) { addPreciseIssue(tree.colon(), "Leave only one whitespace between the colon and the value."); } } super.visitPropertyDeclaration(tree); }
private void setPropertiesToNotUse(List<PropertyDeclarationTree> propertyDeclarationTrees) { propertiesToNotUse = null; for (PropertyDeclarationTree declaration : propertyDeclarationTrees) { if ("display".equals(declaration.property().standardProperty().getName()) && declaration.isValid(this.getContext().getLanguage()) && declaration.value().sanitizedValueElements().get(0) instanceof IdentifierTree) { displayDeclaration = declaration; String displayValue = ((IdentifierTree) declaration.value().sanitizedValueElements().get(0)).text(); if (displayValue.startsWith("table-")) { propertiesToNotUse = RULES.get("table-*"); } else { propertiesToNotUse = RULES.get(displayValue); } return; } } }
private boolean propertyToBeChecked(PropertyDeclarationTree tree) { if (!(tree.property().standardProperty() instanceof FontFamily)) { return false; } if (tree.parent() != null && tree.parent().parent() != null && tree.parent().parent() instanceof AtRuleTree && ((AtRuleTree) tree.parent().parent()).standardAtRule() instanceof FontFace) { return false; } return true; }
private PropertyDeclarationTree getLastSrcPropertyDeclaration(List<PropertyDeclarationTree> declarations) { PropertyDeclarationTree srcDeclarationNode = null; for (PropertyDeclarationTree declaration : declarations) { if (declaration.property().standardProperty() instanceof Src) { srcDeclarationNode = declaration; } } return srcDeclarationNode; }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (!tree.property().isVendorPrefixed() && !tree.isValid(this.getContext().getLanguage())) { addPreciseIssue( tree, MessageFormat.format( "Update the invalid value of property \"{0}\". Expected format: {1}", tree.property().standardProperty().getName(), tree.property().standardProperty().getValidatorFormat())); } super.visitPropertyDeclaration(tree); }
private List<UriTree> getUris(PropertyDeclarationTree declaration) { List<UriTree> uris = new ArrayList<>(); if (declaration.value().valueElements().get(0).is(Tree.Kind.VALUE_COMMA_SEPARATED_LIST)) { for (ValueTree v : ((ValueCommaSeparatedListTree) declaration.value().valueElements().get(0)).values()) { uris.addAll(v.valueElementsOfType(UriTree.class).stream() .filter(t -> t.uriContent() != null && !t.uriContent().text().isEmpty()) .collect(Collectors.toList())); } } else { uris = declaration.value().valueElementsOfType(UriTree.class).stream() .filter(t -> t.uriContent() != null && !t.uriContent().text().isEmpty()) .collect(Collectors.toList()); } return uris; }
private PropertyDeclarationTree getSecondToLastSrcPropertyDeclaration(List<PropertyDeclarationTree> declarations) { PropertyDeclarationTree srcSecondToLastPropertyDeclaration = null; PropertyDeclarationTree srcLastPropertyDeclaration = null; for (PropertyDeclarationTree declaration : declarations) { if (declaration.property().standardProperty() instanceof Src) { srcSecondToLastPropertyDeclaration = srcLastPropertyDeclaration; srcLastPropertyDeclaration = declaration; } } return srcSecondToLastPropertyDeclaration; }
private boolean propertyToBeChecked(PropertyDeclarationTree tree) { if (!(tree.property().standardProperty() instanceof FontFamily)) { return false; } if (tree.parent() != null && tree.parent().parent() != null && tree.parent().parent() instanceof AtRuleTree && ((AtRuleTree) tree.parent().parent()).standardAtRule() instanceof FontFace) { return false; } return true; }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (!tree.property().isVendorPrefixed() && !tree.isValid(this.getContext().getLanguage())) { addPreciseIssue( tree, MessageFormat.format( "Update the invalid value of property \"{0}\". Expected format: {1}", tree.property().standardProperty().getName(), tree.property().standardProperty().getValidatorFormat())); } super.visitPropertyDeclaration(tree); }
private List<UriTree> getUris(PropertyDeclarationTree declaration) { List<UriTree> uris = new ArrayList<>(); if (declaration.value().valueElements().get(0).is(Tree.Kind.VALUE_COMMA_SEPARATED_LIST)) { for (ValueTree v : ((ValueCommaSeparatedListTree) declaration.value().valueElements().get(0)).values()) { uris.addAll(v.valueElementsOfType(UriTree.class).stream() .filter(t -> t.uriContent() != null && !t.uriContent().text().isEmpty()) .collect(Collectors.toList())); } } else { uris = declaration.value().valueElementsOfType(UriTree.class).stream() .filter(t -> t.uriContent() != null && !t.uriContent().text().isEmpty()) .collect(Collectors.toList()); } return uris; }
private List<UriTree> getAllUriTrees(List<PropertyDeclarationTree> declarations) { List<UriTree> uris = new ArrayList<>(); declarations.stream() .filter(d -> d.property().standardProperty() instanceof Src) .forEach(d -> uris.addAll( d.value().valueElementsOfType(UriTree.class).stream() .collect(Collectors.toList()))); return uris; }
private PropertyDeclarationTree getSecondToLastSrcPropertyDeclaration(List<PropertyDeclarationTree> declarations) { PropertyDeclarationTree srcSecondToLastPropertyDeclaration = null; PropertyDeclarationTree srcLastPropertyDeclaration = null; for (PropertyDeclarationTree declaration : declarations) { if (declaration.property().standardProperty() instanceof Src) { srcSecondToLastPropertyDeclaration = srcLastPropertyDeclaration; srcLastPropertyDeclaration = declaration; } } return srcSecondToLastPropertyDeclaration; }
private void setPropertiesToNotUse(List<PropertyDeclarationTree> propertyDeclarationTrees) { propertiesToNotUse = null; for (PropertyDeclarationTree declaration : propertyDeclarationTrees) { if ("display".equals(declaration.property().standardProperty().getName()) && declaration.isValid(this.getContext().getLanguage()) && declaration.value().sanitizedValueElements().get(0) instanceof IdentifierTree) { displayDeclaration = declaration; String displayValue = ((IdentifierTree) declaration.value().sanitizedValueElements().get(0)).text(); if (displayValue.startsWith("table-")) { propertiesToNotUse = RULES.get("table-*"); } else { propertiesToNotUse = RULES.get(displayValue); } return; } } }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (!isOnSameLine(tree.property(), tree.colon(), tree.value())) { addPreciseIssue(tree, "Move the property, colon and value to the same line."); } if (isOnSameLine(tree.property(), tree.colon()) && nbWhitespacesBetween(tree.property(), tree.colon()) > 0) { addPreciseIssue(tree.colon(), "Remove the whitespaces between the property and the colon."); } if (isOnSameLine(tree.colon(), tree.value())) { if (nbWhitespacesBetween(tree.colon(), tree.value()) == 0) { addPreciseIssue(tree.colon(), "Add one whitespace between the colon and the value."); } else if (nbWhitespacesBetween(tree.colon(), tree.value()) > 1) { addPreciseIssue(tree.colon(), "Leave only one whitespace between the colon and the value."); } } super.visitPropertyDeclaration(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; }
private PropertyDeclarationTree getLastSrcPropertyDeclaration(List<PropertyDeclarationTree> declarations) { PropertyDeclarationTree srcDeclarationNode = null; for (PropertyDeclarationTree declaration : declarations) { if (declaration.property().standardProperty() instanceof Src) { srcDeclarationNode = declaration; } } return srcDeclarationNode; }
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; }