/** * Returns the indent of the given string in indentation units. Odd spaces * are not counted. * * @param line the text line * @param tabWidth the width of the '\t' character in space equivalents * @param indentWidth the width of one indentation unit in space equivalents * @since 3.1 */ public static int computeIndentUnits(String line, int tabWidth, int indentWidth) { return IndentManipulation.measureIndentUnits(line, tabWidth, indentWidth); }
public int computeIndentUnits(String line) { return IndentManipulation.measureIndentUnits(line, this.tabWidth, this.indentWidth); }
/** * Returns the indent of the given string in indentation units. Odd spaces * are not counted. * * @param line the text line * @param tabWidth the width of the '\t' character in space equivalents * @param indentWidth the width of one indentation unit in space equivalents * @return the indent of the given string in indentation units * * @since 3.1 */ public static int computeIndentUnits(String line, int tabWidth, int indentWidth) { return IndentManipulation.measureIndentUnits(line, tabWidth, indentWidth); }
public int computeIndentUnits(String line) { return IndentManipulation.measureIndentUnits(line, this.tabWidth, this.indentWidth); }
public int computeIndentUnits(String line) { return IndentManipulation.measureIndentUnits(line, this.tabWidth, this.indentWidth); }
public int computeIndentUnits(String line) { return IndentManipulation.measureIndentUnits(line, this.tabWidth, this.indentWidth); }
/** * Returns the indent of the given string in indentation units. Odd spaces * are not counted. * * @param line the text line * @param tabWidth the width of the '\t' character in space equivalents * @param indentWidth the width of one indentation unit in space equivalents * @return the indent of the given string in indentation units * * @since 3.1 */ public static int computeIndentUnits(String line, int tabWidth, int indentWidth) { return IndentManipulation.measureIndentUnits(line, tabWidth, indentWidth); }
public int computeIndentUnits(String line) { return IndentManipulation.measureIndentUnits(line, this.tabWidth, this.indentWidth); }
public int computeIndentUnits(String line) { return IndentManipulation.measureIndentUnits(line, this.tabWidth, this.indentWidth); }
public ReplaceEdit[] getModifications(String source) { List result= new ArrayList(); int destIndentLevel= IndentManipulation.measureIndentUnits(this.destinationIndent, this.tabWidth, this.indentWidth); if (destIndentLevel == this.sourceIndentLevel) { return (ReplaceEdit[])result.toArray(new ReplaceEdit[result.size()]); } return IndentManipulation.getChangeIndentEdits(source, this.sourceIndentLevel, this.tabWidth, this.indentWidth, this.destinationIndent); } }
@Override public ReplaceEdit[] getModifications(String source) { List result= new ArrayList(); int destIndentLevel= IndentManipulation.measureIndentUnits(this.destinationIndent, this.tabWidth, this.indentWidth); if (destIndentLevel == this.sourceIndentLevel) { return (ReplaceEdit[])result.toArray(new ReplaceEdit[result.size()]); } return IndentManipulation.getChangeIndentEdits(source, this.sourceIndentLevel, this.tabWidth, this.indentWidth, this.destinationIndent); } }
public ReplaceEdit[] getModifications(String source) { List result= new ArrayList(); int destIndentLevel= IndentManipulation.measureIndentUnits(this.destinationIndent, this.tabWidth, this.indentWidth); if (destIndentLevel == this.sourceIndentLevel) { return (ReplaceEdit[])result.toArray(new ReplaceEdit[result.size()]); } return IndentManipulation.getChangeIndentEdits(source, this.sourceIndentLevel, this.tabWidth, this.indentWidth, this.destinationIndent); } }
public ReplaceEdit[] getModifications(String source) { List result= new ArrayList(); int destIndentLevel= IndentManipulation.measureIndentUnits(this.destinationIndent, this.tabWidth, this.indentWidth); if (destIndentLevel == this.sourceIndentLevel) { return (ReplaceEdit[])result.toArray(new ReplaceEdit[result.size()]); } return IndentManipulation.getChangeIndentEdits(source, this.sourceIndentLevel, this.tabWidth, this.indentWidth, this.destinationIndent); } }
public ReplaceEdit[] getModifications(String source) { List result= new ArrayList(); int destIndentLevel= IndentManipulation.measureIndentUnits(this.destinationIndent, this.tabWidth, this.indentWidth); if (destIndentLevel == this.sourceIndentLevel) { return (ReplaceEdit[])result.toArray(new ReplaceEdit[result.size()]); } return IndentManipulation.getChangeIndentEdits(source, this.sourceIndentLevel, this.tabWidth, this.indentWidth, this.destinationIndent); } }
public ReplaceEdit[] getModifications(String source) { List result= new ArrayList(); int destIndentLevel= IndentManipulation.measureIndentUnits(this.destinationIndent, this.tabWidth, this.indentWidth); if (destIndentLevel == this.sourceIndentLevel) { return (ReplaceEdit[])result.toArray(new ReplaceEdit[result.size()]); } return IndentManipulation.getChangeIndentEdits(source, this.sourceIndentLevel, this.tabWidth, this.indentWidth, this.destinationIndent); } }
/** * Returns the indent of the given string in indentation units. Odd spaces * are not counted. * * @param line the text 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 int computeIndentUnits(String line, IJavaProject project) { return IndentManipulation.measureIndentUnits(line, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project)); }
/** * Returns the indent of the given string in indentation units. Odd spaces * are not counted. * * @param line the text line * @param project the java project from which to get the formatter * preferences, or <code>null</code> for global preferences * @return the number of indent units * @since 3.1 */ public static int computeIndentUnits(String line, IJavaProject project) { return IndentManipulation.measureIndentUnits(line, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project)); }
/** * Returns the indent of the given string in indentation units. Odd spaces * are not counted. * * @param line the text line * @param project the java project from which to get the formatter * preferences, or <code>null</code> for global preferences * @return the number of indent units * @since 3.1 */ public static int computeIndentUnits(String line, IJavaProject project) { return IndentManipulation.measureIndentUnits(line, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project)); }
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; }