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);
}
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();
}
}
}
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;
}
Aggregations