Skip to content

Commit

Permalink
Make the Token class into an enum
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=124639427
  • Loading branch information
blickly committed Jun 13, 2016
1 parent 6a26c4a commit 62f4c44
Show file tree
Hide file tree
Showing 58 changed files with 373 additions and 569 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private void nameObjectLiteralMethods(Node objectLiteral, String context) {
// concatenate the context and key name to get a new qualified name. // concatenate the context and key name to get a new qualified name.
String name = namer.getCombinedName(context, namer.getName(keyNode)); String name = namer.getCombinedName(context, namer.getName(keyNode));


Token.Kind type = valueNode.getType(); Token type = valueNode.getType();
if (type == Token.FUNCTION) { if (type == Token.FUNCTION) {
// set name if function is anonymous // set name if function is anonymous
Node functionNameNode = valueNode.getFirstChild(); Node functionNameNode = valueNode.getFirstChild();
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/AstChangeProxy.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ final void replaceWith(Node parent, Node node, List<Node> replacements) {
return; return;
} }


Token.Kind parentType = parent.getType(); Token parentType = parent.getType();


Preconditions.checkState(size == 1 || Preconditions.checkState(size == 1 ||
parentType == Token.BLOCK || parentType == Token.BLOCK ||
Expand Down
20 changes: 10 additions & 10 deletions src/com/google/javascript/jscomp/AstValidator.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ private void validateParametersEs6(Node n) {
} }
} }


private void validateDefaultValue(Token.Kind type, Node n) { private void validateDefaultValue(Token type, Node n) {
validateAssignmentExpression(n); validateAssignmentExpression(n);
Node lhs = n.getFirstChild(); Node lhs = n.getFirstChild();


Expand All @@ -795,7 +795,7 @@ private void validateCall(Node n) {
* appropriately for a descendant of a {@link Node} of this type. * appropriately for a descendant of a {@link Node} of this type.
* @param n * @param n
*/ */
private void validateRest(Token.Kind contextType, Node n) { private void validateRest(Token contextType, Node n) {
validateNodeType(Token.REST, n); validateNodeType(Token.REST, n);
validateChildCount(n); validateChildCount(n);
validateLHS(contextType, n.getFirstChild()); validateLHS(contextType, n.getFirstChild());
Expand Down Expand Up @@ -827,14 +827,14 @@ private void validateNew(Node n) {
} }
} }


private void validateNameDeclarationHelper(Token.Kind type, Node n) { private void validateNameDeclarationHelper(Token type, Node n) {
validateMinimumChildCount(n, 1); validateMinimumChildCount(n, 1);
for (Node c = n.getFirstChild(); c != null; c = c.getNext()) { for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
validateNameDeclarationChild(type, c); validateNameDeclarationChild(type, c);
} }
} }


private void validateNameDeclarationChild(Token.Kind type, Node n) { private void validateNameDeclarationChild(Token type, Node n) {
if (n.isName()) { if (n.isName()) {
validateLHS(type, n); validateLHS(type, n);
} else if (n.isDestructuringLhs()) { } else if (n.isDestructuringLhs()) {
Expand All @@ -849,7 +849,7 @@ private void validateNameDeclarationChild(Token.Kind type, Node n) {
* appropriately for a descendant of a {@link Node} of this type. * appropriately for a descendant of a {@link Node} of this type.
* @param n * @param n
*/ */
private void validateLHS(Token.Kind contextType, Node n) { private void validateLHS(Token contextType, Node n) {
if (n.isName()) { if (n.isName()) {
// Don't use validateName here since this NAME node may have // Don't use validateName here since this NAME node may have
// a child. // a child.
Expand All @@ -871,7 +871,7 @@ private void validateLHS(Token.Kind contextType, Node n) {
} }
} }


private void validateArrayPattern(Token.Kind type, Node n) { private void validateArrayPattern(Token type, Node n) {
validateNodeType(Token.ARRAY_PATTERN, n); validateNodeType(Token.ARRAY_PATTERN, n);
for (Node c = n.getFirstChild(); c != null; c = c.getNext()) { for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
// When the array pattern is a direct child of a var/let/const node, // When the array pattern is a direct child of a var/let/const node,
Expand All @@ -890,7 +890,7 @@ private void validateArrayPattern(Token.Kind type, Node n) {
} }
} }


private void validateObjectPattern(Token.Kind type, Node n) { private void validateObjectPattern(Token type, Node n) {
validateNodeType(Token.OBJECT_PATTERN, n); validateNodeType(Token.OBJECT_PATTERN, n);
for (Node c = n.getFirstChild(); c != null; c = c.getNext()) { for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {
// When the object pattern is a direct child of a var/let/const node, // When the object pattern is a direct child of a var/let/const node,
Expand Down Expand Up @@ -1243,7 +1243,7 @@ private void validateObjectLitStringKey(Node n) {
} }
} }


private void validateObjectPatternStringKey(Token.Kind type, Node n) { private void validateObjectPatternStringKey(Token type, Node n) {
validateNodeType(Token.STRING_KEY, n); validateNodeType(Token.STRING_KEY, n);
validateObjectLiteralKeyName(n); validateObjectLiteralKeyName(n);
validateChildCountIn(n, 0, 1); validateChildCountIn(n, 0, 1);
Expand All @@ -1260,7 +1260,7 @@ private void validateObjectLitComputedPropKey(Node n) {
validateExpression(n.getLastChild()); validateExpression(n.getLastChild());
} }


private void validateObjectPatternComputedPropKey(Token.Kind type, Node n) { private void validateObjectPatternComputedPropKey(Token type, Node n) {
validateNodeType(Token.COMPUTED_PROP, n); validateNodeType(Token.COMPUTED_PROP, n);
validateChildCount(n); validateChildCount(n);
validateExpression(n.getFirstChild()); validateExpression(n.getFirstChild());
Expand Down Expand Up @@ -1394,7 +1394,7 @@ private void violation(String message, Node n) {
violationHandler.handleViolation(message, n); violationHandler.handleViolation(message, n);
} }


private void validateNodeType(Token.Kind type, Node n) { private void validateNodeType(Token type, Node n) {
if (n.getType() != type) { if (n.getType() != type) {
violation("Expected " + type + " but was " + n.getType(), n); violation("Expected " + type + " but was " + n.getType(), n);
} }
Expand Down
4 changes: 2 additions & 2 deletions src/com/google/javascript/jscomp/CallGraph.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private void createFunctionsAndCallsites(Node jsRoot,
NodeTraversal.traverseEs6(compiler, jsRoot, new AbstractPostOrderCallback() { NodeTraversal.traverseEs6(compiler, jsRoot, new AbstractPostOrderCallback() {
@Override @Override
public void visit(NodeTraversal t, Node n, Node parent) { public void visit(NodeTraversal t, Node n, Node parent) {
Token.Kind nodeType = n.getType(); Token nodeType = n.getType();


if (nodeType == Token.CALL || nodeType == Token.NEW) { if (nodeType == Token.CALL || nodeType == Token.NEW) {
Callsite callsite = createCallsite(n); Callsite callsite = createCallsite(n);
Expand Down Expand Up @@ -365,7 +365,7 @@ private void fillInFunctionInformation(DefinitionProvider provider) {
*/ */
private void updateFunctionForUse(Function function, Node useNode) { private void updateFunctionForUse(Function function, Node useNode) {
Node useParent = useNode.getParent(); Node useParent = useNode.getParent();
Token.Kind parentType = useParent.getType(); Token parentType = useParent.getType();


if ((parentType == Token.CALL || parentType == Token.NEW) if ((parentType == Token.CALL || parentType == Token.NEW)
&& useParent.getFirstChild() == useNode) { && useParent.getFirstChild() == useNode) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/CheckGlobalThis.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
// function a() {} // or // function a() {} // or
// a.x = function() {}; // or // a.x = function() {}; // or
// var a = {x: function() {}}; // var a = {x: function() {}};
Token.Kind pType = parent.getType(); Token pType = parent.getType();
if (!(pType == Token.BLOCK || if (!(pType == Token.BLOCK ||
pType == Token.SCRIPT || pType == Token.SCRIPT ||
pType == Token.NAME || pType == Token.NAME ||
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/CheckRegExp.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {
if (NodeUtil.isReferenceName(n)) { if (NodeUtil.isReferenceName(n)) {
String name = n.getString(); String name = n.getString();
if (name.equals("RegExp") && t.getScope().getVar(name) == null) { if (name.equals("RegExp") && t.getScope().getVar(name) == null) {
Token.Kind parentType = parent.getType(); Token parentType = parent.getType();
boolean first = (n == parent.getFirstChild()); boolean first = (n == parent.getFirstChild());
if (!((parentType == Token.NEW && first) if (!((parentType == Token.NEW && first)
|| (parentType == Token.CALL && first) || (parentType == Token.CALL && first)
Expand Down
4 changes: 2 additions & 2 deletions src/com/google/javascript/jscomp/CodeGenerator.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void add(Node n, Context context) {
} }
} }


Token.Kind type = n.getType(); Token type = n.getType();
String opstr = NodeUtil.opToStr(type); String opstr = NodeUtil.opToStr(type);
int childCount = n.getChildCount(); int childCount = n.getChildCount();
Node first = n.getFirstChild(); Node first = n.getFirstChild();
Expand Down Expand Up @@ -1354,7 +1354,7 @@ private void maybeAddOptional(Node n) {
* We assume nodes are left-recursive. * We assume nodes are left-recursive.
*/ */
private void unrollBinaryOperator( private void unrollBinaryOperator(
Node n, Token.Kind op, String opStr, Context context, Node n, Token op, String opStr, Context context,
Context rhsContext, int leftPrecedence, int rightPrecedence) { Context rhsContext, int leftPrecedence, int rightPrecedence) {
Node firstNonOperator = n.getFirstChild(); Node firstNonOperator = n.getFirstChild();
while (firstNonOperator.getType() == op) { while (firstNonOperator.getType() == op) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/CodePrinter.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ boolean breakAfterBlockFor(Node n, boolean isStatementContext) {
Preconditions.checkState(n.isBlock(), n); Preconditions.checkState(n.isBlock(), n);
Node parent = n.getParent(); Node parent = n.getParent();
if (parent != null) { if (parent != null) {
Token.Kind type = parent.getType(); Token type = parent.getType();
switch (type) { switch (type) {
case DO: case DO:
// Don't break before 'while' in DO-WHILE statements. // Don't break before 'while' in DO-WHILE statements.
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/CollapseProperties.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ private void flattenNameRefAtDepth(String alias, Node n, int depth,
// This method has to work for both GETPROP chains and, in rare cases, // This method has to work for both GETPROP chains and, in rare cases,
// OBJLIT keys, possibly nested. That's why we check for children before // OBJLIT keys, possibly nested. That's why we check for children before
// proceeding. In the OBJLIT case, we don't need to do anything. // proceeding. In the OBJLIT case, we don't need to do anything.
Token.Kind nType = n.getType(); Token nType = n.getType();
boolean isQName = nType == Token.NAME || nType == Token.GETPROP; boolean isQName = nType == Token.NAME || nType == Token.GETPROP;
boolean isObjKey = NodeUtil.isObjectLitKey(n); boolean isObjKey = NodeUtil.isObjectLitKey(n);
Preconditions.checkState(isObjKey || isQName); Preconditions.checkState(isObjKey || isQName);
Expand Down
4 changes: 2 additions & 2 deletions src/com/google/javascript/jscomp/ControlFlowAnalysis.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -876,9 +876,9 @@ private void connectToPossibleExceptionHandler(Node cfgNode, Node target) {
/** /**
* Get the next sibling (including itself) of one of the given types. * Get the next sibling (including itself) of one of the given types.
*/ */
private static Node getNextSiblingOfType(Node first, Token.Kind ... types) { private static Node getNextSiblingOfType(Node first, Token ... types) {
for (Node c = first; c != null; c = c.getNext()) { for (Node c = first; c != null; c = c.getNext()) {
for (Token.Kind type : types) { for (Token type : types) {
if (c.getType() == type) { if (c.getType() == type) {
return c; return c;
} }
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/DefinitionsRemover.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public boolean isExtern() {
* RHS is missing. * RHS is missing.
*/ */
abstract static class IncompleteDefinition extends Definition { abstract static class IncompleteDefinition extends Definition {
private static final Set<Token.Kind> ALLOWED_TYPES = private static final Set<Token> ALLOWED_TYPES =
ImmutableSet.of(Token.NAME, Token.GETPROP, Token.GETELEM); ImmutableSet.of(Token.NAME, Token.GETPROP, Token.GETELEM);
private final Node lValue; private final Node lValue;


Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/Denormalize.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void maybeCollapseAssignShorthand(Node n, Node parent) {
&& NodeUtil.hasCorrespondingAssignmentOp(n.getLastChild()) && NodeUtil.hasCorrespondingAssignmentOp(n.getLastChild())
&& n.getLastChild().getFirstChild().isName()) { && n.getLastChild().getFirstChild().isName()) {
Node op = n.getLastChild(); Node op = n.getLastChild();
Token.Kind assignOp = NodeUtil.getAssignOpFromOp(op); Token assignOp = NodeUtil.getAssignOpFromOp(op);
if (n.getFirstChild().getString().equals(op.getFirstChild().getString())) { if (n.getFirstChild().getString().equals(op.getFirstChild().getString())) {
op.setType(assignOp); op.setType(assignOp);
Node opDetached = op.detachFromParent(); Node opDetached = op.detachFromParent();
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ private void visitDestructuringPatternInEnhancedFor(Node pattern) {
Node block = forNode.getLastChild(); Node block = forNode.getLastChild();
declarationNode.replaceChild( declarationNode.replaceChild(
destructuringLhs, IR.name(tempVarName).useSourceInfoFrom(pattern)); destructuringLhs, IR.name(tempVarName).useSourceInfoFrom(pattern));
Token.Kind declarationType = declarationNode.getType(); Token declarationType = declarationNode.getType();
Node decl = IR.declaration(pattern.detachFromParent(), IR.name(tempVarName), declarationType); Node decl = IR.declaration(pattern.detachFromParent(), IR.name(tempVarName), declarationType);
decl.useSourceInfoIfMissingFromForTree(pattern); decl.useSourceInfoIfMissingFromForTree(pattern);
block.addChildToFront(decl); block.addChildToFront(decl);
Expand Down
4 changes: 2 additions & 2 deletions src/com/google/javascript/jscomp/Es6RewriteGenerators.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ private boolean controlCanExit(Node n) {
/** /**
* Finds the only child of the {@code node} of the given type. * Finds the only child of the {@code node} of the given type.
*/ */
private Node getUnique(Node node, Token.Kind type) { private Node getUnique(Node node, Token type) {
List<Node> matches = new ArrayList<>(); List<Node> matches = new ArrayList<>();
insertAll(node, type, matches); insertAll(node, type, matches);
Preconditions.checkState(matches.size() == 1, matches); Preconditions.checkState(matches.size() == 1, matches);
Expand All @@ -927,7 +927,7 @@ private Node getUnique(Node node, Token.Kind type) {
/** /**
* Adds all children of the {@code node} of the given type to given list. * Adds all children of the {@code node} of the given type to given list.
*/ */
private void insertAll(Node node, Token.Kind type, List<Node> matchingNodes) { private void insertAll(Node node, Token type, List<Node> matchingNodes) {
if (node.getType() == type) { if (node.getType() == type) {
matchingNodes.add(node); matchingNodes.add(node);
} }
Expand Down
4 changes: 2 additions & 2 deletions src/com/google/javascript/jscomp/Es6ToEs3Converter.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private void visitForOf(Node node, Node parent) {
iterName.makeNonIndexable(); iterName.makeNonIndexable();
Node getNext = IR.call(IR.getprop(iterName.cloneTree(), IR.string("next"))); Node getNext = IR.call(IR.getprop(iterName.cloneTree(), IR.string("next")));
String variableName; String variableName;
Token.Kind declType; Token declType;
if (variable.isName()) { if (variable.isName()) {
declType = Token.NAME; declType = Token.NAME;
variableName = variable.getQualifiedName(); variableName = variable.getQualifiedName();
Expand Down Expand Up @@ -502,7 +502,7 @@ private void visitObjectWithComputedProperty(Node obj) {
} }
Node val = propdef.removeFirstChild(); Node val = propdef.removeFirstChild();
propdef.setType(Token.STRING); propdef.setType(Token.STRING);
Token.Kind type = propdef.isQuotedString() ? Token.GETELEM : Token.GETPROP; Token type = propdef.isQuotedString() ? Token.GETELEM : Token.GETPROP;
Node access = new Node(type, IR.name(objName), propdef); Node access = new Node(type, IR.name(objName), propdef);
result = IR.comma(IR.assign(access, val), result); result = IR.comma(IR.assign(access, val), result);
} }
Expand Down
6 changes: 3 additions & 3 deletions src/com/google/javascript/jscomp/ExpressionDecomposer.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void exposeExpression(Node expressionRoot, Node subExpression) {
grandchild = child, grandchild = child,
child = parent, child = parent,
parent = child.getParent()) { parent = child.getParent()) {
Token.Kind parentType = parent.getType(); Token parentType = parent.getType();
Preconditions.checkState( Preconditions.checkState(
!isConditionalOp(parent) || child == parent.getFirstChild()); !isConditionalOp(parent) || child == parent.getFirstChild());
if (parentType == Token.ASSIGN) { if (parentType == Token.ASSIGN) {
Expand All @@ -184,7 +184,7 @@ private void exposeExpression(Node expressionRoot, Node subExpression) {
} else { } else {
// Alias "next()" in "next().foo" // Alias "next()" in "next().foo"
Node left = parent.getFirstChild(); Node left = parent.getFirstChild();
Token.Kind type = left.getType(); Token type = left.getType();
if (left != child) { if (left != child) {
Preconditions.checkState(NodeUtil.isGet(left)); Preconditions.checkState(NodeUtil.isGet(left));
if (type == Token.GETELEM) { if (type == Token.GETELEM) {
Expand Down Expand Up @@ -660,7 +660,7 @@ private static boolean isConditionalOp(Node n) {
static Node findExpressionRoot(Node subExpression) { static Node findExpressionRoot(Node subExpression) {
Node child = subExpression; Node child = subExpression;
for (Node parent : child.getAncestors()) { for (Node parent : child.getAncestors()) {
Token.Kind parentType = parent.getType(); Token parentType = parent.getType();
switch (parentType) { switch (parentType) {
// Supported expression roots: // Supported expression roots:
// SWITCH and IF can have multiple children, but the CASE, DEFAULT, // SWITCH and IF can have multiple children, but the CASE, DEFAULT,
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private static Set<String> findModifiedParameters(
* @param parent The parent of the node. * @param parent The parent of the node.
*/ */
private static boolean canNameValueChange(Node n, Node parent) { private static boolean canNameValueChange(Node n, Node parent) {
Token.Kind type = parent.getType(); Token type = parent.getType();
return (type == Token.VAR || type == Token.INC || type == Token.DEC || return (type == Token.VAR || type == Token.INC || type == Token.DEC ||
(NodeUtil.isAssignmentOp(parent) && parent.getFirstChild() == n) || (NodeUtil.isAssignmentOp(parent) && parent.getFirstChild() == n) ||
(NodeUtil.isForIn(parent))); (NodeUtil.isForIn(parent)));
Expand Down Expand Up @@ -480,7 +480,7 @@ public void visit(Node n) {
*/ */
private boolean hasNonLocalSideEffect(Node n) { private boolean hasNonLocalSideEffect(Node n) {
boolean sideEffect = false; boolean sideEffect = false;
Token.Kind type = n.getType(); Token type = n.getType();
// Note: Only care about changes to non-local names, specifically // Note: Only care about changes to non-local names, specifically
// ignore VAR declaration assignments. // ignore VAR declaration assignments.
if (NodeUtil.isAssignmentOp(n) if (NodeUtil.isAssignmentOp(n)
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void keepSimplifiedHookExpression(Node hook,
hook.addChildToBack(simplifyShortCircuitBranch(elseBranch)); hook.addChildToBack(simplifyShortCircuitBranch(elseBranch));
keepSubTree(hook); keepSubTree(hook);
} else if (thenHasSideEffects || elseHasSideEffects) { } else if (thenHasSideEffects || elseHasSideEffects) {
Token.Kind type = thenHasSideEffects ? Token.AND : Token.OR; Token type = thenHasSideEffects ? Token.AND : Token.OR;
Node body = thenHasSideEffects ? thenBranch : elseBranch; Node body = thenHasSideEffects ? thenBranch : elseBranch;
Node simplified = new Node( Node simplified = new Node(
type, condition.detachFromParent(), type, condition.detachFromParent(),
Expand Down Expand Up @@ -186,7 +186,7 @@ private Node simplifyShortCircuitBranch(Node node) {
} }
} }


private static final Set<Token.Kind> FORBIDDEN_TYPES = ImmutableSet.of( private static final Set<Token> FORBIDDEN_TYPES = ImmutableSet.of(
Token.BLOCK, Token.SCRIPT, Token.VAR, Token.EXPR_RESULT, Token.RETURN); Token.BLOCK, Token.SCRIPT, Token.VAR, Token.EXPR_RESULT, Token.RETURN);
private final AbstractCompiler compiler; private final AbstractCompiler compiler;
private final SideEffectAccumulator accumulator; private final SideEffectAccumulator accumulator;
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/InstrumentFunctions.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {
} else { } else {
Node beforeChild = n; Node beforeChild = n;
for (Node ancestor : n.getAncestors()) { for (Node ancestor : n.getAncestors()) {
Token.Kind type = ancestor.getType(); Token type = ancestor.getType();
if (type == Token.BLOCK || type == Token.SCRIPT) { if (type == Token.BLOCK || type == Token.SCRIPT) {
addingRoot = ancestor; addingRoot = ancestor;
break; break;
Expand Down
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/JsMessageVisitor.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ static String toLowerCamelCaseWithNumericSuffixes(String input) {
* *
* @throws MalformedException if the node is null or the wrong type * @throws MalformedException if the node is null or the wrong type
*/ */
protected void checkNode(@Nullable Node node, Token.Kind type) throws MalformedException { protected void checkNode(@Nullable Node node, Token type) throws MalformedException {
if (node == null) { if (node == null) {
throw new MalformedException( throw new MalformedException(
"Expected node type " + type + "; found: null", node); "Expected node type " + type + "; found: null", node);
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static TypeDeclarationNode convert(@Nullable JSTypeExpression typeExpr) {
// representation directly, and delete this function. // representation directly, and delete this function.
@Nullable @Nullable
public static TypeDeclarationNode convertTypeNodeAST(Node n) { public static TypeDeclarationNode convertTypeNodeAST(Node n) {
Token.Kind token = n.getType(); Token token = n.getType();
switch (token) { switch (token) {
case STAR: case STAR:
case EMPTY: // for function types that don't declare a return type case EMPTY: // for function types that don't declare a return type
Expand Down
10 changes: 5 additions & 5 deletions src/com/google/javascript/jscomp/MinimizeExitPoints.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {
* @param labelName If parent is a label the name of the label to look for, * @param labelName If parent is a label the name of the label to look for,
* null otherwise. Non-null only for breaks within labels. * null otherwise. Non-null only for breaks within labels.
*/ */
void tryMinimizeExits(Node n, Token.Kind exitType, @Nullable String labelName) { void tryMinimizeExits(Node n, Token exitType, @Nullable String labelName) {


// Just an 'exit'. // Just an 'exit'.
if (matchingExitNode(n, exitType, labelName)) { if (matchingExitNode(n, exitType, labelName)) {
Expand Down Expand Up @@ -212,7 +212,7 @@ void tryMinimizeExits(Node n, Token.Kind exitType, @Nullable String labelName) {
} }
} }


void tryMinimizeSwitchExits(Node n, Token.Kind exitType, @Nullable String labelName) { void tryMinimizeSwitchExits(Node n, Token exitType, @Nullable String labelName) {
Preconditions.checkState(n.isSwitch()); Preconditions.checkState(n.isSwitch());
// Skipping the switch condition, visit all the children. // Skipping the switch condition, visit all the children.
for (Node c = n.getSecondChild(); c != null; c = c.getNext()) { for (Node c = n.getSecondChild(); c != null; c = c.getNext()) {
Expand All @@ -229,7 +229,7 @@ void tryMinimizeSwitchExits(Node n, Token.Kind exitType, @Nullable String labelN
* Attempt to remove explicit exits from switch cases that also occur implicitly * Attempt to remove explicit exits from switch cases that also occur implicitly
* after the switch. * after the switch.
*/ */
void tryMinimizeSwitchCaseExits(Node n, Token.Kind exitType, @Nullable String labelName) { void tryMinimizeSwitchCaseExits(Node n, Token exitType, @Nullable String labelName) {
Preconditions.checkState(NodeUtil.isSwitchCase(n)); Preconditions.checkState(NodeUtil.isSwitchCase(n));


Preconditions.checkState(n != n.getParent().getLastChild()); Preconditions.checkState(n != n.getParent().getLastChild());
Expand Down Expand Up @@ -267,7 +267,7 @@ void tryMinimizeSwitchCaseExits(Node n, Token.Kind exitType, @Nullable String la
* named-break associated with a label. * named-break associated with a label.
*/ */
private void tryMinimizeIfBlockExits(Node srcBlock, Node destBlock, private void tryMinimizeIfBlockExits(Node srcBlock, Node destBlock,
Node ifNode, Token.Kind exitType, @Nullable String labelName) { Node ifNode, Token exitType, @Nullable String labelName) {
Node exitNodeParent = null; Node exitNodeParent = null;
Node exitNode = null; Node exitNode = null;


Expand Down Expand Up @@ -326,7 +326,7 @@ private void tryMinimizeIfBlockExits(Node srcBlock, Node destBlock,
* non-null only for breaks associated with labels. * non-null only for breaks associated with labels.
* @return Whether the node matches the specified block-exit type. * @return Whether the node matches the specified block-exit type.
*/ */
private static boolean matchingExitNode(Node n, Token.Kind type, @Nullable String labelName) { private static boolean matchingExitNode(Node n, Token type, @Nullable String labelName) {
if (n.getType() == type) { if (n.getType() == type) {
if (type == Token.RETURN) { if (type == Token.RETURN) {
// only returns without expressions. // only returns without expressions.
Expand Down
4 changes: 2 additions & 2 deletions src/com/google/javascript/jscomp/MinimizedCondition.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ private static MinimizedCondition computeMinimizedCondition(Node n) {
} }
case AND: case AND:
case OR: { case OR: {
Token.Kind opType = n.getType(); Token opType = n.getType();
Token.Kind complementType = opType == Token.AND ? Token.OR : Token.AND; Token complementType = opType == Token.AND ? Token.OR : Token.AND;
MinimizedCondition leftSubtree = MinimizedCondition leftSubtree =
computeMinimizedCondition(n.getFirstChild().detachFromParent()); computeMinimizedCondition(n.getFirstChild().detachFromParent());
MinimizedCondition rightSubtree = MinimizedCondition rightSubtree =
Expand Down

0 comments on commit 62f4c44

Please sign in to comment.