Klasse DefaultCodeFormatter
-
Feldübersicht
FelderVon 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
KonstruktorenKonstruktorBeschreibungDefaultCodeFormatter(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.TextEditFormatsource, and returns a text edit that correspond to the difference between the given string and the formatted string.org.eclipse.text.edits.TextEditformat(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.voidsetOptions(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:CodeFormatterAnswers 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:
createIndentationStringin 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:CodeFormatterFormatsource, 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:
formatin KlasseCodeFormatter- Parameter:
kind- Use to specify the kind of the code snippet to format. It can be any of these:CodeFormatter.K_EXPRESSIONCodeFormatter.K_STATEMENTSCodeFormatter.K_CLASS_BODY_DECLARATIONSCodeFormatter.K_COMPILATION_UNITCodeFormatter.K_MODULE_INFOCodeFormatter.K_UNKNOWNCodeFormatter.K_SINGLE_LINE_COMMENTCodeFormatter.K_MULTI_LINE_COMMENTCodeFormatter.K_JAVA_DOC
CodeFormatter.K_COMPILATION_UNITand since 3.6 for other kinds unrelated to comments, theCodeFormatter.F_INCLUDE_COMMENTSflag 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
regionsmust 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:
formatin KlasseCodeFormatter- Parameter:
kind- Use to specify the kind of the code snippet to format. It can be any of these:CodeFormatter.K_EXPRESSIONCodeFormatter.K_STATEMENTSCodeFormatter.K_CLASS_BODY_DECLARATIONSCodeFormatter.K_COMPILATION_UNITCodeFormatter.K_MODULE_INFOCodeFormatter.K_UNKNOWNCodeFormatter.K_SINGLE_LINE_COMMENTCodeFormatter.K_MULTI_LINE_COMMENTCodeFormatter.K_JAVA_DOC
CodeFormatter.K_COMPILATION_UNITand since 3.6 for other kinds unrelated to comments, theCodeFormatter.F_INCLUDE_COMMENTSflag 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:CodeFormatterSets the formatting options for this formatter.The default implementation ignores the options.
- Setzt außer Kraft:
setOptionsin KlasseCodeFormatter- Parameter:
options- the options for the formatter
-