private PropertyDeclarationTree getLastSrcPropertyDeclaration(List<PropertyDeclarationTree> declarations) { PropertyDeclarationTree srcDeclarationNode = null; for (PropertyDeclarationTree declaration : declarations) { if (declaration.property().standardProperty() instanceof Src) { srcDeclarationNode = declaration; } } return srcDeclarationNode; }
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 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; }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (tree.property().isVendorPrefixed()) { String standardPropertyName = tree.property().standardProperty().getName(); Vendor vendor = tree.property().vendor(); if (properties.containsKey(standardPropertyName)) { properties.get(standardPropertyName).add(vendor); } else { properties.put(standardPropertyName, Sets.newHashSet(vendor)); } } super.visitPropertyDeclaration(tree); }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (tree.property().isVendorPrefixed()) { String standardPropertyName = tree.property().standardProperty().getName(); Vendor vendor = tree.property().vendor(); if (properties.containsKey(standardPropertyName)) { properties.get(standardPropertyName).add(vendor); } else { properties.put(standardPropertyName, Sets.newHashSet(vendor)); } } super.visitPropertyDeclaration(tree); }
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 boolean definesScrPropertyWithUrl(List<PropertyDeclarationTree> declarations) { for (PropertyDeclarationTree declaration : declarations) if (declaration.property().standardProperty() instanceof Src && !getUris(declaration).isEmpty()) { return true; } return false; }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { StandardProperty standardProperty = tree.property().standardProperty(); String propertyName = standardProperty.getName(); if (SHORTHAND_PROPERTIES.contains(propertyName) && tree.value().sanitizedValueElements().size() > 1) { addPreciseIssue( tree.property(), "Replace this \"" + propertyName + "\" shorthand property with its longhand properties: " + standardProperty.getShorthandForPropertyNames().stream().sorted().collect(Collectors.joining(", "))); } super.visitPropertyDeclaration(tree); }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (tree.property().standardProperty() instanceof FontFamily || tree.property().standardProperty() instanceof Font) { getAllStrings(tree.value()).stream() .filter(t -> FontFamily.GENERIC_FAMILY_NAMES.contains(t.actualText().toLowerCase())) .forEach(t -> addPreciseIssue(t, "Unquote this generic font family name.")); } super.visitPropertyDeclaration(tree); }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (tree.property().standardProperty() instanceof FontFamily || tree.property().standardProperty() instanceof Font) { getAllStrings(tree.value()).stream() .filter(t -> FontFamily.GENERIC_FAMILY_NAMES.contains(t.actualText().toLowerCase())) .forEach(t -> addPreciseIssue(t, "Unquote this generic font family name.")); } super.visitPropertyDeclaration(tree); }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (tree.property().standardProperty() instanceof FontFamily) { getAllIdentifiers(tree.value()).stream() .filter(t -> !FontFamily.GENERIC_FAMILY_NAMES.contains(t.text().toLowerCase()) && !StandardProperty.COMMON_VALUES.contains(t.text().toLowerCase())) .forEach(t -> addPreciseIssue(t, "Quote this font family name.")); } super.visitPropertyDeclaration(tree); }
private boolean isFloatNone(PropertyDeclarationTree declaration) { if ("float".equals(declaration.property().standardProperty().getName())) { List<Tree> valueElements = declaration.value().sanitizedValueElements(); if (valueElements.size() == 1 && ValidatorFactory.getNoneValidator().isValid(valueElements.get(0))) { return true; } } return false; }
private boolean isOtherUsed(List<String> props, PropertyDeclarationTree tree) { String propertyName = tree.property().standardProperty().getName(); return props.contains(propertyName) && !isZeroValue(propertyName, tree.value()); }
private void addIssues(List<PropertyDeclarationTree> propertyDeclarationTrees, List<String> propertiesToNotUse) { for (PropertyDeclarationTree declaration : propertyDeclarationTrees) { String propertyName = declaration.property().standardProperty().getName(); if (propertiesToNotUse.contains(propertyName) && !isFloatNone(declaration)) { PreciseIssue issue = addPreciseIssue( declaration, "Remove this \"" + propertyName + "\" declaration that does not work with the \"display\" declaration."); issue.secondary(displayDeclaration, "\"display\" property declaration"); } } }
private void addIssues(List<PropertyDeclarationTree> propertyDeclarationTrees, List<String> propertiesToNotUse) { for (PropertyDeclarationTree declaration : propertyDeclarationTrees) { String propertyName = declaration.property().standardProperty().getName(); if (propertiesToNotUse.contains(propertyName) && !isFloatNone(declaration)) { PreciseIssue issue = addPreciseIssue( declaration, "Remove this \"" + propertyName + "\" declaration that does not work with the \"display\" declaration."); issue.secondary(displayDeclaration, "\"display\" property declaration"); } } }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (tree.property().standardProperty() instanceof TextTransform && !tree.value().sanitizedValueElements().isEmpty() && tree.value().sanitizedValueElements().get(0).is(Tree.Kind.IDENTIFIER) && FORBIDDEN_VALUES.contains(((IdentifierTree) tree.value().sanitizedValueElements().get(0)).text().toLowerCase())) { addPreciseIssue(tree, "Remove this \"text-transform\" property declaration."); } super.visitPropertyDeclaration(tree); }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { if (tree.property().standardProperty() instanceof FontFamily && tree.isValid(this.getContext().getLanguage())) { checkForIssues(mapByFontFamilyName(tree.value())); } super.visitPropertyDeclaration(tree); }
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; }