private void createIssue(StandardProperty shorthandProperty, Tree tree) { Tree primaryIssueLocation; if (tree.is(Tree.Kind.RULESET)) { primaryIssueLocation = CheckUtils.rulesetIssueLocation((RulesetTree) tree); } else { primaryIssueLocation = ((AtRuleTree) tree).atKeyword(); } PreciseIssue issue = addPreciseIssue(primaryIssueLocation, "Use the \"" + shorthandProperty.getName() + "\" shorthand property instead."); for (Iterator<Map.Entry<String, PropertyTree>> it = declaredProperties.entrySet().iterator(); it.hasNext();) { Map.Entry<String, PropertyTree> entry = it.next(); if (shorthandProperty.getShorthandForPropertyNames().contains(entry.getKey())) { issue.secondary(entry.getValue(), "\"" + shorthandProperty.getName() + "\" property"); } } }
private void createIssue(StandardProperty shorthandProperty, Tree tree) { Tree primaryIssueLocation; if (tree.is(Tree.Kind.RULESET)) { primaryIssueLocation = CheckUtils.rulesetIssueLocation((RulesetTree) tree); } else { primaryIssueLocation = ((AtRuleTree) tree).atKeyword(); } PreciseIssue issue = addPreciseIssue(primaryIssueLocation, "Use the \"" + shorthandProperty.getName() + "\" shorthand property instead."); for (Iterator<Map.Entry<String, PropertyTree>> it = declaredProperties.entrySet().iterator(); it.hasNext();) { Map.Entry<String, PropertyTree> entry = it.next(); if (shorthandProperty.getShorthandForPropertyNames().contains(entry.getKey())) { issue.secondary(entry.getValue(), "\"" + shorthandProperty.getName() + "\" property"); } } }
@Override public void visitStyleSheet(StyleSheetTree tree) { precedingRules.clear(); super.visitStyleSheet(tree); for (StatementTree statementTree : tree.statements()) { if (statementTree instanceof RulesetTree) { precedingRules.add(CheckUtils.rulesetIssueLocation((RulesetTree) statementTree)); } else if (((AtRuleTree) statementTree).standardAtRule() instanceof Import) { if (!precedingRules.isEmpty()) { createIssue(((AtRuleTree) statementTree).atKeyword()); } } else if (!(((AtRuleTree) statementTree).standardAtRule() instanceof Charset)) { precedingRules.add(statementTree); } } }
@Override public void visitStyleSheet(StyleSheetTree tree) { precedingRules.clear(); super.visitStyleSheet(tree); for (StatementTree statementTree : tree.statements()) { if (statementTree instanceof RulesetTree) { precedingRules.add(CheckUtils.rulesetIssueLocation((RulesetTree) statementTree)); } else if (((AtRuleTree) statementTree).standardAtRule() instanceof Import) { if (!precedingRules.isEmpty()) { createIssue(((AtRuleTree) statementTree).atKeyword()); } } else if (!(((AtRuleTree) statementTree).standardAtRule() instanceof Charset)) { precedingRules.add(statementTree); } } }
private boolean isFontFaceRuleToBeChecked(AtRuleTree tree) { return "font-face".equalsIgnoreCase(tree.atKeyword().keyword().text()) && tree.block() != null && definesScrPropertyWithUrl(tree.block().propertyDeclarations()); }
private boolean isFontFaceRuleToBeChecked(AtRuleTree tree) { return "font-face".equalsIgnoreCase(tree.atKeyword().keyword().text()) && tree.block() != null && definesScrPropertyWithUrl(tree.block().propertyDeclarations()); }
private void checkAtRuleOpeningCurlyBrace(AtRuleTree tree) { Preconditions.checkNotNull(tree.block()); Tree tree1 = tree.preludes() != null ? tree.preludes() : tree.atKeyword(); Tree tree2 = tree.block().openCurlyBrace(); if (!isOnSameLine(tree1, tree2)) { addPreciseIssue(tree2, "Move the opening curly brace to the previous line."); } }
private void checkAtRuleOpeningCurlyBrace(AtRuleTree tree) { Preconditions.checkNotNull(tree.block()); Tree tree1 = tree.preludes() != null ? tree.preludes() : tree.atKeyword(); Tree tree2 = tree.block().openCurlyBrace(); if (!isOnSameLine(tree1, tree2)) { addPreciseIssue(tree2, "Move the opening curly brace to the previous line."); } }
@Override public void visitAtRule(AtRuleTree tree) { if (tree.standardAtRule() instanceof UnknownAtRule && !tree.isVendorPrefixed()) { addPreciseIssue( tree.atKeyword(), "Remove this usage of the unknown \"" + tree.standardAtRule().getName() + "\" @-rule."); } super.visitAtRule(tree); }
@Override public void visitAtRule(AtRuleTree tree) { if (tree.standardAtRule() instanceof UnknownAtRule && !tree.isVendorPrefixed()) { addPreciseIssue( tree.atKeyword(), "Remove this usage of the unknown \"" + tree.standardAtRule().getName() + "\" @-rule."); } super.visitAtRule(tree); }
@Override public void visitAtRule(AtRuleTree tree) { if (!tree.standardAtRule().getName().matches(atRulesToExclude) && (tree.isVendorPrefixed() || tree.standardAtRule().isExperimental())) { addPreciseIssue( tree.atKeyword(), "Remove this usage of the experimental \"" + tree.standardAtRule().getName() + "\" @-rule."); } super.visitAtRule(tree); }
@Override public void visitAtRule(AtRuleTree tree) { if (tree.isVendorPrefixed() || tree.standardAtRule().isExperimental()) { addPreciseIssue( tree.atKeyword(), "Remove this usage of the experimental \"" + tree.standardAtRule().getName() + "\" @-rule."); } super.visitAtRule(tree); }
@Override public void visitAtRule(AtRuleTree tree) { if (!isFontFaceRuleToBeChecked(tree)) { return; } List<PropertyDeclarationTree> declarations = tree.block().propertyDeclarations(); if (DEEPEST_LEVEL.equals(browserSupportLevel)) { if (getSecondToLastSrcPropertyDeclaration(declarations) == null) { addPreciseIssue(tree.atKeyword(), "Add an \"src\" property setting the URL for the \".eot\" font file (to support IE9 Compatibility Modes)."); } else { checkSecondToLastSrcPropertyDeclaration(getSecondToLastSrcPropertyDeclaration(declarations)); } } checkLastSrcProperty(getLastSrcPropertyDeclaration(declarations)); super.visitAtRule(tree); }
@Override public void visitAtRule(AtRuleTree tree) { if (!isFontFaceRuleToBeChecked(tree)) { return; } List<PropertyDeclarationTree> declarations = tree.block().propertyDeclarations(); if (DEEPEST_LEVEL.equals(browserSupportLevel)) { if (getSecondToLastSrcPropertyDeclaration(declarations) == null) { addPreciseIssue(tree.atKeyword(), "Add an \"src\" property setting the URL for the \".eot\" font file (to support IE9 Compatibility Modes)."); } else { checkSecondToLastSrcPropertyDeclaration(getSecondToLastSrcPropertyDeclaration(declarations)); } } checkLastSrcProperty(getLastSrcPropertyDeclaration(declarations)); super.visitAtRule(tree); }