/** * Returns extra indentation string for strings that are broken by a newline * based on the value of the formatter preferences for tabs vs. spaces. * * @return two tabs or equivalent number of spaces */ private String getExtraIndentAfterNewLine() { // read settings int formatterContinuationIndentationSize= getContinuationIndentationSize(); int binaryAlignmentValue= getBinaryOperatorAlignmentStyle(); // work out indent int indentSize= formatterContinuationIndentationSize; if (binaryAlignmentValue == DefaultCodeFormatterConstants.INDENT_BY_ONE) { indentSize= 1; } else if (binaryAlignmentValue == DefaultCodeFormatterConstants.INDENT_ON_COLUMN) { // there is no obvious way to work out the current column indent } // generate indentation string with correct size return CodeFormatterUtil.createIndentString(indentSize, fProject); }
/** * Returns extra indentation string for strings that are broken by a newline * based on the value of the formatter preferences for tabs vs. spaces. * * @return two tabs or equivalent number of spaces */ private String getExtraIndentAfterNewLine() { // read settings int formatterContinuationIndentationSize= getContinuationIndentationSize(); int binaryAlignmentValue= getBinaryOperatorAlignmentStyle(); // work out indent int indentSize= formatterContinuationIndentationSize; if (binaryAlignmentValue == DefaultCodeFormatterConstants.INDENT_BY_ONE) { indentSize= 1; } else if (binaryAlignmentValue == DefaultCodeFormatterConstants.INDENT_ON_COLUMN) { // there is no obvious way to work out the current column indent } // generate indentation string with correct size return CodeFormatterUtil.createIndentString(indentSize, fProject); }
private void indent(IDocument document) throws BadLocationException, MalformedTreeException { // first line int offset= document.getLineOffset(0); document.replace(offset, 0, CodeFormatterUtil.createIndentString(fInitialIndentLevel, fProject)); // following lines int lineCount= document.getNumberOfLines(); IndentUtil.indentLines(document, new LineRange(1, lineCount - 1), fProject, null); } }
private void indent(IDocument document) throws BadLocationException, MalformedTreeException { // first line int offset= document.getLineOffset(0); document.replace(offset, 0, CodeFormatterUtil.createIndentString(fInitialIndentLevel, fProject)); // following lines int lineCount= document.getNumberOfLines(); IndentUtil.indentLines(document, new LineRange(1, lineCount - 1), fProject, null); } }
private void indent(IDocument document) throws BadLocationException, MalformedTreeException { // first line int offset= document.getLineOffset(0); document.replace(offset, 0, CodeFormatterUtil.createIndentString(fInitialIndentLevel, fProject)); // following lines int lineCount= document.getNumberOfLines(); IndentUtil.indentLines(document, new LineRange(1, lineCount - 1), fProject, null); } }
replacement= Strings.changeIndent(replacement, 0, project, CodeFormatterUtil.createIndentString(indent, project), lineDelim); setReplacementString(replacement.substring(replacement.indexOf('(') + 1));
private String[] getBlocks(RangeMarker[] markers) throws BadLocationException { String[] result= new String[markers.length]; for (int i= 0; i < markers.length; i++) { RangeMarker marker= markers[i]; String content= fDocument.get(marker.getOffset(), marker.getLength()); String lines[]= Strings.convertIntoLines(content); Strings.trimIndentation(lines, fTypeRoot.getJavaProject(), false); if (fMarkerMode == STATEMENT_MODE && lines.length == 2 && isSingleControlStatementWithoutBlock()) { lines[1]= CodeFormatterUtil.createIndentString(1, fTypeRoot.getJavaProject()) + lines[1]; } result[i]= Strings.concatenate(lines, TextUtilities.getDefaultLineDelimiter(fDocument)); } return result; }
private String[] getBlocks(RangeMarker[] markers) throws BadLocationException { String[] result= new String[markers.length]; for (int i= 0; i < markers.length; i++) { RangeMarker marker= markers[i]; String content= fDocument.get(marker.getOffset(), marker.getLength()); String lines[]= Strings.convertIntoLines(content); Strings.trimIndentation(lines, fTypeRoot.getJavaProject(), false); if (fMarkerMode == STATEMENT_MODE && lines.length == 2 && isSingleControlStatementWithoutBlock()) { lines[1]= CodeFormatterUtil.createIndentString(1, fTypeRoot.getJavaProject()) + lines[1]; } result[i]= Strings.concatenate(lines, TextUtilities.getDefaultLineDelimiter(fDocument)); } return result; }
replacementString= replacementString + ';'; replacementString= Strings.changeIndent(replacementString, 0, project, CodeFormatterUtil.createIndentString(indent, project), lineDelim);
private String[] getBlocks(RangeMarker[] markers) throws BadLocationException { String[] result= new String[markers.length]; for (int i= 0; i < markers.length; i++) { RangeMarker marker= markers[i]; String content= fDocument.get(marker.getOffset(), marker.getLength()); String lines[]= Strings.convertIntoLines(content); Strings.trimIndentation(lines, fTypeRoot.getJavaProject(), false); if (fMarkerMode == STATEMENT_MODE && lines.length == 2 && isSingleControlStatementWithoutBlock()) { lines[1]= CodeFormatterUtil.createIndentString(1, fTypeRoot.getJavaProject()) + lines[1]; } result[i]= Strings.concatenate(lines, TextUtilities.getDefaultLineDelimiter(fDocument)); } return result; }
replacementString= replacementString + ';'; replacementString= Strings.changeIndent(replacementString, 0, project, CodeFormatterUtil.createIndentString(indent, project), lineDelim);