|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.caja.render.Indenter
class Indenter
Wraps a list of tokens and provides operations that may replace whitespace tokens in that list.
Field Summary | |
---|---|
(package private) boolean |
breakAfterComment
Whether to break after a comment. |
(package private) int[] |
match
Maps indices of brackets ("(", ")", etc.) in tokens to the corresponding open or close bracket. |
(package private) boolean[] |
parenthetical
For each token in tokens, true if the closest containing pair of brackets are parentheses. |
(package private) java.util.List<java.lang.String> |
tokens
The token list. |
Constructor Summary | |
---|---|
Indenter(java.util.List<java.lang.String> tokens,
boolean breakAfterComment)
|
Method Summary | |
---|---|
(package private) void |
breakLines()
Change space tokens into newlines when a single line contains too many tokens or when a line is normally broken at that token. |
(package private) void |
indent(int lineLengthLimit)
Called once all the line-breaks are present to introduce indentation by looking at the stack of open bracketed blocks. |
private boolean |
isShortRun(int start,
int end)
|
private static java.lang.String |
makeIndent(int nSpaces)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
final java.util.List<java.lang.String> tokens
final int[] match
For each token in tokens, the corresponding element in this list is -1 if token is not a bracket, or the index of the close/open bracket token that ends/starts the run of tokens started/opened by token.
For example, for the code f(a[i])
, tokens is
["f", "(", "a", "[", "i", "]", ")"]
, and
match[1] == 6 && match[6] == 1
as the outer parentheses match up,
match[3] == 5 && match[5] == 3
as the inner parentheses match up.
and all the other elements in match are -1.
final boolean[] parenthetical
For example, for the code f(a[i])
, tokens is
["f", "(", "a", "[", "i", "]", ")"]
, and
parenthetical is [false, true, true, false, false, false, true]
final boolean breakAfterComment
Constructor Detail |
---|
Indenter(java.util.List<java.lang.String> tokens, boolean breakAfterComment)
Method Detail |
---|
void breakLines()
This does not need to worry about inserting newlines into restricted productions since the superclass will convert to spaces any newlines that would appear in a restricted context.
void indent(int lineLengthLimit)
private boolean isShortRun(int start, int end)
private static java.lang.String makeIndent(int nSpaces)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |