Search in sources :

Example 1 with IStructuredFormatContraints

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints in project webtools.sourceediting by eclipse.

the class NodeFormatter method format.

public void format(Node node) {
    IStructuredFormatContraints formatContraints = getFormatContraints();
    format(node, formatContraints);
}
Also used : IStructuredFormatContraints(org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints)

Example 2 with IStructuredFormatContraints

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints in project webtools.sourceediting by eclipse.

the class DocumentNodeFormatter method formatChildren.

protected void formatChildren(IDOMNode node, IStructuredFormatContraints formatContraints) {
    String singleIndent = getFormatPreferences().getIndent();
    String lineIndent = formatContraints.getCurrentIndent();
    if (node != null && (fProgressMonitor == null || !fProgressMonitor.isCanceled())) {
        // normalize node first to combine adjacent text nodes
        node.normalize();
        IDOMNode nextChild = (IDOMNode) node.getFirstChild();
        while (nextChild != null) {
            IDOMNode eachChildNode = nextChild;
            nextChild = (IDOMNode) eachChildNode.getNextSibling();
            IStructuredFormatter formatter = getFormatter(eachChildNode);
            IStructuredFormatContraints childFormatContraints = formatter.getFormatContraints();
            String childIndent = lineIndent + singleIndent;
            childFormatContraints.setCurrentIndent(childIndent);
            childFormatContraints.setClearAllBlankLines(formatContraints.getClearAllBlankLines());
            childFormatContraints.setInPreserveSpaceElement(formatContraints.getInPreserveSpaceElement());
            // format each child
            formatter.format(eachChildNode, childFormatContraints);
            if (nextChild != null && nextChild.getParentNode() == null)
                // nextNode is deleted during format
                nextChild = (IDOMNode) eachChildNode.getNextSibling();
        }
    }
}
Also used : IStructuredFormatContraints(org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) IStructuredFormatter(org.eclipse.wst.sse.core.internal.format.IStructuredFormatter)

Example 3 with IStructuredFormatContraints

use of org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints in project webtools.sourceediting by eclipse.

the class NodeFormatter method getFormatContraints.

public IStructuredFormatContraints getFormatContraints() {
    if (fFormatContraints == null) {
        fFormatContraints = new StructuredFormatContraints();
        fFormatContraints.setClearAllBlankLines(getFormatPreferences().getClearAllBlankLines());
    }
    return fFormatContraints;
}
Also used : IStructuredFormatContraints(org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints) StructuredFormatContraints(org.eclipse.wst.sse.core.internal.format.StructuredFormatContraints)

Aggregations

IStructuredFormatContraints (org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints)3 IStructuredFormatter (org.eclipse.wst.sse.core.internal.format.IStructuredFormatter)1 StructuredFormatContraints (org.eclipse.wst.sse.core.internal.format.StructuredFormatContraints)1 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)1