public ASTVariableDeclaration(VariableDeclaration variableDeclaration) { super(variableDeclaration); super.setImage(Token.typeToName(variableDeclaration.getType()).toLowerCase(Locale.ROOT)); }
private void print(VariableDeclaration node) throws IOException { switch (node.getType()) { case Token.VAR: writer.append("var "); break; case Token.LET: writer.append("let "); break; case Token.CONST: writer.append("const "); break; default: break; } print(node.getVariables().get(0)); for (int i = 1; i < node.getVariables().size(); ++i) { writer.append(',').ws(); print(node.getVariables().get(i)); } if (node.isStatement()) { writer.append(';'); } }
private Node transformVariables(VariableDeclaration node) { decompiler.addToken(node.getType()); transformVariableInitializers(node); // Might be most robust to have parser record whether it was // a variable declaration statement, possibly as a node property. AstNode parent = node.getParent(); if (!(parent instanceof Loop) && !(parent instanceof LetNode)) { decompiler.addEOL(Token.SEMI); } return node; }
private Node transformVariables(VariableDeclaration node) { decompiler.addToken(node.getType()); transformVariableInitializers(node); // Might be most robust to have parser record whether it was // a variable declaration statement, possibly as a node property. AstNode parent = node.getParent(); if (!(parent instanceof Loop) && !(parent instanceof LetNode)) { decompiler.addEOL(Token.SEMI); } return node; }
private Node transformVariables(VariableDeclaration node) { decompiler.addToken(node.getType()); transformVariableInitializers(node); // Might be most robust to have parser record whether it was // a variable declaration statement, possibly as a node property. AstNode parent = node.getParent(); if (!(parent instanceof Loop) && !(parent instanceof LetNode)) { decompiler.addEOL(Token.SEMI); } return node; }
private Node transformVariables(VariableDeclaration node) { decompiler.addToken(node.getType()); transformVariableInitializers(node); // Might be most robust to have parser record whether it was // a variable declaration statement, possibly as a node property. AstNode parent = node.getParent(); if (!(parent instanceof Loop) && !(parent instanceof LetNode)) { decompiler.addEOL(Token.SEMI); } return node; }
private void print(VariableDeclaration node) throws IOException { switch (node.getType()) { case Token.VAR: writer.append("var "); break; case Token.LET: writer.append("let "); break; case Token.CONST: writer.append("const "); break; default: break; } print(node.getVariables().get(0)); for (int i = 1; i < node.getVariables().size(); ++i) { writer.append(',').ws(); print(node.getVariables().get(i)); } if (node.isStatement()) { writer.append(';'); } }
node.addChildToBack(left); } else { Node d = createDestructuringAssignment(node.getType(), left, right); node.addChildToBack(d);
node.addChildToBack(left); } else { Node d = createDestructuringAssignment(node.getType(), left, right); node.addChildToBack(d);
node.addChildToBack(left); } else { Node d = createDestructuringAssignment(node.getType(), left, right); node.addChildToBack(d);
node.addChildToBack(left); } else { Node d = createDestructuringAssignment(node.getType(), left, right); node.addChildToBack(d);
private Node transformForInLoop(ForInLoop loop) { decompiler.addToken(Token.FOR); if (loop.isForEach()) decompiler.addName("each "); decompiler.addToken(Token.LP); loop.setType(Token.LOOP); pushScope(loop); try { int declType = -1; AstNode iter = loop.getIterator(); if (iter instanceof VariableDeclaration) { declType = ((VariableDeclaration)iter).getType(); } Node lhs = transform(iter); decompiler.addToken(Token.IN); Node obj = transform(loop.getIteratedObject()); decompiler.addToken(Token.RP); decompiler.addEOL(Token.LC); Node body = transform(loop.getBody()); decompiler.addEOL(Token.RC); return createForIn(declType, loop, lhs, obj, body, loop.isForEach()); } finally { popScope(); } }
private Node transformForInLoop(ForInLoop loop) { decompiler.addToken(Token.FOR); if (loop.isForEach()) decompiler.addName("each "); decompiler.addToken(Token.LP); loop.setType(Token.LOOP); pushScope(loop); try { int declType = -1; AstNode iter = loop.getIterator(); if (iter instanceof VariableDeclaration) { declType = ((VariableDeclaration)iter).getType(); } Node lhs = transform(iter); decompiler.addToken(Token.IN); Node obj = transform(loop.getIteratedObject()); decompiler.addToken(Token.RP); decompiler.addEOL(Token.LC); Node body = transform(loop.getBody()); decompiler.addEOL(Token.RC); return createForIn(declType, loop, lhs, obj, body, loop.isForEach()); } finally { popScope(); } }
private Node transformForInLoop(ForInLoop loop) { decompiler.addToken(Token.FOR); if (loop.isForEach()) decompiler.addName("each "); decompiler.addToken(Token.LP); loop.setType(Token.LOOP); pushScope(loop); try { int declType = -1; AstNode iter = loop.getIterator(); if (iter instanceof VariableDeclaration) { declType = ((VariableDeclaration)iter).getType(); } Node lhs = transform(iter); decompiler.addToken(Token.IN); Node obj = transform(loop.getIteratedObject()); decompiler.addToken(Token.RP); decompiler.addEOL(Token.LC); Node body = transform(loop.getBody()); decompiler.addEOL(Token.RC); return createForIn(declType, loop, lhs, obj, body, loop.isForEach()); } finally { popScope(); } }
private Node transformForInLoop(ForInLoop loop) { decompiler.addToken(Token.FOR); if (loop.isForEach()) decompiler.addName("each "); decompiler.addToken(Token.LP); loop.setType(Token.LOOP); pushScope(loop); try { int declType = -1; AstNode iter = loop.getIterator(); if (iter instanceof VariableDeclaration) { declType = ((VariableDeclaration)iter).getType(); } Node lhs = transform(iter); decompiler.addToken(Token.IN); Node obj = transform(loop.getIteratedObject()); decompiler.addToken(Token.RP); decompiler.addEOL(Token.LC); Node body = transform(loop.getBody()); decompiler.addEOL(Token.RC); return createForIn(declType, loop, lhs, obj, body, loop.isForEach()); } finally { popScope(); } }