private List<StringTree> getAllStringsFromCommaSeparatedListElement(ValueTree valueTree) { return valueTree.valueElementsOfType(StringTree.class); }
private List<IdentifierTree> getAllIdentifiersFromCommaSeparatedListElement(ValueTree valueTree) { return valueTree.valueElementsOfType(IdentifierTree.class); }
private List<IdentifierTree> getAllIdentifiersFromCommaSeparatedListElement(ValueTree valueTree) { return valueTree.valueElementsOfType(IdentifierTree.class); }
private List<StringTree> getAllStringsFromCommaSeparatedListElement(ValueTree valueTree) { return valueTree.valueElementsOfType(StringTree.class); }
@Override public long complexity() { return 1 + condition.valueElementsOfType(ScssOperatorTree.class) .stream() .filter(o -> o.type() == ScssOperatorTree.OPERATOR.AND || o.type() == ScssOperatorTree.OPERATOR.OR) .count(); }
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 long complexity() { return 1 + condition.valueElementsOfType(ScssOperatorTree.class) .stream() .filter(o -> o.type() == ScssOperatorTree.OPERATOR.AND || o.type() == ScssOperatorTree.OPERATOR.OR) .count(); }
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 visitValue(ValueTree tree) { tree.valueElementsOfType(IdentifierTree.class) .stream() .filter(IdentifierTree::isVendorPrefixed) .forEach(i -> addPreciseIssue(i, "Remove this usage of the experimental \"" + i.text() + "\" identifier.")); super.visitValue(tree); }
@Override public void visitScssFor(ScssForTree tree) { Optional<IdentifierTree> to = tree.condition().condition().valueElementsOfType(IdentifierTree.class) .stream() .filter(i -> "to".equals(i.text())) .findFirst(); if (to.isPresent()) { addPreciseIssue(to.get(), "Replace 'to' with 'through'."); } super.visitScssFor(tree); }
@Override public void visitScssFor(ScssForTree tree) { Optional<IdentifierTree> to = tree.condition().condition().valueElementsOfType(IdentifierTree.class) .stream() .filter(i -> "to".equals(i.text())) .findFirst(); if (to.isPresent()) { addPreciseIssue(to.get(), "Replace 'to' with 'through'."); } super.visitScssFor(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 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 visitValue(ValueTree tree) { tree.valueElementsOfType(IdentifierTree.class) .stream() .filter(i -> i.isVendorPrefixed() && !i.name().matches(identifiersToExclude)) .forEach(i -> addPreciseIssue(i, "Remove this usage of the experimental \"" + i.text() + "\" identifier.")); super.visitValue(tree); }
@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 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; }
@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 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; }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { StandardProperty standardProperty = tree.property().standardProperty(); if (standardProperty instanceof Background || standardProperty instanceof BackgroundImage) { tree.value().valueElementsOfType(UriTree.class).stream() .filter(t -> t.uriContent() != null && !t.uriContent().text().isEmpty()) .forEach(t -> { String url = t.uriContent().text(); if (urls.containsKey(url)) { urls.get(url).add(t); } else { urls.put(url, Lists.newArrayList(t)); } }); } super.visitPropertyDeclaration(tree); }
@Override public void visitPropertyDeclaration(PropertyDeclarationTree tree) { StandardProperty standardProperty = tree.property().standardProperty(); if (standardProperty instanceof Background || standardProperty instanceof BackgroundImage) { tree.value().valueElementsOfType(UriTree.class).stream() .filter(t -> t.uriContent() != null && !t.uriContent().text().isEmpty()) .forEach(t -> { String url = t.uriContent().text(); if (urls.containsKey(url)) { urls.get(url).add(t); } else { urls.put(url, Lists.newArrayList(t)); } }); } super.visitPropertyDeclaration(tree); }