org.eclipse.cdt.internal.corext.util
Class CodeFormatterUtil

java.lang.Object
  extended by org.eclipse.cdt.internal.corext.util.CodeFormatterUtil

public class CodeFormatterUtil
extends java.lang.Object


Constructor Summary
CodeFormatterUtil()
           
 
Method Summary
static java.lang.String createIndentString(int indentationUnits, org.eclipse.cdt.core.model.ICProject project)
          Creates a string that represents the given number of indentation units.
static org.eclipse.text.edits.TextEdit format(int kind, java.lang.String source, int offset, int length, int indentationLevel, java.lang.String lineSeparator, java.util.Map options)
          Creates edits that describe how to format the given string.
static org.eclipse.text.edits.TextEdit format(int kind, java.lang.String source, int indentationLevel, java.lang.String lineSeparator, java.util.Map options)
           
static int getIndentWidth(org.eclipse.cdt.core.model.ICProject project)
          Returns the current indent width.
static int getTabWidth()
           
static int getTabWidth(org.eclipse.cdt.core.model.ICProject project)
          Gets the current tab width.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeFormatterUtil

public CodeFormatterUtil()
Method Detail

createIndentString

public static java.lang.String createIndentString(int indentationUnits,
                                                  org.eclipse.cdt.core.model.ICProject project)
Creates a string that represents the given number of indentation units. The returned string can contain tabs and/or spaces depending on the core formatter preferences.

Parameters:
indentationUnits - the number of indentation units to generate
project - the project from which to get the formatter settings, null if the workspace default should be used
Returns:
the indent string

getTabWidth

public static int getTabWidth(org.eclipse.cdt.core.model.ICProject project)
Gets the current tab width.

Parameters:
project - The project where the source is used, used for project specific options or null if the project is unknown and the workspace default should be used
Returns:
The tab width

getIndentWidth

public static int getIndentWidth(org.eclipse.cdt.core.model.ICProject project)
Returns the current indent width.

Parameters:
project - the project where the source is used or null if the project is unknown and the workspace default should be used
Returns:
the indent width

format

public static org.eclipse.text.edits.TextEdit format(int kind,
                                                     java.lang.String source,
                                                     int offset,
                                                     int length,
                                                     int indentationLevel,
                                                     java.lang.String lineSeparator,
                                                     java.util.Map options)
Creates edits that describe how to format the given string. Returns null if the code could not be formatted for the given kind.

Throws:
java.lang.IllegalArgumentException - If the offset and length are not inside the string, a IllegalArgumentException is thrown.

format

public static org.eclipse.text.edits.TextEdit format(int kind,
                                                     java.lang.String source,
                                                     int indentationLevel,
                                                     java.lang.String lineSeparator,
                                                     java.util.Map options)

getTabWidth

public static int getTabWidth()
Returns:
The formatter tab width on workspace level.