Search in sources :

Example 6 with CSSSourceFormatter

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

the class EmbeddedCSSFormatter method getCSSContent.

/**
 */
private String getCSSContent(IDOMNode text) {
    ICSSModel model = getCSSModel(text);
    if (model == null)
        return null;
    ICSSNode document = model.getDocument();
    if (document == null)
        return null;
    INodeNotifier notifier = (INodeNotifier) document;
    CSSSourceFormatter formatter = (CSSSourceFormatter) notifier.getAdapterFor(CSSSourceFormatter.class);
    // try another way to get formatter
    if (formatter == null)
        formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter(notifier);
    if (formatter == null)
        return null;
    StringBuffer buffer = formatter.format(document);
    if (buffer == null)
        return null;
    return buffer.toString();
}
Also used : CSSSourceFormatter(org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) ICSSNode(org.eclipse.wst.css.core.internal.provisional.document.ICSSNode) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Aggregations

CSSSourceFormatter (org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter)6 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)6 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)6 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)6 List (java.util.List)2 CSSFormatUtil (org.eclipse.wst.css.core.internal.formatter.CSSFormatUtil)2 ICSSDocument (org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument)2 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)2 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)2 DocumentRewriteSession (org.eclipse.jface.text.DocumentRewriteSession)1 DocumentRewriteSessionType (org.eclipse.jface.text.DocumentRewriteSessionType)1 IDocumentExtension4 (org.eclipse.jface.text.IDocumentExtension4)1 Region (org.eclipse.jface.text.Region)1 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)1