/** * Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added. * The first line of the code will not be changed. (It is considered to have no indent as it might start in * the middle of a line) * @since 3.1 */ public static String changeIndent(String code, int codeIndentLevel, int tabWidth, int indentWidth, String newIndent, String lineDelim) { return IndentManipulation.changeIndent(code, codeIndentLevel, tabWidth, indentWidth, newIndent, lineDelim); }
public String changeIndent(String code, int codeIndentLevel, String newIndent) { return IndentManipulation.changeIndent(code, codeIndentLevel, this.tabWidth, this.indentWidth, newIndent, this.lineDelimiter); }
public String changeIndent(String code, int codeIndentLevel, String newIndent) { return IndentManipulation.changeIndent(code, codeIndentLevel, this.tabWidth, this.indentWidth, newIndent, this.lineDelimiter); }
public String changeIndent(String code, int codeIndentLevel, String newIndent) { return IndentManipulation.changeIndent(code, codeIndentLevel, this.tabWidth, this.indentWidth, newIndent, this.lineDelimiter); }
public String changeIndent(String code, int codeIndentLevel, String newIndent) { return IndentManipulation.changeIndent(code, codeIndentLevel, this.tabWidth, this.indentWidth, newIndent, this.lineDelimiter); }
public String changeIndent(String code, int codeIndentLevel, String newIndent) { return IndentManipulation.changeIndent(code, codeIndentLevel, this.tabWidth, this.indentWidth, newIndent, this.lineDelimiter); }
public String changeIndent(String code, int codeIndentLevel, String newIndent) { return IndentManipulation.changeIndent(code, codeIndentLevel, this.tabWidth, this.indentWidth, newIndent, this.lineDelimiter); }
/** * Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added. * The first line of the code will not be changed. (It is considered to have no indent as it might start in * the middle of a line) * @param code the code * @param codeIndentLevel indent level * @param tabWidth the size of one tab in space equivalents * @param indentWidth the size of the indent in space equivalents * @param newIndent new indent * @param lineDelim line delimiter * @return the changed code * @since 3.1 */ public static String changeIndent(String code, int codeIndentLevel, int tabWidth, int indentWidth, String newIndent, String lineDelim) { return IndentManipulation.changeIndent(code, codeIndentLevel, tabWidth, indentWidth, newIndent, lineDelim); }
/** * Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added. * The first line of the code will not be changed. (It is considered to have no indent as it might start in * the middle of a line) * @param code the code * @param codeIndentLevel indent level * @param tabWidth the size of one tab in space equivalents * @param indentWidth the size of the indent in space equivalents * @param newIndent new indent * @param lineDelim line delimiter * @return the changed code * @since 3.1 */ public static String changeIndent(String code, int codeIndentLevel, int tabWidth, int indentWidth, String newIndent, String lineDelim) { return IndentManipulation.changeIndent(code, codeIndentLevel, tabWidth, indentWidth, newIndent, lineDelim); }
/** * Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added. * The first line of the code will not be changed. (It is considered to have no indent as it might start in * the middle of a line) * * @param project the java project from which to get the formatter * preferences, or <code>null</code> for global preferences * @since 3.1 */ public static String changeIndent(String code, int codeIndentLevel, IJavaProject project, String newIndent, String lineDelim) { return IndentManipulation.changeIndent(code, codeIndentLevel, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), newIndent, lineDelim); }
/** * Change the indent of, possible multi-line, code range. The current indent is removed, a new indent added. * The first line of the code will not be changed. (It is considered to have no indent as it might start in * the middle of a line) * @param code the code * @param codeIndentLevel level of indentation * * @param project the java project from which to get the formatter * preferences, or <code>null</code> for global preferences * @param newIndent new indent * @param lineDelim line delimiter * @return the changed code * @since 3.1 */ public static String changeIndent(String code, int codeIndentLevel, IJavaProject project, String newIndent, String lineDelim) { return IndentManipulation.changeIndent(code, codeIndentLevel, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), newIndent, lineDelim); }
/** * Change the indent of, possible multi-line, code range. The current indent is removed, a new indent added. * The first line of the code will not be changed. (It is considered to have no indent as it might start in * the middle of a line) * @param code the code * @param codeIndentLevel level of indentation * * @param project the java project from which to get the formatter * preferences, or <code>null</code> for global preferences * @param newIndent new indent * @param lineDelim line delimiter * @return the changed code * @since 3.1 */ public static String changeIndent(String code, int codeIndentLevel, IJavaProject project, String newIndent, String lineDelim) { return IndentManipulation.changeIndent(code, codeIndentLevel, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), newIndent, lineDelim); }
private String removeIndentAndNewLines(String code, ICompilationUnit cu) throws JavaModelException { IJavaProject project = cu.getJavaProject(); Map options = project.getOptions(true/*inherit JavaCore options*/); int tabWidth = IndentManipulation.getTabWidth(options); int indentWidth = IndentManipulation.getIndentWidth(options); int indent = IndentManipulation.measureIndentUnits(code, tabWidth, indentWidth); int firstNonWhiteSpace = -1; int length = code.length(); while (firstNonWhiteSpace < length-1) if (!ScannerHelper.isWhitespace(code.charAt(++firstNonWhiteSpace))) break; int lastNonWhiteSpace = length; while (lastNonWhiteSpace > 0) if (!ScannerHelper.isWhitespace(code.charAt(--lastNonWhiteSpace))) break; String lineDelimiter = cu.findRecommendedLineSeparator(); return IndentManipulation.changeIndent(code.substring(firstNonWhiteSpace, lastNonWhiteSpace+1), indent, tabWidth, indentWidth, "", lineDelimiter); //$NON-NLS-1$ } /*
private String removeIndentAndNewLines(String code, ICompilationUnit cu) throws JavaModelException { IJavaProject project = cu.getJavaProject(); Map options = project.getOptions(true/*inherit JavaCore options*/); int tabWidth = IndentManipulation.getTabWidth(options); int indentWidth = IndentManipulation.getIndentWidth(options); int indent = IndentManipulation.measureIndentUnits(code, tabWidth, indentWidth); int firstNonWhiteSpace = -1; int length = code.length(); while (firstNonWhiteSpace < length-1) if (!ScannerHelper.isWhitespace(code.charAt(++firstNonWhiteSpace))) break; int lastNonWhiteSpace = length; while (lastNonWhiteSpace > 0) if (!ScannerHelper.isWhitespace(code.charAt(--lastNonWhiteSpace))) break; String lineDelimiter = cu.findRecommendedLineSeparator(); return IndentManipulation.changeIndent(code.substring(firstNonWhiteSpace, lastNonWhiteSpace+1), indent, tabWidth, indentWidth, "", lineDelimiter); //$NON-NLS-1$ } /*
private String removeIndentAndNewLines(String code, ICompilationUnit cu) throws JavaModelException { IJavaProject project = cu.getJavaProject(); Map options = project.getOptions(true/*inherit JavaCore options*/); int tabWidth = IndentManipulation.getTabWidth(options); int indentWidth = IndentManipulation.getIndentWidth(options); int indent = IndentManipulation.measureIndentUnits(code, tabWidth, indentWidth); int firstNonWhiteSpace = -1; int length = code.length(); while (firstNonWhiteSpace < length-1) if (!ScannerHelper.isWhitespace(code.charAt(++firstNonWhiteSpace))) break; int lastNonWhiteSpace = length; while (lastNonWhiteSpace > 0) if (!ScannerHelper.isWhitespace(code.charAt(--lastNonWhiteSpace))) break; String lineDelimiter = cu.findRecommendedLineSeparator(); return IndentManipulation.changeIndent(code.substring(firstNonWhiteSpace, lastNonWhiteSpace+1), indent, tabWidth, indentWidth, "", lineDelimiter); //$NON-NLS-1$ } /*
private String removeIndentAndNewLines(String code, ICompilationUnit cu) throws JavaModelException { IJavaProject project = cu.getJavaProject(); Map options = project.getOptions(true/*inherit JavaCore options*/); int tabWidth = IndentManipulation.getTabWidth(options); int indentWidth = IndentManipulation.getIndentWidth(options); int indent = IndentManipulation.measureIndentUnits(code, tabWidth, indentWidth); int firstNonWhiteSpace = -1; int length = code.length(); while (firstNonWhiteSpace < length-1) if (!ScannerHelper.isWhitespace(code.charAt(++firstNonWhiteSpace))) break; int lastNonWhiteSpace = length; while (lastNonWhiteSpace > 0) if (!ScannerHelper.isWhitespace(code.charAt(--lastNonWhiteSpace))) break; String lineDelimiter = cu.findRecommendedLineSeparator(); return IndentManipulation.changeIndent(code.substring(firstNonWhiteSpace, lastNonWhiteSpace+1), indent, tabWidth, indentWidth, "", lineDelimiter); //$NON-NLS-1$ } /*
private String removeIndentAndNewLines(String code, ICompilationUnit cu) throws JavaModelException { IJavaProject project = cu.getJavaProject(); Map options = project.getOptions(true/*inherit JavaCore options*/); int tabWidth = IndentManipulation.getTabWidth(options); int indentWidth = IndentManipulation.getIndentWidth(options); int indent = IndentManipulation.measureIndentUnits(code, tabWidth, indentWidth); int firstNonWhiteSpace = -1; int length = code.length(); while (firstNonWhiteSpace < length-1) if (!ScannerHelper.isWhitespace(code.charAt(++firstNonWhiteSpace))) break; int lastNonWhiteSpace = length; while (lastNonWhiteSpace > 0) if (!ScannerHelper.isWhitespace(code.charAt(--lastNonWhiteSpace))) break; String lineDelimiter = cu.findRecommendedLineSeparator(); return IndentManipulation.changeIndent(code.substring(firstNonWhiteSpace, lastNonWhiteSpace+1), indent, tabWidth, indentWidth, "", lineDelimiter); //$NON-NLS-1$ } /*
private String removeIndentAndNewLines(String code, ICompilationUnit cu) throws JavaModelException { IJavaProject project = cu.getJavaProject(); Map options = project.getOptions(true/*inherit JavaCore options*/); int tabWidth = IndentManipulation.getTabWidth(options); int indentWidth = IndentManipulation.getIndentWidth(options); int indent = IndentManipulation.measureIndentUnits(code, tabWidth, indentWidth); int firstNonWhiteSpace = -1; int length = code.length(); while (firstNonWhiteSpace < length-1) if (!ScannerHelper.isWhitespace(code.charAt(++firstNonWhiteSpace))) break; int lastNonWhiteSpace = length; while (lastNonWhiteSpace > 0) if (!ScannerHelper.isWhitespace(code.charAt(--lastNonWhiteSpace))) break; String lineDelimiter = cu.findRecommendedLineSeparator(); return IndentManipulation.changeIndent(code.substring(firstNonWhiteSpace, lastNonWhiteSpace+1), indent, tabWidth, indentWidth, "", lineDelimiter); //$NON-NLS-1$ } /*
private String generateMethodDeclaration(final IDocument document, final Document recoveredDocument, final ASTNode node, final ASTRewrite rewrite, final CodeGenerationSettings settings, final MethodDeclaration stub) throws BadLocationException { ChildListPropertyDescriptor descriptor = getPropDescriptor(node); ListRewrite rewriter = rewrite.getListRewrite(node, descriptor); rewriter.insertFirst(stub, null); ITrackedNodePosition position = rewrite.track(stub); rewrite.rewriteAST(recoveredDocument, fJavaProject.getOptions(true)).apply(recoveredDocument); String generatedCode = recoveredDocument.get(position.getStartPosition(), position.getLength()); int generatedIndent = IndentManipulation.measureIndentUnits( getIndentAt(recoveredDocument, position.getStartPosition(), settings), settings.tabWidth, settings.indentWidth); String indent = getIndentAt(document, getReplacementOffset(), settings); String methodDeclarationText = IndentManipulation.changeIndent(generatedCode, generatedIndent, settings.tabWidth, settings.indentWidth, indent, TextUtilities.getDefaultLineDelimiter(document)); return methodDeclarationText; }
result = IndentManipulation.changeIndent(generatedCode, generatedIndent, settings.tabWidth, settings.indentWidth, "", delimiter);