|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.wst.jsdt.core.formatter.IndentManipulation
public final class IndentManipulation
Helper class to provide String manipulation functions dealing with indentations. 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.
Method Summary | |
---|---|
static java.lang.String |
changeIndent(java.lang.String code,
int indentUnitsToRemove,
int tabWidth,
int indentWidth,
java.lang.String newIndentString,
java.lang.String lineDelim)
Change the indent of a, possible multiple line, code string. |
static java.lang.String |
extractIndentString(java.lang.String line,
int tabWidth,
int indentWidth)
Returns the leading indentation string of the given line. |
static ReplaceEdit[] |
getChangeIndentEdits(java.lang.String source,
int indentUnitsToRemove,
int tabWidth,
int indentWidth,
java.lang.String newIndentString)
Returns the text edits retrieved after changing the indentation of a, possible multi-line, code string. |
static int |
getIndentWidth(java.util.Map options)
Returns the tab width as configured in the given map. |
static int |
getTabWidth(java.util.Map options)
Returns the tab width as configured in the given map. |
static boolean |
isIndentChar(char ch)
Returns true if the given character is an indentation character. |
static boolean |
isLineDelimiterChar(char ch)
Returns true if the given character is a line delimiter character. |
static int |
measureIndentInSpaces(java.lang.CharSequence line,
int tabWidth)
Returns the indentation of the given line in space equivalents. |
static int |
measureIndentUnits(java.lang.CharSequence line,
int tabWidth,
int indentWidth)
Returns the indentation of the given line in indentation units. |
static java.lang.String |
trimIndent(java.lang.String line,
int indentUnitsToRemove,
int tabWidth,
int indentWidth)
Removes the given number of indentation units from a given line. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean isIndentChar(char ch)
true
if the given character is an indentation character. Indentation character are all whitespace characters
except the line delimiter characters.
ch
- the given character
true
if this the character is a indent character, false
otherwisepublic static boolean isLineDelimiterChar(char ch)
true
if the given character is a line delimiter character.
ch
- the given character
true
if this the character is a line delimiter character, false
otherwisepublic static int measureIndentUnits(java.lang.CharSequence line, int tabWidth, int indentWidth)
line
up to the first
non-whitespace character.
line
- the string to measure the indent oftabWidth
- the width of one tab character in space equivalentsindentWidth
- the width of one indentation unit in space equivalents
java.lang.IllegalArgumentException
- if:
indentWidth
is lower or equals to zerotabWidth
is lower than zeroline
is nullpublic static int measureIndentInSpaces(java.lang.CharSequence line, int tabWidth)
Tab characters are counted using the given tabWidth
and every other indent
character as one. This method analyzes the content of line
up to the first
non-whitespace character.
line
- the string to measure the indent oftabWidth
- the width of one tab in space equivalents
java.lang.IllegalArgumentException
- if:
line
is nulltabWidth
is lower than zeropublic static java.lang.String extractIndentString(java.lang.String line, int tabWidth, int indentWidth)
line
- the line to scantabWidth
- the size of one tab in space equivalentsindentWidth
- the width of one indentation unit in space equivalents
line
, but no odd spaces
java.lang.IllegalArgumentException
- if:
indentWidth
is lower or equals to zerotabWidth
is lower than zeroline
is nullpublic static java.lang.String trimIndent(java.lang.String line, int indentUnitsToRemove, int tabWidth, int indentWidth)
indentsToRemove <= 0
the line is returned.
line
- the line to trimtabWidth
- the width of one tab in space equivalentsindentWidth
- the width of one indentation unit in space equivalents
java.lang.IllegalArgumentException
- if:
indentWidth
is lower or equals to zerotabWidth
is lower than zeroline
is nullpublic static java.lang.String changeIndent(java.lang.String code, int indentUnitsToRemove, int tabWidth, int indentWidth, java.lang.String newIndentString, java.lang.String lineDelim)
The first line of the code will not be changed (It is considered to have no indent as it might start in the middle of a line).
code
- the code to change the indent ofindentUnitsToRemove
- the number of indent units to remove from each line (except the first) of the given codetabWidth
- the size of one tab in space equivalentsindentWidth
- the width of one indentation unit in space equivalentsnewIndentString
- the new indent string to be added to all lines (except the first)lineDelim
- the new line delimiter to be used. The returned code will contain only this line delimiter.
java.lang.IllegalArgumentException
- if:
indentWidth
is lower or equals to zerotabWidth
is lower than zerocode
is nullindentUnitsToRemove
is lower than zeronewIndentString
is nulllineDelim
is nullpublic static ReplaceEdit[] getChangeIndentEdits(java.lang.String source, int indentUnitsToRemove, int tabWidth, int indentWidth, java.lang.String newIndentString)
The given number of indent units is removed, and a new indent string is added.
The first line of the code will not be changed (It is considered to have no indent as it might start in the middle of a line).
source
- The code to change the indent ofindentUnitsToRemove
- the number of indent units to remove from each line (except the first) of the given codetabWidth
- the size of one tab in space equivalentsindentWidth
- the width of one indentation unit in space equivalentsnewIndentString
- the new indent string to be added to all lines (except the first)
java.lang.IllegalArgumentException
- if:
indentWidth
is lower or equals to zerotabWidth
is lower than zerosource
is nullindentUnitsToRemove
is lower than zeronewIndentString
is nullpublic static int getTabWidth(java.util.Map options)
Use IJavaScriptProject.getOptions(boolean)
to get the most current project options.
options
- the map to get the formatter settings from.
java.lang.IllegalArgumentException
- if the given options
is nullpublic static int getIndentWidth(java.util.Map options)
Use IJavaScriptProject.getOptions(boolean)
to get the most current project options.
options
- the map to get the formatter settings from
java.lang.IllegalArgumentException
- if the given options
is null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |