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 preceding whitespaces.
@param kind Use to specify the kind of the code snippet to format. It canbe any of these:
- {@link #K_EXPRESSION}
- {@link #K_STATEMENTS}
- {@link #K_CLASS_BODY_DECLARATIONS}
- {@link #K_COMPILATION_UNIT}
Since 3.4, the comments can be formatted on the fly while using this kind of code snippet
(see {@link #F_INCLUDE_COMMENTS} for more detailed explanation onthis flag) - {@link #K_UNKNOWN}
- {@link #K_SINGLE_LINE_COMMENT}
- {@link #K_MULTI_LINE_COMMENT}
- {@link #K_JAVA_DOC}
@param source the source to format
@param offset the given offset to start recording the edits (inclusive).
@param length the given length to stop recording the edits (exclusive).
@param indentationLevel the initial indentation level, usedto shift left/right the entire source fragment. An initial indentation level of zero or below has no effect.
@param lineSeparator the line separator to use in formatted source,if set to
null
, then the platform default one will be used.
@return the text edit
@throws IllegalArgumentException if offset is lower than 0, length is lower than 0 orlength is greater than source length.