|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jdt.core.formatter.CodeFormatter
org.eclipse.jdt.internal.formatter.DefaultCodeFormatter
public class DefaultCodeFormatter
Field Summary | |
---|---|
static boolean |
DEBUG
Debug trace |
static boolean |
ENABLE_NEW_COMMENTS_FORMAT
|
Fields inherited from class org.eclipse.jdt.core.formatter.CodeFormatter |
---|
F_INCLUDE_COMMENTS, K_CLASS_BODY_DECLARATIONS, K_COMPILATION_UNIT, K_EXPRESSION, K_JAVA_DOC, K_MULTI_LINE_COMMENT, K_SINGLE_LINE_COMMENT, K_STATEMENTS, K_UNKNOWN |
Constructor Summary | |
---|---|
DefaultCodeFormatter()
|
|
DefaultCodeFormatter(DefaultCodeFormatterOptions preferences)
|
|
DefaultCodeFormatter(DefaultCodeFormatterOptions defaultCodeFormatterOptions,
java.util.Map options)
|
|
DefaultCodeFormatter(java.util.Map options)
|
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. |
static CommentRegion |
createRegion(int kind,
org.eclipse.jface.text.IDocument document,
org.eclipse.jface.text.Position range,
CodeFormatterVisitor formatter)
Creates a comment region for a specific document partition type. |
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. |
org.eclipse.text.edits.TextEdit |
format(int kind,
java.lang.String source,
org.eclipse.jface.text.IRegion[] regions,
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. |
java.lang.String |
getDebugOutput()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean DEBUG
public static boolean ENABLE_NEW_COMMENTS_FORMAT
Constructor Detail |
---|
public DefaultCodeFormatter()
public DefaultCodeFormatter(DefaultCodeFormatterOptions preferences)
public DefaultCodeFormatter(DefaultCodeFormatterOptions defaultCodeFormatterOptions, java.util.Map options)
public DefaultCodeFormatter(java.util.Map options)
Method Detail |
---|
public static CommentRegion createRegion(int kind, org.eclipse.jface.text.IDocument document, org.eclipse.jface.text.Position range, CodeFormatterVisitor formatter)
kind
- the comment snippet kinddocument
- the document which contains the comment regionrange
- range of the comment region in the document
public java.lang.String createIndentationString(int indentationLevel)
CodeFormatter
This method needs to be overridden in a subclass.
The default implementation returns an empty string.
createIndentationString
in class CodeFormatter
indentationLevel
- the given indentation level
public org.eclipse.text.edits.TextEdit format(int kind, java.lang.String source, int offset, int length, int indentationLevel, java.lang.String lineSeparator)
CodeFormatter
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 preceding whitespaces.
format
in class CodeFormatter
kind
- Use to specify the kind of the code snippet to format. It can
be any of these:
CodeFormatter.K_EXPRESSION
CodeFormatter.K_STATEMENTS
CodeFormatter.K_CLASS_BODY_DECLARATIONS
CodeFormatter.K_COMPILATION_UNIT
CodeFormatter.F_INCLUDE_COMMENTS
for more detailed explanation on
this flag)
CodeFormatter.K_UNKNOWN
CodeFormatter.K_SINGLE_LINE_COMMENT
CodeFormatter.K_MULTI_LINE_COMMENT
CodeFormatter.K_JAVA_DOC
source
- the source 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.
CodeFormatter.format(int, java.lang.String, int, int, int, java.lang.String)
public org.eclipse.text.edits.TextEdit format(int kind, java.lang.String source, org.eclipse.jface.text.IRegion[] regions, int indentationLevel, java.lang.String lineSeparator)
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 an offset position is matching a whitespace, the result can include whitespaces. It would be up to the caller to get rid of preceding whitespaces.
No region in regions
must overlap with any other region in regions
.
Each region must be within source. There must be at least one region. Regions must be sorted
by their offsets, smaller offset first.
format
in class CodeFormatter
kind
- Use to specify the kind of the code snippet to format. It can
be any of these:
CodeFormatter.K_EXPRESSION
CodeFormatter.K_STATEMENTS
CodeFormatter.K_CLASS_BODY_DECLARATIONS
CodeFormatter.K_COMPILATION_UNIT
CodeFormatter.F_INCLUDE_COMMENTS
for more detailed explanation on
this flag)
CodeFormatter.K_UNKNOWN
CodeFormatter.K_SINGLE_LINE_COMMENT
CodeFormatter.K_MULTI_LINE_COMMENT
CodeFormatter.K_JAVA_DOC
source
- the source to formatregions
- a set of regions in source to formatindentationLevel
- 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.
public java.lang.String getDebugOutput()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |