@Override public boolean isValid(Tree tree) { if (tree instanceof IdentifierTree) { if (allowedValues.isEmpty() || ((IdentifierTree) tree).isVendorPrefixed()) { return true; } return allowedValues.contains(((IdentifierTree) tree).text().toLowerCase()); } return false; }
private void addIssue(IdentifierTree classNameTree) { addPreciseIssue( classNameTree, MessageFormat.format("Rename class selector \"{0}\" to match the regular expression: {1}", classNameTree.text(), format)); }
public PropertyTreeImpl(IdentifierTree property, @Nullable SyntaxToken lessMerge) { this.property = property; this.lessMerge = lessMerge; setProperty(property.text()); }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { tree.value().valueElementsOfType(IdentifierTree.class).stream() .filter(t -> Color.CSS2_SYSTEM_COLORS.contains(t.text().toLowerCase()) && !potentialFalsePositives.contains(t.text().toLowerCase())) .forEach(t -> addPreciseIssue(t, "Remove this usage of the deprecated \"" + t.text() + "\" system color.")); super.visitPropertyDeclaration(tree); }
private Vendor setVendor() { for (Vendor v : Vendor.values()) { if (function.text().toLowerCase(Locale.ENGLISH).startsWith(v.getPrefix())) { return v; } } return null; }
@Override public void visitAtKeyword(AtKeywordTree tree) { if ("font-face".equalsIgnoreCase(tree.keyword().text())) { fontFaceTrees.add(tree); } super.visitAtKeyword(tree); }
@Override public void visitAtKeyword(AtKeywordTree tree) { if ("import".equalsIgnoreCase(tree.keyword().text())) { atKeywordTrees.add(tree); } super.visitAtKeyword(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 void addIssue(ScssFunctionTree tree) { addPreciseIssue( tree.name(), MessageFormat.format( "Rename function \"{0}\" to match the regular expression: {1}", tree.name().text(), format)); }
@Override public void visitSelector(SelectorTree tree) { List<SimpleSelectorTree> lastCompoundSelector = tree.compoundSelectors().get(tree.compoundSelectors().size() - 1).selectors(); if (lastCompoundSelector.size() == 1 && lastCompoundSelector.get(0) instanceof TypeSelectorTree && "*".equals(((TypeSelectorTree) lastCompoundSelector.get(0)).identifier().text())) { addPreciseIssue( ((TypeSelectorTree) lastCompoundSelector.get(0)).identifier(), "Remove this usage of the universal selector as key part."); } super.visitSelector(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 visitProperty(PropertyTree tree) { if (!tree.property().isInterpolated() && tree.property().text().matches(regularExpression)) { addPreciseIssue(tree, message); } super.visitProperty(tree); }
@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 visitClassSelector(ClassSelectorTree tree) { if (!tree.className().isInterpolated() && !tree.className().text().matches(format) && !tree.parent().hasAncestor(LessMixinCallTree.class)) { addIssue(tree.className()); } super.visitClassSelector(tree); }
@Override public void visitAtRule(AtRuleTree tree) { if (!tree.atKeyword().keyword().isInterpolated() && tree.atKeyword().keyword().text().matches(regularExpression)) { addPreciseIssue(tree.atKeyword(), message); } super.visitAtRule(tree); }