Example usage for org.eclipse.jdt.core.formatter IndentManipulation extractIndentString

List of usage examples for org.eclipse.jdt.core.formatter IndentManipulation extractIndentString

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.formatter IndentManipulation extractIndentString.

Prototype

public static String extractIndentString(String line, int tabWidth, int indentWidth) 

Source Link

Document

Returns the leading indentation string of the given line.

Usage

From source file:jmockit.assist.MockMethodCompletionProposal.java

License:Open Source License

private static String getIndentAt(final IDocument document, final int offset,
        final CodeGenerationSettings settings) {
    try {/*ww w  .  jav  a2 s. c  o  m*/
        IRegion region = document.getLineInformationOfOffset(offset);
        return IndentManipulation.extractIndentString(document.get(region.getOffset(), region.getLength()),
                settings.tabWidth, settings.indentWidth);
    } catch (BadLocationException e) {
        return "";
    }
}

From source file:org.eclipse.objectteams.otdt.internal.ui.assist.CompletionAdaptor.OverrideRoleCompletionProposal.java

License:Open Source License

private static String getIndentAt(IDocument document, int offset, CodeGenerationSettings settings) {
        try {/*  w  ww .  ja  v  a 2  s.c om*/
            IRegion region = document.getLineInformationOfOffset(offset);
            return IndentManipulation.extractIndentString(document.get(region.getOffset(), region.getLength()),
                    settings.tabWidth, settings.indentWidth);
        } catch (BadLocationException e) {
            return ""; //$NON-NLS-1$
        }
    }

From source file:org.jboss.tools.websockets.ui.internal.ca.MethodCompletionProposal.java

License:Open Source License

private static String getIndentAt(IDocument document, int offset, CodeGenerationSettings settings) {
    try {/*w ww .j a  v  a  2  s  .  com*/
        IRegion region = document.getLineInformationOfOffset(offset);
        return IndentManipulation.extractIndentString(document.get(region.getOffset(), region.getLength()),
                settings.tabWidth, settings.indentWidth);
    } catch (BadLocationException e) {
        return ""; //$NON-NLS-1$
    }
}

From source file:org.limy.eclipse.code.javadoc.LimyAddJavadocOperation.java

License:Open Source License

/**
 * R?gCfg?B//from  w  w w  .j a v a 2  s.  co m
 * @param javaElement JavaNX
 * @param member ?o
 * @param document hL?g
 * @param lineDelim f~^
 * @param comment R?g
 * @return Cfg
 * @throws BadLocationException hL?gO
 * @throws CoreException RAO
 */
private String createIndentedComment(IJavaElement javaElement, IMember member, IDocument document,
        String lineDelim) throws BadLocationException, CoreException {

    // JavadocR?g??
    String comment = createComment(member, lineDelim);

    // v?WFNgL^u?
    int tabWidth = LimyJavaUtils.getTabWidth(javaElement.getJavaProject());

    // ?o`u?se
    IRegion region = document.getLineInformationOfOffset(LimyJavaUtils.getMemberStartOffset(member, document));
    String line = document.get(region.getOffset(), region.getLength());

    String indentString = IndentManipulation.extractIndentString(line, tabWidth, tabWidth);

    // R?gCfg
    return IndentManipulation.changeIndent(comment, 0, tabWidth, tabWidth, indentString, lineDelim);
}