|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.wst.jsdt.core.formatter.CodeFormatter
public abstract class CodeFormatter
Specification for a generic source code formatter. Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
Field Summary | |
---|---|
static int |
K_CLASS_BODY_DECLARATIONS
Kind used to format a set of class body declarations |
static int |
K_EXPRESSION
Kind used to format an expression |
static int |
K_JAVA_DOC
Kind used to format a jsdoc comment |
static int |
K_JAVASCRIPT_UNIT
Kind used to format a javascript unit |
static int |
K_MULTI_LINE_COMMENT
Kind used to format a multi-line comment |
static int |
K_SINGLE_LINE_COMMENT
Kind used to format a single-line comment |
static int |
K_STATEMENTS
Kind used to format a set of statements |
static int |
K_UNKNOWN
Unknown kind |
Constructor Summary | |
---|---|
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. |
abstract 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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int K_UNKNOWN
public static final int K_EXPRESSION
public static final int K_STATEMENTS
public static final int K_CLASS_BODY_DECLARATIONS
public static final int K_JAVASCRIPT_UNIT
public static final int K_SINGLE_LINE_COMMENT
public static final int K_MULTI_LINE_COMMENT
public static final int K_JAVA_DOC
Constructor Detail |
---|
public CodeFormatter()
Method Detail |
---|
public abstract TextEdit format(int kind, java.lang.String source, int offset, int length, 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 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.
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_JAVASCRIPT_UNIT, K_UNKNOWN,
K_SINGLE_LINE_COMMENT, K_MULTI_LINE_COMMENT, K_JAVA_DOCsource
- 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.
java.lang.IllegalArgumentException
- if offset is lower than 0, length is lower than 0 or
length is greater than source length.public java.lang.String createIndentationString(int indentationLevel)
This method needs to be overriden in a subclass.
The default implementation returns an empty string.
indentationLevel
- the given indentation level
java.lang.IllegalArgumentException
- if the given indentation level is lower than zero
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |