public CssClassesVisitor(Rule rule, HtmlRuleContext context, List<Hint> hints) throws IOException { this.context = context; this.hints = hints; this.rule = rule; referredFiles = context.getCssDependenciesGraph().getAllReferedFiles(); classes = context.getCssIndex().findAllClassDeclarations(); classes2files = createReversedMap(classes); }
@Override protected void run(HtmlRuleContext context, List<Hint> result) { try { HtmlParserResult parserResult = context.getHtmlParserResult(); CssClassesVisitor visitor = new CssClassesVisitor(this, context, result); ElementUtils.visitChildren(parserResult.root(), visitor, ElementType.OPEN_TAG); } catch (IOException ioe) { Exceptions.printStackTrace(ioe); } }
private static OffsetRange getAttributeValueOffsetRange(Attribute attr, HtmlRuleContext context) { boolean quoted = attr.isValueQuoted(); int from = attr.valueOffset() + (quoted ? 1 : 0); int to = from + attr.unquotedValue().length(); return EmbeddingUtil.convertToDocumentOffsets(from, to, context.getSnapshot()); }