Klasse DefaultCodeFormatter
-
Feldübersicht
Von Klasse geerbte Felder org.aspectj.org.eclipse.jdt.core.formatter.CodeFormatter
F_INCLUDE_COMMENTS, K_CLASS_BODY_DECLARATIONS, K_COMPILATION_UNIT, K_EXPRESSION, K_JAVA_DOC, K_MODULE_INFO, K_MULTI_LINE_COMMENT, K_SINGLE_LINE_COMMENT, K_STATEMENTS, K_UNKNOWN
-
Konstruktorübersicht
KonstruktorBeschreibungDefaultCodeFormatter
(Map<String, String> options) DefaultCodeFormatter
(DefaultCodeFormatterOptions defaultCodeFormatterOptions, Map<String, String> options) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungcreateIndentationString
(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
Formatsource
, 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, String source, org.eclipse.jface.text.IRegion[] regions, int indentationLevel, String lineSeparator) Formatsource
, and returns a text edit that correspond to the difference between the given string and the formatted string.void
setOptions
(Map<String, String> options) Sets the formatting options for this formatter.
-
Felddetails
-
DEBUG
public static boolean DEBUGDebug trace -
previewEnabled
public boolean previewEnabled
-
-
Konstruktordetails
-
DefaultCodeFormatter
public DefaultCodeFormatter() -
DefaultCodeFormatter
-
DefaultCodeFormatter
-
DefaultCodeFormatter
public DefaultCodeFormatter(DefaultCodeFormatterOptions defaultCodeFormatterOptions, Map<String, String> options)
-
-
Methodendetails
-
createIndentationString
Beschreibung aus Klasse kopiert: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 overridden in a subclass.
The default implementation returns an empty string.
- Setzt außer Kraft:
createIndentationString
in KlasseCodeFormatter
- Parameter:
indentationLevel
- the given indentation level- Gibt zurück:
- the string corresponding to the right indentation level
-
format
public org.eclipse.text.edits.TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator) Beschreibung aus Klasse kopiert:CodeFormatter
Formatsource
, 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.
- Angegeben von:
format
in KlasseCodeFormatter
- Parameter:
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.K_MODULE_INFO
CodeFormatter.K_UNKNOWN
CodeFormatter.K_SINGLE_LINE_COMMENT
CodeFormatter.K_MULTI_LINE_COMMENT
CodeFormatter.K_JAVA_DOC
CodeFormatter.K_COMPILATION_UNIT
and since 3.6 for other kinds unrelated to comments, theCodeFormatter.F_INCLUDE_COMMENTS
flag can be used to format comments on the fly (see the flag documentation for more detailed explanation).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 tonull
, then the platform default one will be used.- Gibt zurück:
- the text edit
- Siehe auch:
-
format
public org.eclipse.text.edits.TextEdit format(int kind, String source, org.eclipse.jface.text.IRegion[] regions, int indentationLevel, String lineSeparator) Formatsource
, 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 inregions
. Each region must be within source. There must be at least one region. Regions must be sorted by their offsets, smaller offset first.- Angegeben von:
format
in KlasseCodeFormatter
- Parameter:
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.K_MODULE_INFO
CodeFormatter.K_UNKNOWN
CodeFormatter.K_SINGLE_LINE_COMMENT
CodeFormatter.K_MULTI_LINE_COMMENT
CodeFormatter.K_JAVA_DOC
CodeFormatter.K_COMPILATION_UNIT
and since 3.6 for other kinds unrelated to comments, theCodeFormatter.F_INCLUDE_COMMENTS
flag can be used to format comments on the fly (see the flag documentation for more detailed explanation).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 tonull
, then the platform default one will be used.- Gibt zurück:
- the text edit
-
setOptions
Beschreibung aus Klasse kopiert:CodeFormatter
Sets the formatting options for this formatter.The default implementation ignores the options.
- Setzt außer Kraft:
setOptions
in KlasseCodeFormatter
- Parameter:
options
- the options for the formatter
-