X-Git-Url: http://git.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java
index e7d7075..20b7a2a 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java
@@ -15,10 +15,10 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.Hashtable;
-import java.util.Locale;
+//import java.util.Locale;
import java.util.Map;
-import javax.swing.text.html.Option;
+//import javax.swing.text.html.Option;
import net.sourceforge.phpdt.core.ICodeFormatter;
import net.sourceforge.phpdt.core.compiler.CharOperation;
@@ -44,13 +44,13 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
/**
* Represents a block in the constructions
stack.
*/
- public static final int BLOCK = ITerminalSymbols.TokenNameLBRACE;
+ public static final TokenName BLOCK = TokenName.LBRACE;
/**
* Represents a block following a control statement in the
* constructions
stack.
*/
- public static final int NONINDENT_BLOCK = -100;
+ public static final TokenName NONINDENT_BLOCK = TokenName.NONE_INDENT_BLOCK;
/**
* Contains the formatted output.
@@ -72,7 +72,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* Contains the tokens responsible for the current indentation level and the
* blocks not closed yet.
*/
- private int[] constructions;
+ private TokenName[] constructions;
/**
* Index in the constructions
array.
@@ -148,9 +148,9 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
*
* @deprecated Use CodeFormatter(ConfigurableOption[]) instead
*/
- public CodeFormatter() {
- this((Map) null);
- }
+// public CodeFormatter() {
+// this((Map) null);
+// }
/**
* Creates a new instance of Code Formatter using the given settings.
@@ -158,7 +158,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
public CodeFormatter(Map settings) {
// initialize internal state
constructionsCount = 0;
- constructions = new int[10];
+ constructions = new TokenName[10];
currentLineIndentationLevel = indentationLevel = initialIndentationLevel;
currentCommentOffset = -1;
// initialize primary and secondary scanners
@@ -189,11 +189,11 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* Returns true if a lineSeparator has to be inserted before
* operator
false otherwise.
*/
- private static boolean breakLineBeforeOperator(int operator) {
+ private static boolean breakLineBeforeOperator(TokenName operator) {
switch (operator) {
- case TokenNameCOMMA:
- case TokenNameSEMICOLON:
- case TokenNameEQUAL:
+ case COMMA:
+ case SEMICOLON:
+ case EQUAL:
return false;
default:
return true;
@@ -293,12 +293,18 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
beginningOfLineIndex = formattedSource.length();
if (containsOpenCloseBraces) {
containsOpenCloseBraces = false;
- outputLine(currentString, false,
- indentationLevelForOpenCloseBraces, 0, -1, null, 0);
+ outputLine(currentString,
+ false,
+ indentationLevelForOpenCloseBraces,
+ TokenName.NONE,
+ -1, null, 0);
indentationLevelForOpenCloseBraces = currentLineIndentationLevel;
} else {
- outputLine(currentString, false, currentLineIndentationLevel, 0,
- -1, null, 0);
+ outputLine(currentString,
+ false,
+ currentLineIndentationLevel,
+ TokenName.NONE,
+ -1, null, 0);
}
int scannerSourceLength = scanner.source.length;
if ((scannerSourceLength > 2)
@@ -322,9 +328,10 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* Formats the input string.
*/
private void format() {
- int token = 0;
- int previousToken = 0;
- int previousCompilableToken = 0;
+ TokenName token = TokenName.NONE;
+ TokenName previousToken = TokenName.NONE;
+ TokenName previousCompilableToken = TokenName.NONE;
+
int indentationOffset = 0;
int newLinesInWhitespace = 0;
// number of new lines in the previous whitespace token
@@ -358,10 +365,10 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// :
// it can be case or ?
int tokenBeforeColonCount = 0;
- int[] tokenBeforeColon = new int[10];
+ TokenName[] tokenBeforeColon = new TokenName[10];
constructionsCount = 0; // initializes the constructions count.
// contains DO if in a DO..WHILE statement, UNITIALIZED otherwise.
- int nlicsToken = 0;
+ TokenName nlicsToken = ITerminalSymbols.TokenName.NONE;
// fix for 1FF17XY: LFCOM:ALL - Format problem on not matching } and
// else
boolean specialElse = false;
@@ -390,7 +397,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
// Patch for line comment
// See PR http://dev.eclipse.org/bugs/show_bug.cgi?id=23096
- if (token == ITerminalSymbols.TokenNameCOMMENT_LINE) {
+ if (token == ITerminalSymbols.TokenName.COMMENT_LINE) {
int length = scanner.currentPosition;
loop: for (int index = length - 1; index >= 0; index--) {
switch (scanner.source[index]) {
@@ -407,22 +414,22 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
if (!handleInvalidToken(e)) {
throw e;
}
- token = 0;
+ token = ITerminalSymbols.TokenName.NONE;
}
- if (token == Scanner.TokenNameEOF) {
+ if (token == Scanner.TokenName.EOF) {
break;
- } else if (token == Scanner.TokenNameHEREDOC) {
+ } else if (token == Scanner.TokenName.HEREDOC) {
// no indentation for heredocs and HTML !
- outputCurrentTokenWithoutIndent(Scanner.TokenNameHEREDOC, 0);
+ outputCurrentTokenWithoutIndent(Scanner.TokenName.HEREDOC, 0);
continue;
- } else if (token == Scanner.TokenNameINLINE_HTML) {
+ } else if (token == Scanner.TokenName.INLINE_HTML) {
// no indentation for heredocs and HTML !
int newLineCount = 1;
if (scanner.startPosition == 0) {
newLineCount = 0;
}
outputCurrentTokenWithoutIndent(
- Scanner.TokenNameINLINE_HTML, newLineCount);
+ Scanner.TokenName.INLINE_HTML, newLineCount);
int srcLen = scanner.source.length;
if (scanner.currentPosition < srcLen - 1) {
newLine(1);
@@ -439,25 +446,25 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// except if the current token is ELSE, CATCH or if we are in a
// switch/case
if (clearNonBlockIndents
- && (token != Scanner.TokenNameWHITESPACE)) {
+ && (token != Scanner.TokenName.WHITESPACE)) {
switch (token) {
- case TokenNameelse:
+ case ELSE:
if (constructionsCount > 0
- && constructions[constructionsCount - 1] == TokenNameelse) {
+ && constructions[constructionsCount - 1] == TokenName.ELSE) {
pendingNewLines = 1;
specialElse = true;
}
- indentationLevel += popInclusiveUntil(TokenNameif);
+ indentationLevel += popInclusiveUntil(TokenName.IF);
break;
- // case TokenNamecatch :
- // indentationLevel += popInclusiveUntil(TokenNamecatch);
+ // case TokenName.catch :
+ // indentationLevel += popInclusiveUntil(TokenName.catch);
// break;
- // case TokenNamefinally :
- // indentationLevel += popInclusiveUntil(TokenNamecatch);
+ // case TokenName.finally :
+ // indentationLevel += popInclusiveUntil(TokenName.catch);
// break;
- case TokenNamewhile:
- if (nlicsToken == TokenNamedo) {
- indentationLevel += pop(TokenNamedo);
+ case WHILE:
+ if (nlicsToken == TokenName.DO) {
+ indentationLevel += pop(TokenName.DO);
break;
}
default:
@@ -472,14 +479,14 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// returns to the indentation level created by the SWITCH
// keyword
// if the current token is a CASE or a DEFAULT
- if (token == TokenNamecase || token == TokenNamedefault) {
- indentationLevel += pop(TokenNamecase);
+ if (token == TokenName.CASE || token == TokenName.DEFAULT) {
+ indentationLevel += pop(TokenName.CASE);
}
- // if (token == Scanner.TokenNamethrows) {
+ // if (token == Scanner.TokenName.throws) {
// inThrowsClause = true;
// }
- if ((token == Scanner.TokenNameclass || token == Scanner.TokenNameinterface)
- && previousToken != Scanner.TokenNameDOT) {
+ if ((token == Scanner.TokenName.CLASS || token == Scanner.TokenName.INTERFACE)
+ && previousToken != Scanner.TokenName.DOT) {
inClassOrInterfaceHeader = true;
}
/*
@@ -489,12 +496,12 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// elseIfOnSameLine is true.
// Fix for 1ETLWPZ: IVJCOM:ALL - incorrect "else if" formatting
// if (pendingNewlineAfterParen
- // && previousCompilableToken == TokenNameelse
- // && token == TokenNameif
+ // && previousCompilableToken == TokenName.else
+ // && token == TokenName.if
// && options.compactElseIfMode) {
// pendingNewlineAfterParen = false;
// pendingNewLines = 0;
- // indentationLevel += pop(TokenNameelse);
+ // indentationLevel += pop(TokenName.else);
// // because else if is now one single statement,
// // the indentation level after it is increased by one and not
// by 2
@@ -506,9 +513,9 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// block
// following it.
pendingNewlineAfterParen = pendingNewlineAfterParen
- || (previousCompilableToken == TokenNameRPAREN && token == TokenNameLBRACE);
+ || (previousCompilableToken == TokenName.RPAREN && token == TokenName.LBRACE);
if (pendingNewlineAfterParen
- && token != Scanner.TokenNameWHITESPACE) {
+ && token != Scanner.TokenName.WHITESPACE) {
pendingNewlineAfterParen = false;
// Do to add a newline & indent sequence if the current
// token is an
@@ -520,17 +527,17 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// statement
// has been closed and the current token is not an opening
// brace
- if (token != TokenNameLBRACE && !isComment(token)
+ if (token != TokenName.LBRACE && !isComment(token)
// to avoid adding new line between else and a
// comment
- && token != TokenNameDOT
- && !(previousCompilableToken == TokenNameRPAREN && token == TokenNameSEMICOLON)) {
+ && token != TokenName.DOT
+ && !(previousCompilableToken == TokenName.RPAREN && token == TokenName.SEMICOLON)) {
newLine(1);
currentLineIndentationLevel = indentationLevel;
pendingNewLines = 0;
pendingSpace = false;
} else {
- if (token == TokenNameLBRACE
+ if (token == TokenName.LBRACE
&& options.newLineBeforeOpeningBraceMode) {
newLine(1);
if (constructionsCount > 0
@@ -545,17 +552,17 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
}
}
- if (token == TokenNameLBRACE
+ if (token == TokenName.LBRACE
&& options.newLineBeforeOpeningBraceMode
&& constructionsCount > 0
- && constructions[constructionsCount - 1] == TokenNamedo) {
+ && constructions[constructionsCount - 1] == TokenName.DO) {
newLine(1);
currentLineIndentationLevel = indentationLevel - 1;
pendingNewLines = 0;
pendingSpace = false;
}
// see PR 1G5G8EC
- if (token == TokenNameLBRACE && inThrowsClause) {
+ if (token == TokenName.LBRACE && inThrowsClause) {
inThrowsClause = false;
if (options.newLineBeforeOpeningBraceMode) {
newLine(1);
@@ -565,7 +572,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
}
// see PR 1G5G82G
- if (token == TokenNameLBRACE && inClassOrInterfaceHeader) {
+ if (token == TokenName.LBRACE && inClassOrInterfaceHeader) {
inClassOrInterfaceHeader = false;
if (options.newLineBeforeOpeningBraceMode) {
newLine(1);
@@ -575,8 +582,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
}
// don't linebreak empty array declarations
- if (token == TokenNameRPAREN && arrayDeclarationCount > 0) {
- if (previousCompilableToken == TokenNameLPAREN) {
+ if (token == TokenName.RPAREN && arrayDeclarationCount > 0) {
+ if (previousCompilableToken == TokenName.LPAREN) {
pendingNewLines = 0;
}
}
@@ -588,37 +595,37 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// (if it's a one-line comment, a blank line is added after it).
if (((pendingNewLines > 0 && (!isComment(token)))
|| (newLinesInWhitespace > 0 && (openParenthesisCount <= 1 && isComment(token)))
- || (previousCompilableToken == TokenNameLBRACE && token == TokenNameRBRACE) || (newLinesInWhitespace > 0 && previousCompilableToken == TokenNameDOT))
- && token != Scanner.TokenNameWHITESPACE) {
+ || (previousCompilableToken == TokenName.LBRACE && token == TokenName.RBRACE) || (newLinesInWhitespace > 0 && previousCompilableToken == TokenName.DOT))
+ && token != Scanner.TokenName.WHITESPACE) {
// Do not add newline & indent between an adjoining close
// brace and
// close paren. Anonymous inner classes may use this form.
- boolean closeBraceAndCloseParen = previousToken == TokenNameRBRACE
- && token == TokenNameRPAREN;
+ boolean closeBraceAndCloseParen = previousToken == TokenName.RBRACE
+ && token == TokenName.RPAREN;
// OPTION (NewLineInCompoundStatement): do not add newline &
// indent
// between close brace and else, (do) while, catch, and
// finally if
// newlineInCompoundStatement is true.
- boolean nlicsOption = previousToken == TokenNameRBRACE
+ boolean nlicsOption = previousToken == TokenName.RBRACE
&& !options.newlineInControlStatementMode
- && (token == TokenNameelse
- || (token == TokenNamewhile && nlicsToken == TokenNamedo)
- || token == TokenNamecatch || token == TokenNamefinally);
+ && (token == TokenName.ELSE
+ || (token == TokenName.WHILE && nlicsToken == TokenName.DO)
+ || token == TokenName.CATCH || token == TokenName.FINALLY);
// Do not add a newline & indent between a close brace and
// semi-colon.
- boolean semiColonAndCloseBrace = previousToken == TokenNameRBRACE
- && token == TokenNameSEMICOLON;
+ boolean semiColonAndCloseBrace = previousToken == TokenName.RBRACE
+ && token == TokenName.SEMICOLON;
// Do not add a new line & indent between a multiline
// comment and a
// opening brace
- boolean commentAndOpenBrace = previousToken == Scanner.TokenNameCOMMENT_BLOCK
- && token == TokenNameLBRACE;
+ boolean commentAndOpenBrace = previousToken == Scanner.TokenName.COMMENT_BLOCK
+ && token == TokenName.LBRACE;
// Do not add a newline & indent between a close brace and a
// colon
// (in array assignments, for example).
- boolean commaAndCloseBrace = previousToken == TokenNameRBRACE
- && token == TokenNameCOMMA;
+ boolean commaAndCloseBrace = previousToken == TokenName.RBRACE
+ && token == TokenName.COMMA;
// Add a newline and indent, if appropriate.
if (specialElse
|| (!commentAndOpenBrace
@@ -637,8 +644,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
pendingNewLines = (pendingNewLines > 2) ? 2
: pendingNewLines;
}
- if (previousCompilableToken == TokenNameLBRACE
- && token == TokenNameRBRACE) {
+ if (previousCompilableToken == TokenName.LBRACE
+ && token == TokenName.RBRACE) {
containsOpenCloseBraces = true;
indentationLevelForOpenCloseBraces = currentLineIndentationLevel;
if (isComment(previousToken)) {
@@ -649,7 +656,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* constructions[constructionsCount-1] ==
* NONINDENT_BLOCK &&
* (constructions[constructionsCount-2] ==
- * TokenNamefor
+ * TokenName.for
*/
if (options.newLineInEmptyBlockMode) {
if (inArrayAssignment) {
@@ -665,18 +672,18 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// see PR 1FKKC3U: LFCOM:WINNT - Format problem with
// a comment
// before the ';'
- if (!((previousToken == Scanner.TokenNameCOMMENT_BLOCK || previousToken == Scanner.TokenNameCOMMENT_PHPDOC) && token == TokenNameSEMICOLON)) {
+ if (!((previousToken == Scanner.TokenName.COMMENT_BLOCK || previousToken == Scanner.TokenName.COMMENT_PHPDOC) && token == TokenName.SEMICOLON)) {
newLine(pendingNewLines);
}
}
- if (((previousCompilableToken == TokenNameSEMICOLON)
- || (previousCompilableToken == TokenNameLBRACE)
- || (previousCompilableToken == TokenNameRBRACE) || (isComment(previousToken)))
- && (token == TokenNameRBRACE)) {
+ if (((previousCompilableToken == TokenName.SEMICOLON)
+ || (previousCompilableToken == TokenName.LBRACE)
+ || (previousCompilableToken == TokenName.RBRACE) || (isComment(previousToken)))
+ && (token == TokenName.RBRACE)) {
indentationOffset = -1;
indentationLevel += popExclusiveUntilBlock();
}
- if (previousToken == Scanner.TokenNameCOMMENT_LINE
+ if (previousToken == Scanner.TokenName.COMMENT_LINE
&& inAssignment) {
// PR 1FI5IPO
currentLineIndentationLevel++;
@@ -690,51 +697,51 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
pendingNewLines = 0;
newLinesInWhitespace = 0;
specialElse = false;
- if (nlicsToken == TokenNamedo && token == TokenNamewhile) {
- nlicsToken = 0;
+ if (nlicsToken == TokenName.DO && token == TokenName.WHILE) {
+ nlicsToken = ITerminalSymbols.TokenName.NONE;
}
}
- boolean phpTagAndWhitespace = previousToken == TokenNameINLINE_HTML
- && token == TokenNameWHITESPACE;
+ boolean phpTagAndWhitespace = previousToken == TokenName.INLINE_HTML
+ && token == TokenName.WHITESPACE;
switch (token) {
- // case TokenNameDOLLAR :
+ // case TokenName.DOLLAR :
// dollarBraceCount++;
// break;
- case TokenNameelse:
- // case TokenNamefinally :
+ case ELSE:
+ // case TokenName.finally :
expectingOpenBrace = true;
pendingNewlineAfterParen = true;
indentationLevel += pushControlStatement(token);
break;
- case TokenNamecase:
- case TokenNamedefault:
+ case CASE:
+ case DEFAULT:
if (tokenBeforeColonCount == tokenBeforeColon.length) {
System
.arraycopy(
tokenBeforeColon,
0,
- (tokenBeforeColon = new int[tokenBeforeColonCount * 2]),
+ (tokenBeforeColon = new TokenName[tokenBeforeColonCount * 2]),
0, tokenBeforeColonCount);
}
- tokenBeforeColon[tokenBeforeColonCount++] = TokenNamecase;
- indentationLevel += pushControlStatement(TokenNamecase);
+ tokenBeforeColon[tokenBeforeColonCount++] = TokenName.CASE;
+ indentationLevel += pushControlStatement(TokenName.CASE);
break;
- case TokenNameQUESTION:
+ case QUESTION:
if (tokenBeforeColonCount == tokenBeforeColon.length) {
System
.arraycopy(
tokenBeforeColon,
0,
- (tokenBeforeColon = new int[tokenBeforeColonCount * 2]),
+ (tokenBeforeColon = new TokenName[tokenBeforeColonCount * 2]),
0, tokenBeforeColonCount);
}
tokenBeforeColon[tokenBeforeColonCount++] = token;
break;
- case TokenNameswitch:
- case TokenNamefor:
- case TokenNameforeach:
- case TokenNameif:
- case TokenNamewhile:
+ case SWITCH:
+ case FOR:
+ case FOREACH:
+ case IF:
+ case WHILE:
if (openParenthesisCount == openParenthesis.length) {
System
.arraycopy(
@@ -747,42 +754,42 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
expectingOpenBrace = true;
indentationLevel += pushControlStatement(token);
break;
- case TokenNametry:
+ case TRY:
pendingNewlineAfterParen = true;
- case TokenNamecatch:
+ case CATCH:
// several CATCH statements can be contiguous.
// a CATCH is encountered pop until first CATCH (if a CATCH
// follows a TRY it works the same way,
// as CATCH and TRY are the same token in the stack).
expectingOpenBrace = true;
- indentationLevel += pushControlStatement(TokenNamecatch);
+ indentationLevel += pushControlStatement(TokenName.CATCH);
break;
- case TokenNamedo:
+ case DO:
expectingOpenBrace = true;
indentationLevel += pushControlStatement(token);
nlicsToken = token;
break;
- case TokenNamenew:
+ case NEW:
break;
- case TokenNameLPAREN:
- // if (previousToken == TokenNamesynchronized) {
+ case LPAREN:
+ // if (previousToken == TokenName.synchronized) {
// indentationLevel += pushControlStatement(previousToken);
// } else {
// Put a space between the previous and current token if the
// previous token was not a keyword, open paren, logical
// compliment (eg: !), semi-colon, open brace, close brace,
// super, or this.
- if (previousCompilableToken != TokenNameLBRACKET
- && previousToken != TokenNameIdentifier
- && previousToken != 0
- && previousToken != TokenNameNOT
- && previousToken != TokenNameLPAREN
- && previousToken != TokenNameTWIDDLE
- && previousToken != TokenNameSEMICOLON
- && previousToken != TokenNameLBRACE
- && previousToken != TokenNameRBRACE
- && previousToken != TokenNamesuper) {
- // && previousToken != TokenNamethis) {
+ if (previousCompilableToken != TokenName.LBRACKET
+ && previousToken != TokenName.IDENTIFIER
+ && previousToken != TokenName.NONE
+ && previousToken != TokenName.NOT
+ && previousToken != TokenName.LPAREN
+ && previousToken != TokenName.TWIDDLE
+ && previousToken != TokenName.SEMICOLON
+ && previousToken != TokenName.LBRACE
+ && previousToken != TokenName.RBRACE
+ && previousToken != TokenName.SUPER) {
+ // && previousToken != TokenName.THIS) {
if (!options.compactArrays) {
space();
}
@@ -797,7 +804,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
openParenthesis[0]++;
pendingSpace = false;
// recognize array declaration for nice output
- if (previousCompilableToken == TokenNamearray) {
+ if (previousCompilableToken == TokenName.ARRAY) {
arrayDeclarationCount++;
arrayDeclarationParenthesis[arrayDeclarationCount] = openParenthesis[openParenthesisCount - 1];
if (!options.compactArrays) {
@@ -807,17 +814,17 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
// S }
break;
- case TokenNameRPAREN:
+ case RPAREN:
// check for closing array declaration
if (arrayDeclarationCount > 0) {
if (arrayDeclarationParenthesis[arrayDeclarationCount] == openParenthesis[openParenthesisCount - 1]) {
- if (previousCompilableToken != TokenNameLPAREN) {
+ if (previousCompilableToken != TokenName.LPAREN) {
if (!options.compactArrays) {
newLine(1);
}
- } else if (previousToken == TokenNameCOMMENT_LINE
- || previousToken == TokenNameCOMMENT_BLOCK
- || previousToken == TokenNameCOMMENT_PHPDOC) {
+ } else if (previousToken == TokenName.COMMENT_LINE
+ || previousToken == TokenName.COMMENT_BLOCK
+ || previousToken == TokenName.COMMENT_PHPDOC) {
// prevent to combine comment line and statement line (#1475484)
if (!options.compactArrays) {
newLine(1);
@@ -850,13 +857,13 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
pendingSpace = false;
break;
- case TokenNameLBRACE:
- if (previousCompilableToken == TokenNameDOLLAR) {
+ case LBRACE:
+ if (previousCompilableToken == TokenName.DOLLAR) {
dollarBraceCount++;
} else {
- if ((previousCompilableToken == TokenNameRBRACKET)
- || (previousCompilableToken == TokenNameEQUAL)) {
- // if (previousCompilableToken == TokenNameRBRACKET)
+ if ((previousCompilableToken == TokenName.RBRACKET)
+ || (previousCompilableToken == TokenName.EQUAL)) {
+ // if (previousCompilableToken == TokenName.RBRACKET)
// {
inArrayAssignment = true;
inAssignment = false;
@@ -872,12 +879,12 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
}
break;
- case TokenNameRBRACE:
+ case RBRACE:
if (dollarBraceCount > 0) {
dollarBraceCount--;
break;
}
- if (previousCompilableToken == TokenNameRPAREN) {
+ if (previousCompilableToken == TokenName.RPAREN) {
pendingSpace = false;
}
if (inArrayAssignment) {
@@ -887,7 +894,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
} else {
pendingNewLines = 1;
indentationLevel += popInclusiveUntilBlock();
- if (previousCompilableToken == TokenNameRPAREN) {
+ if (previousCompilableToken == TokenName.RPAREN) {
// fix for 1FGDDV6: LFCOM:WIN98 - Weird splitting on
// message
// expression
@@ -897,19 +904,19 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
if (constructionsCount > 0) {
switch (constructions[constructionsCount - 1]) {
- case TokenNamefor:
- case TokenNameforeach:
+ case FOR:
+ case FOREACH:
// indentationLevel += popExclusiveUntilBlock();
// break;
- case TokenNameswitch:
- case TokenNameif:
- case TokenNameelse:
- case TokenNametry:
- case TokenNamecatch:
- case TokenNamefinally:
- case TokenNamewhile:
- case TokenNamedo:
- // case TokenNamesynchronized :
+ case SWITCH:
+ case IF:
+ case ELSE:
+ case TRY:
+ case CATCH:
+ case FINALLY:
+ case WHILE:
+ case DO:
+ // case TokenName.synchronized :
clearNonBlockIndents = true;
default:
break;
@@ -917,18 +924,18 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
}
break;
- case TokenNameLBRACKET:
+ case LBRACKET:
openBracketCount++;
pendingSpace = false;
break;
- case TokenNameRBRACKET:
+ case RBRACKET:
openBracketCount -= (openBracketCount > 0) ? 1 : 0;
// if there is no left bracket to close, the right bracket
// is
// ignored.
pendingSpace = false;
break;
- case TokenNameCOMMA:
+ case COMMA:
pendingSpace = false;
if (arrayDeclarationCount > 0) {
if (arrayDeclarationParenthesis[arrayDeclarationCount] == openParenthesis[openParenthesisCount - 1]) {
@@ -939,13 +946,13 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
}
break;
- case TokenNameDOT:
+ case DOT:
if (!options.compactStringConcatenation) {
space();
}
pendingSpace = false;
break;
- case TokenNameSEMICOLON:
+ case SEMICOLON:
// Do not generate line terminators in the definition of
// the for statement.
// if not in this case, jump a line and reduce indentation
@@ -964,53 +971,53 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
inAssignment = false;
pendingSpace = false;
break;
- case TokenNamePLUS_PLUS:
- case TokenNameMINUS_MINUS:
+ case PLUS_PLUS:
+ case MINUS_MINUS:
// Do not put a space between a post-increment/decrement
// and the identifier being modified.
- if (previousToken == TokenNameIdentifier
- || previousToken == TokenNameRBRACKET
- || previousToken == TokenNameVariable) {
+ if (previousToken == TokenName.IDENTIFIER
+ || previousToken == TokenName.RBRACKET
+ || previousToken == TokenName.VARIABLE) {
pendingSpace = false;
}
break;
- case TokenNamePLUS:
+ case PLUS:
// previously ADDITION
- case TokenNameMINUS:
+ case MINUS:
// Handle the unary operators plus and minus via a flag
if (!isLiteralToken(previousToken)
- && previousToken != TokenNameIdentifier
- && previousToken != TokenNameRPAREN
- && previousToken != TokenNameRBRACKET) {
+ && previousToken != TokenName.IDENTIFIER
+ && previousToken != TokenName.RPAREN
+ && previousToken != TokenName.RBRACKET) {
unarySignModifier = 1;
}
break;
- case TokenNameCOLON:
+ case COLON:
// In a switch/case statement, add a newline & indent
// when a colon is encountered.
if (tokenBeforeColonCount > 0) {
- if (tokenBeforeColon[tokenBeforeColonCount - 1] == TokenNamecase) {
+ if (tokenBeforeColon[tokenBeforeColonCount - 1] == TokenName.CASE) {
pendingNewLines = 1;
}
tokenBeforeColonCount--;
}
break;
- case TokenNameEQUAL:
+ case EQUAL:
inAssignment = true;
break;
- case Scanner.TokenNameCOMMENT_LINE:
+ case COMMENT_LINE:
pendingNewLines = 1;
//if (inAssignment) {
// currentLineIndentationLevel++;
//}
break; // a line is always inserted after a one-line
// comment
- case Scanner.TokenNameCOMMENT_PHPDOC:
- case Scanner.TokenNameCOMMENT_BLOCK:
+ case COMMENT_PHPDOC:
+ case COMMENT_BLOCK:
currentCommentOffset = getCurrentCommentOffset();
pendingNewLines = 1;
break;
- case Scanner.TokenNameWHITESPACE:
+ case WHITESPACE:
if (!phpTagAndWhitespace) {
// Count the number of line terminators in the
// whitespace so
@@ -1036,7 +1043,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
- scanner.currentPosition);
break;
}
- // case TokenNameHTML :
+ // case TokenName.HTML :
// // Add the next token to the formatted source string.
// // outputCurrentToken(token);
// int startPosition = scanner.startPosition;
@@ -1050,16 +1057,16 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// }
// break;
default:
- if ((token == TokenNameIdentifier) || isLiteralToken(token)
- || token == TokenNamesuper) {
- // || token == TokenNamethis) {
+ if ((token == TokenName.IDENTIFIER) || isLiteralToken(token)
+ || token == TokenName.SUPER) {
+ // || token == TokenName.this) {
// Do not put a space between a unary operator
// (eg: ++, --, +, -) and the identifier being modified.
- if (previousToken == TokenNamePLUS_PLUS
- || previousToken == TokenNameMINUS_MINUS
- || (previousToken == TokenNameMINUS_GREATER && options.compactDereferencingMode) // ->
- || (previousToken == TokenNamePLUS && unarySignModifier > 0)
- || (previousToken == TokenNameMINUS && unarySignModifier > 0)) {
+ if (previousToken == TokenName.PLUS_PLUS
+ || previousToken == TokenName.MINUS_MINUS
+ || (previousToken == TokenName.MINUS_GREATER && options.compactDereferencingMode) // ->
+ || (previousToken == TokenName.PLUS && unarySignModifier > 0)
+ || (previousToken == TokenName.MINUS && unarySignModifier > 0)) {
pendingSpace = false;
}
unarySignModifier = 0;
@@ -1067,7 +1074,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
break;
}
// Do not output whitespace tokens.
- if (token != Scanner.TokenNameWHITESPACE || phpTagAndWhitespace) {
+ if (token != Scanner.TokenName.WHITESPACE || phpTagAndWhitespace) {
/*
* Add pending space to the formatted source string. Do not
* output a space under the following circumstances: 1) this
@@ -1080,23 +1087,23 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* close brace 8) previous token is a single line comment 9)
* current token is a '->'
*/
- if (token == TokenNameMINUS_GREATER
+ if (token == TokenName.MINUS_GREATER
&& options.compactDereferencingMode)
pendingSpace = false;
- boolean openAndCloseBrace = previousCompilableToken == TokenNameLBRACE
- && token == TokenNameRBRACE;
+ boolean openAndCloseBrace = previousCompilableToken == TokenName.LBRACE
+ && token == TokenName.RBRACE;
if (pendingSpace
&& insertSpaceAfter(previousToken)
- && !(inAssignment && (previousToken == TokenNameLBRACE || token == TokenNameRBRACE))
- && previousToken != Scanner.TokenNameCOMMENT_LINE) {
- if ((!(options.compactAssignmentMode && token == TokenNameEQUAL))
+ && !(inAssignment && (previousToken == TokenName.LBRACE || token == TokenName.RBRACE))
+ && previousToken != Scanner.TokenName.COMMENT_LINE) {
+ if ((!(options.compactAssignmentMode && token == TokenName.EQUAL))
&& !openAndCloseBrace)
space();
}
// Add the next token to the formatted source string.
outputCurrentToken(token);
- if (token == Scanner.TokenNameCOMMENT_LINE
+ if (token == Scanner.TokenName.COMMENT_LINE
&& openParenthesisCount > 1) {
pendingNewLines = 0;
currentLineBuffer.append(options.lineSeparatorSequence);
@@ -1105,11 +1112,11 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
pendingSpace = true;
}
// Whitespace tokens do not need to be remembered.
- if (token != Scanner.TokenNameWHITESPACE || phpTagAndWhitespace) {
+ if (token != Scanner.TokenName.WHITESPACE || phpTagAndWhitespace) {
previousToken = token;
- if (token != Scanner.TokenNameCOMMENT_BLOCK
- && token != Scanner.TokenNameCOMMENT_LINE
- && token != Scanner.TokenNameCOMMENT_PHPDOC) {
+ if (token != Scanner.TokenName.COMMENT_BLOCK
+ && token != Scanner.TokenName.COMMENT_LINE
+ && token != Scanner.TokenName.COMMENT_PHPDOC) {
previousCompilableToken = token;
}
}
@@ -1261,40 +1268,40 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
*
* @deprecated backport 1.0 internal functionality
*/
- public static ConfigurableOption[] getDefaultOptions(Locale locale) {
- String componentName = CodeFormatter.class.getName();
- FormatterOptions options = new FormatterOptions();
- return new ConfigurableOption[] {
- new ConfigurableOption(componentName, "newline.openingBrace",
- locale, options.newLineBeforeOpeningBraceMode ? 0 : 1),
- //$NON-NLS-1$
- new ConfigurableOption(componentName,
- "newline.controlStatement", locale,
- options.newlineInControlStatementMode ? 0 : 1),
- //$NON-NLS-1$
- new ConfigurableOption(componentName, "newline.clearAll",
- locale, options.clearAllBlankLinesMode ? 0 : 1),
- //$NON-NLS-1$
- // new ConfigurableOption(componentName, "newline.elseIf",
- // locale,
- // options.compactElseIfMode ? 0 : 1), //$NON-NLS-1$
- new ConfigurableOption(componentName, "newline.emptyBlock",
- locale, options.newLineInEmptyBlockMode ? 0 : 1),
- //$NON-NLS-1$
- new ConfigurableOption(componentName, "line.split", locale,
- options.maxLineLength),
- //$NON-NLS-1$
- new ConfigurableOption(componentName,
- "style.compactAssignment", locale,
- options.compactAssignmentMode ? 0 : 1),
- //$NON-NLS-1$
- new ConfigurableOption(componentName, "tabulation.char",
- locale, options.indentWithTab ? 0 : 1),
- //$NON-NLS-1$
- new ConfigurableOption(componentName,
- "tabulation.size", locale, options.tabSize) //$NON-NLS-1$
- };
- }
+// public static ConfigurableOption[] getDefaultOptions(Locale locale) {
+// String componentName = CodeFormatter.class.getName();
+// FormatterOptions options = new FormatterOptions();
+// return new ConfigurableOption[] {
+// new ConfigurableOption(componentName, "newline.openingBrace",
+// locale, options.newLineBeforeOpeningBraceMode ? 0 : 1),
+// //$NON-NLS-1$
+// new ConfigurableOption(componentName,
+// "newline.controlStatement", locale,
+// options.newlineInControlStatementMode ? 0 : 1),
+// //$NON-NLS-1$
+// new ConfigurableOption(componentName, "newline.clearAll",
+// locale, options.clearAllBlankLinesMode ? 0 : 1),
+// //$NON-NLS-1$
+// // new ConfigurableOption(componentName, "newline.elseIf",
+// // locale,
+// // options.compactElseIfMode ? 0 : 1), //$NON-NLS-1$
+// new ConfigurableOption(componentName, "newline.emptyBlock",
+// locale, options.newLineInEmptyBlockMode ? 0 : 1),
+// //$NON-NLS-1$
+// new ConfigurableOption(componentName, "line.split", locale,
+// options.maxLineLength),
+// //$NON-NLS-1$
+// new ConfigurableOption(componentName,
+// "style.compactAssignment", locale,
+// options.compactAssignmentMode ? 0 : 1),
+// //$NON-NLS-1$
+// new ConfigurableOption(componentName, "tabulation.char",
+// locale, options.indentWithTab ? 0 : 1),
+// //$NON-NLS-1$
+// new ConfigurableOption(componentName,
+// "tabulation.size", locale, options.tabSize) //$NON-NLS-1$
+// };
+// }
/**
* Returns the array of mapped positions. Returns null is no positions have
@@ -1322,106 +1329,106 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* @param token
* the token of which the priority is requested
*/
- private static int getTokenPriority(int token) {
- switch (token) {
- case TokenNameextends:
- // case TokenNameimplements :
- // case TokenNamethrows :
- return 10;
- case TokenNameSEMICOLON:
- // ;
- return 20;
- case TokenNameCOMMA:
- // ,
- return 25;
- case TokenNameEQUAL:
- // =
- return 30;
- case TokenNameAND_AND:
- // &&
- case TokenNameOR_OR:
- // ||
- return 40;
- case TokenNameQUESTION:
- // ?
- case TokenNameCOLON:
- // :
- return 50; // it's better cutting on ?: than on ;
- case TokenNameEQUAL_EQUAL:
- // ==
- case TokenNameEQUAL_EQUAL_EQUAL:
- // ===
- case TokenNameNOT_EQUAL:
- // !=
- case TokenNameNOT_EQUAL_EQUAL:
- // !=
- return 60;
- case TokenNameLESS:
- // <
- case TokenNameLESS_EQUAL:
- // <=
- case TokenNameGREATER:
- // >
- case TokenNameGREATER_EQUAL:
- // >=
- // case TokenNameinstanceof : // instanceof
- return 70;
- case TokenNamePLUS:
- // +
- case TokenNameMINUS:
- // -
- return 80;
- case TokenNameMULTIPLY:
- // *
- case TokenNameDIVIDE:
- // /
- case TokenNameREMAINDER:
- // %
- return 90;
- case TokenNameLEFT_SHIFT:
- // <<
- case TokenNameRIGHT_SHIFT:
- // >>
- // case TokenNameUNSIGNED_RIGHT_SHIFT : // >>>
- return 100;
- case TokenNameAND:
- // &
- case TokenNameOR:
- // |
- case TokenNameXOR:
- // ^
- return 110;
- case TokenNameMULTIPLY_EQUAL:
- // *=
- case TokenNameDIVIDE_EQUAL:
- // /=
- case TokenNameREMAINDER_EQUAL:
- // %=
- case TokenNamePLUS_EQUAL:
- // +=
- case TokenNameMINUS_EQUAL:
- // -=
- case TokenNameLEFT_SHIFT_EQUAL:
- // <<=
- case TokenNameRIGHT_SHIFT_EQUAL:
- // >>=
- // case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>=
- case TokenNameAND_EQUAL:
- // &=
- case TokenNameXOR_EQUAL:
- // ^=
- case TokenNameOR_EQUAL:
- // .=
- case TokenNameDOT_EQUAL:
- // |=
- return 120;
- case TokenNameDOT:
- // .
- return 130;
- default:
- return Integer.MAX_VALUE;
- }
- }
+// private static int getTokenPriority(int token) {
+// switch (token) {
+// case TokenName.extends:
+// // case TokenName.implements :
+// // case TokenName.throws :
+// return 10;
+// case TokenName.SEMICOLON:
+// // ;
+// return 20;
+// case TokenName.COMMA:
+// // ,
+// return 25;
+// case TokenName.EQUAL:
+// // =
+// return 30;
+// case TokenName.AND_AND:
+// // &&
+// case TokenName.OR_OR:
+// // ||
+// return 40;
+// case TokenName.QUESTION:
+// // ?
+// case TokenName.COLON:
+// // :
+// return 50; // it's better cutting on ?: than on ;
+// case TokenName.EQUAL_EQUAL:
+// // ==
+// case TokenName.EQUAL_EQUAL_EQUAL:
+// // ===
+// case TokenName.NOT_EQUAL:
+// // !=
+// case TokenName.NOT_EQUAL_EQUAL:
+// // !=
+// return 60;
+// case TokenName.LESS:
+// // <
+// case TokenName.LESS_EQUAL:
+// // <=
+// case TokenName.GREATER:
+// // >
+// case TokenName.GREATER_EQUAL:
+// // >=
+// // case TokenName.instanceof : // instanceof
+// return 70;
+// case TokenName.PLUS:
+// // +
+// case TokenName.MINUS:
+// // -
+// return 80;
+// case TokenName.MULTIPLY:
+// // *
+// case TokenName.DIVIDE:
+// // /
+// case TokenName.REMAINDER:
+// // %
+// return 90;
+// case TokenName.LEFT_SHIFT:
+// // <<
+// case TokenName.RIGHT_SHIFT:
+// // >>
+// // case TokenName.UNSIGNED_RIGHT_SHIFT : // >>>
+// return 100;
+// case TokenName.AND:
+// // &
+// case TokenName.OR:
+// // |
+// case TokenName.XOR:
+// // ^
+// return 110;
+// case TokenName.MULTIPLY_EQUAL:
+// // *=
+// case TokenName.DIVIDE_EQUAL:
+// // /=
+// case TokenName.REMAINDER_EQUAL:
+// // %=
+// case TokenName.PLUS_EQUAL:
+// // +=
+// case TokenName.MINUS_EQUAL:
+// // -=
+// case TokenName.LEFT_SHIFT_EQUAL:
+// // <<=
+// case TokenName.RIGHT_SHIFT_EQUAL:
+// // >>=
+// // case TokenName.UNSIGNED_RIGHT_SHIFT_EQUAL : // >>>=
+// case TokenName.AND_EQUAL:
+// // &=
+// case TokenName.XOR_EQUAL:
+// // ^=
+// case TokenName.OR_EQUAL:
+// // .=
+// case TokenName.DOT_EQUAL:
+// // |=
+// return 120;
+// case TokenName.DOT:
+// // .
+// return 130;
+// default:
+// return Integer.MAX_VALUE;
+// }
+// }
/**
* Handles the exception raised when an invalid token is encountered.
@@ -1452,19 +1459,19 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* Returns true if a space has to be inserted after operator
* false otherwise.
*/
- private boolean insertSpaceAfter(int token) {
+ private boolean insertSpaceAfter(TokenName token) {
switch (token) {
- case TokenNameLPAREN:
- case TokenNameNOT:
- case TokenNameTWIDDLE:
- case 0:
+ case LPAREN:
+ case NOT:
+ case TWIDDLE:
+ case NONE:
// no token
- case TokenNameWHITESPACE:
- case TokenNameLBRACKET:
- case TokenNameDOLLAR:
- case Scanner.TokenNameCOMMENT_LINE:
+ case WHITESPACE:
+ case LBRACKET:
+ case DOLLAR:
+ case COMMENT_LINE:
return false;
- case TokenNameDOT:
+ case DOT:
return !options.compactStringConcatenation;
default:
return true;
@@ -1477,29 +1484,29 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* Cannot be static as it uses the code formatter options (to know if the
* compact assignment mode is on).
*/
- private boolean insertSpaceBefore(int token) {
+ private boolean insertSpaceBefore(TokenName token) {
switch (token) {
- case TokenNameEQUAL:
+ case EQUAL:
return (!options.compactAssignmentMode);
default:
return false;
}
}
- private static boolean isComment(int token) {
- boolean result = token == Scanner.TokenNameCOMMENT_BLOCK
- || token == Scanner.TokenNameCOMMENT_LINE
- || token == Scanner.TokenNameCOMMENT_PHPDOC;
+ private static boolean isComment(TokenName token) {
+ boolean result = token == Scanner.TokenName.COMMENT_BLOCK
+ || token == Scanner.TokenName.COMMENT_LINE
+ || token == Scanner.TokenName.COMMENT_PHPDOC;
return result;
}
- private static boolean isLiteralToken(int token) {
- boolean result = token == TokenNameIntegerLiteral
- // || token == TokenNameLongLiteral
- // || token == TokenNameFloatingPointLiteral
- || token == TokenNameDoubleLiteral
- // || token == TokenNameCharacterLiteral
- || token == TokenNameStringDoubleQuote;
+ private static boolean isLiteralToken(TokenName token) {
+ boolean result = token == TokenName.INTEGERLITERAL
+ // || token == TokenName.LongLiteral
+ // || token == TokenName.FloatingPointLiteral
+ || token == TokenName.DOUBLELITERAL
+ // || token == TokenName.CharacterLiteral
+ || token == TokenName.STRINGDOUBLEQUOTE;
return result;
}
@@ -1519,10 +1526,10 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
if (containsOpenCloseBraces) {
containsOpenCloseBraces = false;
outputLine(currentLine, false, indentationLevelForOpenCloseBraces,
- 0, -1, null, 0);
+ TokenName.NONE, -1, null, 0);
indentationLevelForOpenCloseBraces = currentLineIndentationLevel;
} else {
- outputLine(currentLine, false, currentLineIndentationLevel, 0, -1,
+ outputLine(currentLine, false, currentLineIndentationLevel, TokenName.NONE, -1,
null, 0);
}
// dump line break(s)
@@ -1541,139 +1548,139 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
currentLineIndentationLevel = initialIndentationLevel;
}
- private String operatorString(int operator) {
+ private String operatorString(TokenName operator) {
switch (operator) {
- case TokenNameextends:
+ case EXTENDS:
return "extends"; //$NON-NLS-1$
- // case TokenNameimplements :
+ // case TokenName.implements :
// return "implements"; //$NON-NLS-1$
//
- // case TokenNamethrows :
+ // case TokenName.throws :
// return "throws"; //$NON-NLS-1$
- case TokenNameSEMICOLON:
+ case SEMICOLON:
// ;
return ";"; //$NON-NLS-1$
- case TokenNameCOMMA:
+ case COMMA:
// ,
return ","; //$NON-NLS-1$
- case TokenNameEQUAL:
+ case EQUAL:
// =
return "="; //$NON-NLS-1$
- case TokenNameAND_AND:
+ case AND_AND:
// && (15.22)
return "&&"; //$NON-NLS-1$
- case TokenNameOR_OR:
+ case OR_OR:
// || (15.23)
return "||"; //$NON-NLS-1$
- case TokenNameQUESTION:
+ case QUESTION:
// ? (15.24)
return "?"; //$NON-NLS-1$
- case TokenNameCOLON:
+ case COLON:
// : (15.24)
return ":"; //$NON-NLS-1$
- case TokenNamePAAMAYIM_NEKUDOTAYIM:
+ case PAAMAYIM_NEKUDOTAYIM:
// : (15.24)
return "::"; //$NON-NLS-1$
- case TokenNameEQUAL_EQUAL:
+ case EQUAL_EQUAL:
// == (15.20, 15.20.1, 15.20.2, 15.20.3)
return "=="; //$NON-NLS-1$
- case TokenNameEQUAL_EQUAL_EQUAL:
+ case EQUAL_EQUAL_EQUAL:
// == (15.20, 15.20.1, 15.20.2, 15.20.3)
return "==="; //$NON-NLS-1$
- case TokenNameEQUAL_GREATER:
+ case EQUAL_GREATER:
// -= (15.25.2)
return "=>"; //$NON-NLS-1$
- case TokenNameNOT_EQUAL:
+ case NOT_EQUAL:
// != (15.20, 15.20.1, 15.20.2, 15.20.3)
return "!="; //$NON-NLS-1$
- case TokenNameNOT_EQUAL_EQUAL:
+ case NOT_EQUAL_EQUAL:
// != (15.20, 15.20.1, 15.20.2, 15.20.3)
return "!=="; //$NON-NLS-1$
- case TokenNameLESS:
+ case LESS:
// < (15.19.1)
return "<"; //$NON-NLS-1$
- case TokenNameLESS_EQUAL:
+ case LESS_EQUAL:
// <= (15.19.1)
return "<="; //$NON-NLS-1$
- case TokenNameGREATER:
+ case GREATER:
// > (15.19.1)
return ">"; //$NON-NLS-1$
- case TokenNameGREATER_EQUAL:
+ case GREATER_EQUAL:
// >= (15.19.1)
return ">="; //$NON-NLS-1$
- // case TokenNameinstanceof : // instanceof
+ // case instanceof : // instanceof
// return "instanceof"; //$NON-NLS-1$
- case TokenNamePLUS:
+ case PLUS:
// + (15.17, 15.17.2)
return "+"; //$NON-NLS-1$
- case TokenNameMINUS:
+ case MINUS:
// - (15.17.2)
return "-"; //$NON-NLS-1$
- case TokenNameMULTIPLY:
+ case MULTIPLY:
// * (15.16.1)
return "*"; //$NON-NLS-1$
- case TokenNameDIVIDE:
+ case DIVIDE:
// / (15.16.2)
return "/"; //$NON-NLS-1$
- case TokenNameREMAINDER:
+ case REMAINDER:
// % (15.16.3)
return "%"; //$NON-NLS-1$
- case TokenNameLEFT_SHIFT:
+ case LEFT_SHIFT:
// << (15.18)
return "<<"; //$NON-NLS-1$
- case TokenNameRIGHT_SHIFT:
+ case RIGHT_SHIFT:
// >> (15.18)
return ">>"; //$NON-NLS-1$
- // case TokenNameUNSIGNED_RIGHT_SHIFT : // >>> (15.18)
+ // case UNSIGNED_RIGHT_SHIFT : // >>> (15.18)
// return ">>>"; //$NON-NLS-1$
- case TokenNameAND:
+ case OP_AND:
// & (15.21, 15.21.1, 15.21.2)
return "&"; //$NON-NLS-1$
- case TokenNameOR:
+ case OP_OR:
// | (15.21, 15.21.1, 15.21.2)
return "|"; //$NON-NLS-1$
- case TokenNameXOR:
+ case OP_XOR:
// ^ (15.21, 15.21.1, 15.21.2)
return "^"; //$NON-NLS-1$
- case TokenNameMULTIPLY_EQUAL:
+ case MULTIPLY_EQUAL:
// *= (15.25.2)
return "*="; //$NON-NLS-1$
- case TokenNameDIVIDE_EQUAL:
+ case DIVIDE_EQUAL:
// /= (15.25.2)
return "/="; //$NON-NLS-1$
- case TokenNameREMAINDER_EQUAL:
+ case REMAINDER_EQUAL:
// %= (15.25.2)
return "%="; //$NON-NLS-1$
- case TokenNamePLUS_EQUAL:
+ case PLUS_EQUAL:
// += (15.25.2)
return "+="; //$NON-NLS-1$
- case TokenNameMINUS_EQUAL:
+ case MINUS_EQUAL:
// -= (15.25.2)
return "-="; //$NON-NLS-1$
- case TokenNameMINUS_GREATER:
+ case MINUS_GREATER:
// -= (15.25.2)
return "->"; //$NON-NLS-1$
- case TokenNameLEFT_SHIFT_EQUAL:
+ case LEFT_SHIFT_EQUAL:
// <<= (15.25.2)
return "<<="; //$NON-NLS-1$
- case TokenNameRIGHT_SHIFT_EQUAL:
+ case RIGHT_SHIFT_EQUAL:
// >>= (15.25.2)
return ">>="; //$NON-NLS-1$
- // case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>= (15.25.2)
+ // case UNSIGNED_RIGHT_SHIFT_EQUAL : // >>>= (15.25.2)
// return ">>>="; //$NON-NLS-1$
- case TokenNameAND_EQUAL:
+ case AND_EQUAL:
// &= (15.25.2)
return "&="; //$NON-NLS-1$
- case TokenNameXOR_EQUAL:
+ case XOR_EQUAL:
// ^= (15.25.2)
return "^="; //$NON-NLS-1$
- case TokenNameOR_EQUAL:
+ case OR_EQUAL:
// |= (15.25.2)
return "|="; //$NON-NLS-1$
- case TokenNameDOT_EQUAL:
+ case DOT_EQUAL:
// .=
return ".="; //$NON-NLS-1$
- case TokenNameDOT:
+ case DOT:
// .
return "."; //$NON-NLS-1$
default:
@@ -1695,7 +1702,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
}
- private void outputCurrentTokenWithoutIndent(int token, int newLineCount) {
+ private void outputCurrentTokenWithoutIndent(TokenName heredoc, int newLineCount) {
newLine(newLineCount);
formattedSource.append(scanner.source, scanner.startPosition,
scanner.currentPosition - scanner.startPosition);
@@ -1706,13 +1713,13 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* If it contains \n
, append a LINE_SEPARATOR and indent
* after it.
*/
- private void outputCurrentToken(int token) {
+ private void outputCurrentToken(TokenName token) {
char[] source = scanner.source;
int startPosition = scanner.startPosition;
switch (token) {
- case Scanner.TokenNameCOMMENT_PHPDOC:
- case Scanner.TokenNameCOMMENT_BLOCK:
- case Scanner.TokenNameCOMMENT_LINE:
+ case COMMENT_PHPDOC:
+ case COMMENT_BLOCK:
+ case COMMENT_LINE:
boolean endOfLine = false;
int currentCommentOffset = getCurrentCommentOffset();
int beginningOfLineSpaces = 0;
@@ -1827,7 +1834,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* value of the operator belonging to currentString
.
*/
private void outputLine(String currentString, boolean preIndented,
- int depth, int operator, int substringIndex,
+ int depth, TokenName operator, int substringIndex,
int[] startSubstringIndexes, int offsetInGlobalLine) {
boolean emptyFirstSubString = false;
String operatorString = operatorString(operator);
@@ -1839,7 +1846,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
dumpTab(depth);
preIndented = true;
}
- if (operator != 0) {
+ if (operator.compareTo (TokenName.NONE) > 0) {
if (insertSpaceBefore(operator)) {
formattedSource.append(' ');
increaseSplitDelta(1);
@@ -1847,9 +1854,9 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
formattedSource.append(operatorString);
increaseSplitDelta(operatorString.length());
if (insertSpaceAfter(operator)
- && operator != TokenNameimplements
- && operator != TokenNameextends) {
- // && operator != TokenNamethrows) {
+ && operator != TokenName.IMPLEMENTS
+ && operator != TokenName.EXTENDS) {
+ // && operator != TokenName.throws) {
formattedSource.append(' ');
increaseSplitDelta(1);
}
@@ -1864,8 +1871,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// dumping it
// indent before postfix operator
// indent also when the line cannot be split
- if (operator == TokenNameextends || operator == TokenNameimplements) {
- // || operator == TokenNamethrows) {
+ if (operator == TokenName.EXTENDS || operator == TokenName.IMPLEMENTS) {
+ // || operator == TokenName.throws) {
formattedSource.append(' ');
increaseSplitDelta(1);
}
@@ -1948,12 +1955,12 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
if (placeOperatorBehind) {
if (insertSpaceBefore(operator)) {
formattedSource.append(' ');
- if (operator != 0) {
+ if (operator.compareTo (TokenName.NONE) > 0) {
increaseSplitDelta(1);
}
}
formattedSource.append(operatorString);
- if (operator != 0) {
+ if (operator.compareTo (TokenName.NONE) > 0) {
increaseSplitDelta(operatorString.length());
}
}
@@ -1963,23 +1970,23 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// extends has to stand alone on a line when currentString has been
// split.
if (options.maxLineLength != 0 && splitLine != null
- && (operator == TokenNameextends)) {
- // || operator == TokenNameimplements
- // || operator == TokenNamethrows)) {
+ && (operator == TokenName.EXTENDS)) {
+ // || operator == TokenName.IMPLEMENTS
+ // || operator == TokenName.THROWS)) {
formattedSource.append(options.lineSeparatorSequence);
increaseSplitDelta(options.lineSeparatorSequence.length);
dumpTab(depth + 1);
} else {
- if (operator == TokenNameextends) {
- // || operator == TokenNameimplements
- // || operator == TokenNamethrows) {
+ if (operator == TokenName.EXTENDS) {
+ // || operator == TokenName.implements
+ // || operator == TokenName.throws) {
formattedSource.append(' ');
increaseSplitDelta(1);
}
}
// perform actual splitting
String result[] = splitLine.substrings;
- int[] splitOperators = splitLine.operators;
+ TokenName[] splitOperators = splitLine.operators;
if (result[0].length() == 0) {
// when the substring 0 is null, the substring 1 is correctly
// indented.
@@ -1998,16 +2005,18 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// line
// comments)
String currentResult = result[i];
- if (currentResult.length() != 0 || splitOperators[i] != 0) {
+ if (currentResult.length() != 0 || splitOperators[i].compareTo (TokenName.NONE) > 0) {
int newDepth = (currentResult.startsWith("/*") //$NON-NLS-1$
|| currentResult.startsWith("//")) //$NON-NLS-1$
? indentationLevel - 1
: depth;
- outputLine(currentResult, i == 0
- || (i == 1 && emptyFirstSubString) ? preIndented
- : false, i == 0 ? newDepth : newDepth + 1,
- splitOperators[i], i, splitLine.startSubstringsIndexes,
- currentString.indexOf(currentResult));
+ outputLine(currentResult,
+ i == 0 || (i == 1 && emptyFirstSubString) ? preIndented: false,
+ i == 0 ? newDepth : newDepth + 1,
+ splitOperators[i],
+ i,
+ splitLine.startSubstringsIndexes,
+ currentString.indexOf(currentResult));
if (i != max - 1) {
formattedSource.append(options.lineSeparatorSequence);
increaseSplitDelta(options.lineSeparatorSequence.length);
@@ -2015,13 +2024,13 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
}
}
if (result.length == splitOperators.length - 1) {
- int lastOperator = splitOperators[result.length];
+ TokenName lastOperator = splitOperators[result.length];
String lastOperatorString = operatorString(lastOperator);
formattedSource.append(options.lineSeparatorSequence);
increaseSplitDelta(options.lineSeparatorSequence.length);
if (breakLineBeforeOperator(lastOperator)) {
dumpTab(depth + 1);
- if (lastOperator != 0) {
+ if (lastOperator.compareTo (TokenName.NONE) > 0) {
if (insertSpaceBefore(lastOperator)) {
formattedSource.append(' ');
increaseSplitDelta(1);
@@ -2029,9 +2038,9 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
formattedSource.append(lastOperatorString);
increaseSplitDelta(lastOperatorString.length());
if (insertSpaceAfter(lastOperator)
- && lastOperator != TokenNameimplements
- && lastOperator != TokenNameextends) {
- // && lastOperator != TokenNamethrows) {
+ && lastOperator != TokenName.IMPLEMENTS
+ && lastOperator != TokenName.EXTENDS) {
+ // && lastOperator != TokenName.throws) {
formattedSource.append(' ');
increaseSplitDelta(1);
}
@@ -2051,10 +2060,10 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
/**
* Pops the top statement of the stack if it is token
*/
- private int pop(int token) {
+ private int pop(TokenName do1) {
int delta = 0;
if ((constructionsCount > 0)
- && (constructions[constructionsCount - 1] == token)) {
+ && (constructions[constructionsCount - 1] == do1)) {
delta--;
constructionsCount--;
}
@@ -2065,16 +2074,16 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* Pops the top statement of the stack if it is a BLOCK
or a
* NONINDENT_BLOCK
.
*/
- private int popBlock() {
- int delta = 0;
- if ((constructionsCount > 0)
- && ((constructions[constructionsCount - 1] == BLOCK) || (constructions[constructionsCount - 1] == NONINDENT_BLOCK))) {
- if (constructions[constructionsCount - 1] == BLOCK)
- delta--;
- constructionsCount--;
- }
- return delta;
- }
+// private int popBlock() {
+// int delta = 0;
+// if ((constructionsCount > 0)
+// && ((constructions[constructionsCount - 1] == BLOCK) || (constructions[constructionsCount - 1] == NONINDENT_BLOCK))) {
+// if (constructions[constructionsCount - 1] == BLOCK)
+// delta--;
+// constructionsCount--;
+// }
+// return delta;
+// }
/**
* Pops elements until the stack is empty or the top element is
@@ -2084,16 +2093,16 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* @param token
* the token to be left as the top of the stack
*/
- private int popExclusiveUntil(int token) {
- int delta = 0;
- int startCount = constructionsCount;
- for (int i = startCount - 1; i >= 0 && constructions[i] != token; i--) {
- if (constructions[i] != NONINDENT_BLOCK)
- delta--;
- constructionsCount--;
- }
- return delta;
- }
+// private int popExclusiveUntil(int token) {
+// int delta = 0;
+// int startCount = constructionsCount;
+// for (int i = startCount - 1; i >= 0 && constructions[i] != token; i--) {
+// if (constructions[i] != NONINDENT_BLOCK)
+// delta--;
+// constructionsCount--;
+// }
+// return delta;
+// }
/**
* Pops elements until the stack is empty or the top element is a
@@ -2122,7 +2131,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
int delta = 0;
for (int i = startCount - 1; i >= 0 && constructions[i] != BLOCK
&& constructions[i] != NONINDENT_BLOCK
- && constructions[i] != TokenNamecase; i--) {
+ && constructions[i] != TokenName.CASE; i--) {
constructionsCount--;
delta--;
}
@@ -2137,7 +2146,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* @param token
* the token to remove from the stack
*/
- private int popInclusiveUntil(int token) {
+ private int popInclusiveUntil(TokenName token) {
int startCount = constructionsCount;
int delta = 0;
for (int i = startCount - 1; i >= 0 && constructions[i] != token; i--) {
@@ -2184,12 +2193,12 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
int delta = 0;
if (constructionsCount == constructions.length)
System.arraycopy(constructions, 0,
- (constructions = new int[constructionsCount * 2]), 0,
+ (constructions = new TokenName[constructionsCount * 2]), 0,
constructionsCount);
if ((constructionsCount == 0)
|| (constructions[constructionsCount - 1] == BLOCK)
|| (constructions[constructionsCount - 1] == NONINDENT_BLOCK)
- || (constructions[constructionsCount - 1] == TokenNamecase)) {
+ || (constructions[constructionsCount - 1] == TokenName.CASE)) {
delta++;
constructions[constructionsCount++] = BLOCK;
} else {
@@ -2202,25 +2211,25 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* Pushes token
.
* Creates a new bigger array if the current one is full.
*/
- private int pushControlStatement(int token) {
+ private int pushControlStatement(TokenName token) {
if (constructionsCount == constructions.length)
System.arraycopy(constructions, 0,
- (constructions = new int[constructionsCount * 2]), 0,
+ (constructions = new TokenName[constructionsCount * 2]), 0,
constructionsCount);
constructions[constructionsCount++] = token;
return 1;
}
- private static boolean separateFirstArgumentOn(int currentToken) {
- // return (currentToken == TokenNameCOMMA || currentToken ==
- // TokenNameSEMICOLON);
- return currentToken != TokenNameif && currentToken != TokenNameLPAREN
- && currentToken != TokenNameNOT
- && currentToken != TokenNamewhile
- && currentToken != TokenNamefor
- && currentToken != TokenNameforeach
- && currentToken != TokenNameswitch;
- }
+// private static boolean separateFirstArgumentOn(int currentToken) {
+// // return (currentToken == TokenName.COMMA || currentToken ==
+// // TokenName.SEMICOLON);
+// return currentToken != TokenName.if && currentToken != TokenName.LPAREN
+// && currentToken != TokenName.NOT
+// && currentToken != TokenName.while
+// && currentToken != TokenName.for
+// && currentToken != TokenName.foreach
+// && currentToken != TokenName.switch;
+// }
/**
* Set the positions to map. The mapped positions should be retrieved using
@@ -2256,9 +2265,9 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
* @return an object containing the operator and all the substrings or null
* if the string cannot be split
*/
- public SplitLine split(String stringToSplit) {
- return split(stringToSplit, 0);
- }
+// public SplitLine split(String stringToSplit) {
+// return split(stringToSplit, 0);
+// }
/**
* Splits stringToSplit
on the top level token
@@ -2313,7 +2322,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// while (true) {
// // takes the next token
// try {
- // if (currentToken != Scanner.TokenNameWHITESPACE)
+ // if (currentToken != Scanner.TokenName.WHITESPACE)
// previousToken = currentToken;
// currentToken = splitScanner.getNextToken();
// if (Scanner.DEBUG) {
@@ -2330,14 +2339,14 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// currentToken = 0;
// // this value is not modify when an exception is raised.
// }
- // if (currentToken == TokenNameEOF)
+ // if (currentToken == TokenName.EOF)
// break;
// if (firstTokenOnLine == -1) {
// firstTokenOnLine = currentToken;
// }
// switch (currentToken) {
- // case TokenNameRBRACE :
- // case TokenNameRPAREN :
+ // case TokenName.RBRACE :
+ // case TokenName.RPAREN :
// if (openParenthesisPositionCount > 0) {
// if (openParenthesisPositionCount == 1
// && lastOpenParenthesisPosition < openParenthesisPosition[0]) {
@@ -2363,8 +2372,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// openParenthesisPositionCount--;
// }
// break;
- // case TokenNameLBRACE :
- // case TokenNameLPAREN :
+ // case TokenName.LBRACE :
+ // case TokenName.LPAREN :
// if (openParenthesisPositionCount == openParenthesisPosition.length) {
// System
// .arraycopy(
@@ -2376,17 +2385,17 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// }
// openParenthesisPosition[openParenthesisPositionCount++] =
// splitScanner.currentPosition;
- // if (currentToken == TokenNameLPAREN
- // && previousToken == TokenNameRPAREN) {
+ // if (currentToken == TokenName.LPAREN
+ // && previousToken == TokenName.RPAREN) {
// openParenthesisPosition[openParenthesisPositionCount - 1] =
// splitScanner.startPosition;
// }
// break;
- // case TokenNameSEMICOLON :
+ // case TokenName.SEMICOLON :
// // ;
- // case TokenNameCOMMA :
+ // case TokenName.COMMA :
// // ,
- // case TokenNameEQUAL :
+ // case TokenName.EQUAL :
// // =
// if (openParenthesisPositionCount < splitTokenDepth
// || (openParenthesisPositionCount == splitTokenDepth &&
@@ -2425,8 +2434,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// } else {
// if ((openParenthesisPositionCount == splitTokenDepth &&
// splitTokenPriority == getTokenPriority(currentToken))
- // && splitTokenType != TokenNameEQUAL
- // && currentToken != TokenNameEQUAL) {
+ // && splitTokenType != TokenName.EQUAL
+ // && currentToken != TokenName.EQUAL) {
// // fix for 1FG0BCN: LFCOM:WIN98 - Missing one indentation after
// // split
// // take only the 1st = into account.
@@ -2460,93 +2469,93 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// }
// }
// break;
- // case TokenNameCOLON :
+ // case TokenName.COLON :
// // : (15.24)
// // see 1FK7C5R, we only split on a colon, when it is associated
// // with a question-mark.
// // indeed it might appear also behind a case statement, and we do
// // not to break at this point.
// if ((splitOperatorsCount == 0)
- // || splitOperators[splitOperatorsCount - 1] != TokenNameQUESTION) {
+ // || splitOperators[splitOperatorsCount - 1] != TokenName.QUESTION) {
// break;
// }
- // case TokenNameextends :
- // case TokenNameimplements :
- // //case TokenNamethrows :
- // case TokenNameDOT :
+ // case TokenName.extends :
+ // case TokenName.implements :
+ // //case TokenName.throws :
+ // case TokenName.DOT :
// // .
- // case TokenNameMULTIPLY :
+ // case TokenName.MULTIPLY :
// // * (15.16.1)
- // case TokenNameDIVIDE :
+ // case TokenName.DIVIDE :
// // / (15.16.2)
- // case TokenNameREMAINDER :
+ // case TokenName.REMAINDER :
// // % (15.16.3)
- // case TokenNamePLUS :
+ // case TokenName.PLUS :
// // + (15.17, 15.17.2)
- // case TokenNameMINUS :
+ // case TokenName.MINUS :
// // - (15.17.2)
- // case TokenNameLEFT_SHIFT :
+ // case TokenName.LEFT_SHIFT :
// // << (15.18)
- // case TokenNameRIGHT_SHIFT :
+ // case TokenName.RIGHT_SHIFT :
// // >> (15.18)
- // // case TokenNameUNSIGNED_RIGHT_SHIFT : // >>> (15.18)
- // case TokenNameLESS :
+ // // case TokenName.UNSIGNED_RIGHT_SHIFT : // >>> (15.18)
+ // case TokenName.LESS :
// // < (15.19.1)
- // case TokenNameLESS_EQUAL :
+ // case TokenName.LESS_EQUAL :
// // <= (15.19.1)
- // case TokenNameGREATER :
+ // case TokenName.GREATER :
// // > (15.19.1)
- // case TokenNameGREATER_EQUAL :
+ // case TokenName.GREATER_EQUAL :
// // >= (15.19.1)
- // // case TokenNameinstanceof : // instanceof
- // case TokenNameEQUAL_EQUAL :
+ // // case TokenName.instanceof : // instanceof
+ // case TokenName.EQUAL_EQUAL :
// // == (15.20, 15.20.1, 15.20.2, 15.20.3)
- // case TokenNameEQUAL_EQUAL_EQUAL :
+ // case TokenName.EQUAL_EQUAL_EQUAL :
// // == (15.20, 15.20.1, 15.20.2, 15.20.3)
- // case TokenNameNOT_EQUAL :
+ // case TokenName.NOT_EQUAL :
// // != (15.20, 15.20.1, 15.20.2, 15.20.3)
- // case TokenNameNOT_EQUAL_EQUAL :
+ // case TokenName.NOT_EQUAL_EQUAL :
// // != (15.20, 15.20.1, 15.20.2, 15.20.3)
- // case TokenNameAND :
+ // case TokenName.AND :
// // & (15.21, 15.21.1, 15.21.2)
- // case TokenNameOR :
+ // case TokenName.OR :
// // | (15.21, 15.21.1, 15.21.2)
- // case TokenNameXOR :
+ // case TokenName.XOR :
// // ^ (15.21, 15.21.1, 15.21.2)
- // case TokenNameAND_AND :
+ // case TokenName.AND_AND :
// // && (15.22)
- // case TokenNameOR_OR :
+ // case TokenName.OR_OR :
// // || (15.23)
- // case TokenNameQUESTION :
+ // case TokenName.QUESTION :
// // ? (15.24)
- // case TokenNameMULTIPLY_EQUAL :
+ // case TokenName.MULTIPLY_EQUAL :
// // *= (15.25.2)
- // case TokenNameDIVIDE_EQUAL :
+ // case TokenName.DIVIDE_EQUAL :
// // /= (15.25.2)
- // case TokenNameREMAINDER_EQUAL :
+ // case TokenName.REMAINDER_EQUAL :
// // %= (15.25.2)
- // case TokenNamePLUS_EQUAL :
+ // case TokenName.PLUS_EQUAL :
// // += (15.25.2)
- // case TokenNameMINUS_EQUAL :
+ // case TokenName.MINUS_EQUAL :
// // -= (15.25.2)
- // case TokenNameLEFT_SHIFT_EQUAL :
+ // case TokenName.LEFT_SHIFT_EQUAL :
// // <<= (15.25.2)
- // case TokenNameRIGHT_SHIFT_EQUAL :
+ // case TokenName.RIGHT_SHIFT_EQUAL :
// // >>= (15.25.2)
- // // case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : // >>>= (15.25.2)
- // case TokenNameAND_EQUAL :
+ // // case TokenName.UNSIGNED_RIGHT_SHIFT_EQUAL : // >>>= (15.25.2)
+ // case TokenName.AND_EQUAL :
// // &= (15.25.2)
- // case TokenNameXOR_EQUAL :
+ // case TokenName.XOR_EQUAL :
// // ^= (15.25.2)
- // case TokenNameOR_EQUAL :
+ // case TokenName.OR_EQUAL :
// // |= (15.25.2)
// if ((openParenthesisPositionCount < splitTokenDepth ||
// (openParenthesisPositionCount == splitTokenDepth &&
// splitTokenPriority
// > getTokenPriority(currentToken)))
- // && !((currentToken == TokenNamePLUS || currentToken ==
- // TokenNameMINUS) && (previousToken == TokenNameLBRACE
- // || previousToken == TokenNameLBRACKET || splitScanner.startPosition
+ // && !((currentToken == TokenName.PLUS || currentToken ==
+ // TokenName.MINUS) && (previousToken == TokenName.LBRACE
+ // || previousToken == TokenName.LBRACKET || splitScanner.startPosition
// == 0))) {
// // the current token is better than the one we currently have
// // (in level or in priority if same level)
@@ -2631,9 +2640,9 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// if (splitOperatorsCount == 0)
// return null;
// // ## SPECIAL CASES BEGIN
- // if (((splitOperatorsCount == 2 && splitOperators[1] == TokenNameDOT
+ // if (((splitOperatorsCount == 2 && splitOperators[1] == TokenName.DOT
// && splitTokenDepth == 0 && lastOpenParenthesisPosition > -1)
- // || (splitOperatorsCount > 2 && splitOperators[1] == TokenNameDOT
+ // || (splitOperatorsCount > 2 && splitOperators[1] == TokenName.DOT
// && splitTokenDepth == 0 && lastOpenParenthesisPosition > -1 &&
// lastOpenParenthesisPosition <= options.maxLineLength) ||
// (separateFirstArgumentOn(firstTokenOnLine)
@@ -2651,7 +2660,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// SplitLine sl = split(
// stringToSplit.substring(lastOpenParenthesisPosition),
// lastOpenParenthesisPosition);
- // if (sl == null || sl.operators[0] != TokenNameCOMMA) {
+ // if (sl == null || sl.operators[0] != TokenName.COMMA) {
// // trim() is used to remove the extra blanks at the end of the
// // substring. See PR 1FGYPI1
// return new SplitLine(new int[]{0, 0}, new String[]{