private int computeAvailableLineWidth(IStructuredDocument doc, int nodeOffset, int lineWidth) { // compute current available line width int currentAvailableLineWidth = 0; try { int lineOffset = doc.getLineInformationOfOffset(nodeOffset).getOffset(); String text = doc.get(lineOffset, nodeOffset - lineOffset); int usedWidth = getIndentationLength(text); currentAvailableLineWidth = lineWidth - usedWidth; } catch (BadLocationException e) { // log for now, unless we find reason not to Logger.log(Logger.INFO, e.getMessage()); } return currentAvailableLineWidth; }
@Override public void placeMatchingBlanks(IStructuredDocument document, StringBuilder result, int lineNumber, int forOffset) throws BadLocationException { final IRegion curlyOpenLine = getCurlyOpenLineInformation(document, forOffset); if (curlyOpenLine == null) { return; } int indentationBaseLineIndex = DefaultIndentationStrategy.getIndentationBaseLine(document, document.getLineOfOffset(curlyOpenLine.getOffset()), forOffset, true); final IRegion indentationBaseLine = document.getLineInformation(indentationBaseLineIndex); String blanks = ""; if (indentationBaseLine != null) { blanks = FormatterUtils.getLineBlanks(document, indentationBaseLine); } else { // if no matching bracket was found leaving the bracket as is. blanks = FormatterUtils.getLineBlanks(document, document.getLineInformationOfOffset(forOffset)); } result.append(blanks); }
private static boolean isIndentationBase(final IStructuredDocument document, final int checkedOffset, final int forOffset, int currLineIndex, boolean checkMultiLine) throws BadLocationException { final IRegion lineInfo = document.getLineInformationOfOffset(checkedOffset); int lineStart = lineInfo.getOffset();
int lineOffset = node.getStructuredDocument().getLineInformationOfOffset(nodeNameOffset).getOffset(); String text = node.getStructuredDocument().get(lineOffset, nodeNameOffset - lineOffset); int usedWidth = getIndentationLength(text);
curlyCount--; if (curlyCount < 0) { return document.getLineInformationOfOffset(tRegion.getStart() + regionStart);