public void format(Node node) { IStructuredFormatContraints formatContraints = getFormatContraints(); format(node, formatContraints); }
protected void formatNode(IDOMNode node, IStructuredFormatContraints formatContraints) { if (node != null && (fProgressMonitor == null || !fProgressMonitor.isCanceled())) { // format indentation before node formatIndentationBeforeNode(node, formatContraints); // format indentation after node formatIndentationAfterNode(node, formatContraints); } }
public void format(Node node, IStructuredFormatContraints formatContraints) { if (formatContraints.getFormatWithSiblingIndent()) formatContraints.setCurrentIndent(getSiblingIndent(node)); if (node instanceof IDOMNode) formatNode((IDOMNode) node, formatContraints); }
IDOMNode nextSibling = (IDOMNode) node.getNextSibling(); IStructuredDocument doc = node.getModel().getStructuredDocument(); String lineDelimiter = getLineDelimiter(node, doc); if (nextSibling != null) if (nextSibling.getNodeType() == Node.TEXT_NODE) getFormatter(nextSibling).format(nextSibling, formatContraints); else if (nextSibling.getNodeType() == Node.COMMENT_NODE) { insertAfterNode(node, lineDelimiter + lineIndent); getFormatter(nextSibling).format(nextSibling, formatContraints); else if (nextSibling.getNodeType() == Node.COMMENT_NODE) { insertAfterNode(node, lineDelimiter + lineIndent); IDOMNode indentNode = getParentIndentNode(node); String lineIndent = getNodeIndent(indentNode); IDOMNode lastChild = getDeepestChildNode(node); boolean clearAllBlankLines = formatContraints.getClearAllBlankLines(); replaceNodeValue(lastChild, lineDelimiter + lineIndent); insertAfterNode(lastChild, lineIndent); replaceNodeValue(lastChild, lineDelimiter + lineIndent); insertAfterNode(lastChild, lineDelimiter + lineIndent);
IDOMNode previousSibling = (IDOMNode) node.getPreviousSibling(); IStructuredDocument doc = node.getModel().getStructuredDocument(); String lineDelimiter = getLineDelimiter(node, doc); if (previousSibling != null) if (previousSibling.getNodeType() == Node.TEXT_NODE) getFormatter(previousSibling).format(previousSibling, formatContraints); else { insertBeforeNode(node, lineDelimiter + lineIndent); insertBeforeNode(node, lineDelimiter + lineIndent); if (previousSibling.getNodeValue().length() == 0) { replaceNodeValue(previousSibling, lineDelimiter + lineIndent); insertAfterNode(previousSibling, lineIndent); getFormatter(previousSibling).format(previousSibling, formatContraints);
protected IDOMNode getDeepestChildNode(IDOMNode node) { IDOMNode result = null; IDOMNode lastChild = (IDOMNode) node.getLastChild(); if (lastChild == null) result = node; else { result = getDeepestChildNode(lastChild); if ((result.getNodeType() == Node.TEXT_NODE || result.getNodeType() == Node.COMMENT_NODE) && !isEndTagMissing(node)) result = node; } return result; }
sibling = (IDOMNode) sibling.getNextSibling(); String singleIndent = getFormatPreferences().getIndent(); String parentLineIndent = getNodeIndent(node.getParentNode()); String siblingIndent = getNodeIndent(sibling); if (siblingIndent.length() > 0) result = siblingIndent; else { String nodeIndent = getNodeIndent(node); if (nodeIndent.length() > parentLineIndent.length()) String nodeIndent = getNodeIndent(node); if (nodeIndent.length() > parentLineIndent.length())
formatter = new NodeFormatter(); formatter.setFormatPreferences(getFormatPreferences()); formatter.setProgressMonitor(fProgressMonitor);
public IStructuredFormatContraints getFormatContraints() { if (fFormatContraints == null) { fFormatContraints = new StructuredFormatContraints(); fFormatContraints.setClearAllBlankLines(getFormatPreferences().getClearAllBlankLines()); } return fFormatContraints; }
formatter = new NodeFormatter();