Search in sources :

Example 1 with AttrChangeContext

use of org.eclipse.wst.css.core.internal.formatter.AttrChangeContext in project webtools.sourceediting by eclipse.

the class CSSModelUpdater method attrInserted.

/**
 * @param parentNode
 *            org.eclipse.wst.css.core.model.CSSNodeImpl
 * @param node
 *            org.eclipse.wst.css.core.model.CSSNodeImpl
 */
private void attrInserted(CSSNodeImpl parentNode, CSSAttrImpl attr) {
    CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(parentNode);
    if (formatter == null) {
        // $NON-NLS-1$
        CSSUtil.debugOut("Cannot get format adapter : " + parentNode.getClass().toString());
        return;
    }
    short updateMode = CSSModelUpdateContext.UPDATE_INSERT_RCONTAINER;
    fParser.setupUpdateContext(updateMode, parentNode, attr);
    // get formatted info
    AttrChangeContext region = new AttrChangeContext();
    String text = new String(formatter.formatAttrChanged(parentNode, attr, true, region));
    // set text
    insertText(region.start, region.end - region.start, text);
    fParser.cleanupUpdateContext();
}
Also used : CSSSourceGenerator(org.eclipse.wst.css.core.internal.formatter.CSSSourceGenerator) AttrChangeContext(org.eclipse.wst.css.core.internal.formatter.AttrChangeContext)

Example 2 with AttrChangeContext

use of org.eclipse.wst.css.core.internal.formatter.AttrChangeContext in project webtools.sourceediting by eclipse.

the class CSSModelUpdater method attrRemoved.

/**
 * @param parentNode
 *            org.eclipse.wst.css.core.model.CSSNodeImpl
 * @param node
 *            org.eclipse.wst.css.core.model.CSSNodeImpl
 */
private void attrRemoved(CSSNodeImpl parentNode, CSSAttrImpl attr) {
    CSSSourceGenerator formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(parentNode);
    if (formatter == null) {
        // $NON-NLS-1$
        CSSUtil.debugOut("Cannot get format adapter : " + parentNode.getClass().toString());
        return;
    }
    short updateMode = CSSModelUpdateContext.UPDATE_REMOVE_RCONTAINER;
    fParser.setupUpdateContext(updateMode, parentNode, attr);
    // get formatted info
    AttrChangeContext region = new AttrChangeContext();
    String text = new String(formatter.formatAttrChanged(parentNode, attr, false, region));
    // set text
    insertText(region.start, region.end - region.start, text);
    fParser.cleanupUpdateContext();
}
Also used : CSSSourceGenerator(org.eclipse.wst.css.core.internal.formatter.CSSSourceGenerator) AttrChangeContext(org.eclipse.wst.css.core.internal.formatter.AttrChangeContext)

Aggregations

AttrChangeContext (org.eclipse.wst.css.core.internal.formatter.AttrChangeContext)2 CSSSourceGenerator (org.eclipse.wst.css.core.internal.formatter.CSSSourceGenerator)2