protected final void formatChildren(ICSSNode node, IRegion region, StringBuffer source) { ICSSNode child = node.getFirstChild(); int start = region.getOffset(); int end = region.getOffset() + region.getLength(); boolean first = true; while (child != null) { int curEnd = ((IndexedRegion) child).getEndOffset(); StringBuffer childSource = null; boolean toFinish = false; if (start < curEnd) { int curStart = ((IndexedRegion) child).getStartOffset(); if (curStart < end) { // append child CSSSourceFormatter formatter = (CSSSourceFormatter) ((INodeNotifier) child).getAdapterFor(CSSSourceFormatter.class); if (formatter == null) { formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) child); } if (includes(region, curStart, curEnd)) childSource = ((AbstractCSSSourceFormatter) formatter).formatProc(child); else childSource = ((AbstractCSSSourceFormatter) formatter) .formatProc(child, overlappedRegion(region, curStart, curEnd)); } else toFinish = true; } // append between children if (!first) { curEnd = ((IndexedRegion) child).getStartOffset(); // change // only // start if (start < curEnd) { int curStart = ((IndexedRegion) child.getPreviousSibling()).getEndOffset(); if (curStart < end) { String toAppend = (childSource != null) ? new String(childSource) : ""; // $NON-NLS-1$ if (includes(region, curStart, curEnd)) formatBefore(node, child, toAppend, source, null); else formatBefore( node, child, overlappedRegion(region, curStart, curEnd), toAppend, source); } } } if (childSource != null) { source.append(childSource); } first = false; if (toFinish) break; child = child.getNextSibling(); } }
protected final void formatChildren(ICSSNode node, StringBuffer source) { ICSSNode child = node.getFirstChild(); boolean first = true; while (child != null) { // append child CSSSourceFormatter formatter = (CSSSourceFormatter) ((INodeNotifier) child).getAdapterFor(CSSSourceFormatter.class); if (formatter == null) { formatter = CSSSourceFormatterFactory.getInstance().getSourceFormatter((INodeNotifier) child); } StringBuffer childSource = ((AbstractCSSSourceFormatter) formatter).formatProc(child); if (!first) { formatBefore(node, child, new String(childSource), source, null); } source.append(childSource); // append between children child = child.getNextSibling(); first = false; } }