Search in sources :

Example 1 with CSSUnknownRule

use of org.w3c.dom.css.CSSUnknownRule in project webtools.sourceediting by eclipse.

the class UnknownRuleFormatter method formatPre.

/**
 */
protected void formatPre(ICSSNode node, StringBuffer source) {
    CSSCleanupStrategy stgy = getCleanupStrategy(node);
    int start = ((IndexedRegion) node).getStartOffset();
    int end = ((IndexedRegion) node).getEndOffset();
    if (end > 0) {
        // format source
        IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument();
        CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy);
        for (int i = 0; i < regions.length; i++) {
            if (i != 0)
                appendSpaceBefore(node, regions[i], source);
            source.append(decoratedPropValueRegion(regions[i], stgy));
        }
    } else {
        // generate source
        CSSUnknownRule rule = (CSSUnknownRule) node;
        source.append(rule.getCssText());
    }
}
Also used : CSSUnknownRule(org.w3c.dom.css.CSSUnknownRule) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IndexedRegion(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion) CSSCleanupStrategy(org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy)

Aggregations

CSSCleanupStrategy (org.eclipse.wst.css.core.internal.cleanup.CSSCleanupStrategy)1 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 CSSUnknownRule (org.w3c.dom.css.CSSUnknownRule)1