org.eclipse.cdt.internal.formatter
Class CCodeFormatter
java.lang.Object
org.eclipse.cdt.core.formatter.CodeFormatter
org.eclipse.cdt.internal.formatter.CCodeFormatter
public class CCodeFormatter
- extends CodeFormatter
Method Summary |
java.lang.String |
createIndentationString(int indentationLevel)
Answers the string that corresponds to the indentation to the given indentation level or an empty string
if the indentation cannot be computed. |
org.eclipse.text.edits.TextEdit |
format(int kind,
java.lang.String source,
int offset,
int length,
int indentationLevel,
java.lang.String lineSeparator)
Format source ,
and returns a text edit that correspond to the difference between the given string and the formatted string. |
void |
setOptions(java.util.Map options)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CCodeFormatter
public CCodeFormatter()
CCodeFormatter
public CCodeFormatter(DefaultCodeFormatterOptions preferences)
CCodeFormatter
public CCodeFormatter(DefaultCodeFormatterOptions defaultCodeFormatterOptions,
java.util.Map options)
CCodeFormatter
public CCodeFormatter(java.util.Map options)
createIndentationString
public java.lang.String createIndentationString(int indentationLevel)
- Description copied from class:
CodeFormatter
- Answers the string that corresponds to the indentation to the given indentation level or an empty string
if the indentation cannot be computed.
This method needs to be overriden in a subclass.
The default implementation returns an empty string.
- Overrides:
createIndentationString
in class CodeFormatter
- Parameters:
indentationLevel
- the given indentation level
- Returns:
- the string corresponding to the right indentation level
setOptions
public void setOptions(java.util.Map options)
- Specified by:
setOptions
in class CodeFormatter
- Parameters:
options
- - general formatter options
format
public org.eclipse.text.edits.TextEdit format(int kind,
java.lang.String source,
int offset,
int length,
int indentationLevel,
java.lang.String lineSeparator)
- Description copied from class:
CodeFormatter
- Format
source
,
and returns a text edit that correspond to the difference between the given string and the formatted string.
It returns null if the given string cannot be formatted.
If the offset position is matching a whitespace, the result can include whitespaces. It would be up to the
caller to get rid of preceeding whitespaces.
- Specified by:
format
in class CodeFormatter
- Parameters:
kind
- Use to specify the kind of the code snippet to format. It can be any of these:
K_EXPRESSION, K_STATEMENTS, K_CLASS_BODY_DECLARATIONS, K_COMPILATION_UNIT, K_UNKNOWNsource
- the document to formatoffset
- the given offset to start recording the edits (inclusive).length
- the given length to stop recording the edits (exclusive).indentationLevel
- the initial indentation level, used
to shift left/right the entire source fragment. An initial indentation
level of zero or below has no effect.lineSeparator
- the line separator to use in formatted source,
if set to null
, then the platform default one will be used.
- Returns:
- the text edit