protected Expression transformDeclarationExpression(DeclarationExpression de) { visitAnnotations(de); Expression oldLeft = de.getLeftExpression(); checkingVariableTypeInDeclaration = true; Expression left = transform(oldLeft); checkingVariableTypeInDeclaration = false; if (left instanceof ClassExpression) { ClassExpression ce = (ClassExpression) left; addError("you tried to assign a value to the class " + ce.getType().getName(), oldLeft); return de; } Expression right = transform(de.getRightExpression()); if (right == de.getRightExpression()) { fixDeclaringClass(de); return de; } DeclarationExpression newDeclExpr = new DeclarationExpression(left, de.getOperation(), right); newDeclExpr.setDeclaringClass(de.getDeclaringClass()); fixDeclaringClass(newDeclExpr); newDeclExpr.setSourcePosition(de); newDeclExpr.addAnnotations(de.getAnnotations()); return newDeclExpr; }
expression.addAnnotations(annotations); configureAST(expression, variableDef); ExpressionStatement expressionStatement = new ExpressionStatement(expression);
Expression right = transform(de.getRightExpression()); DeclarationExpression newDecl = new DeclarationExpression(left, de.getOperation(), right); newDecl.addAnnotations(de.getAnnotations()); return newDecl;
protected Expression transformDeclarationExpression(DeclarationExpression de) { visitAnnotations(de); Expression oldLeft = de.getLeftExpression(); checkingVariableTypeInDeclaration = true; Expression left = transform(oldLeft); checkingVariableTypeInDeclaration = false; if (left instanceof ClassExpression) { ClassExpression ce = (ClassExpression) left; addError("you tried to assign a value to the class " + ce.getType().getName(), oldLeft); return de; } Expression right = transform(de.getRightExpression()); if (right == de.getRightExpression()) { fixDeclaringClass(de); return de; } DeclarationExpression newDeclExpr = new DeclarationExpression(left, de.getOperation(), right); newDeclExpr.setDeclaringClass(de.getDeclaringClass()); fixDeclaringClass(newDeclExpr); newDeclExpr.setSourcePosition(de); newDeclExpr.addAnnotations(de.getAnnotations()); return newDeclExpr; }
protected Expression transformDeclarationExpression(DeclarationExpression de) { visitAnnotations(de); Expression oldLeft = de.getLeftExpression(); checkingVariableTypeInDeclaration = true; Expression left = transform(oldLeft); checkingVariableTypeInDeclaration = false; if (left instanceof ClassExpression) { ClassExpression ce = (ClassExpression) left; addError("you tried to assign a value to the class " + ce.getType().getName(), oldLeft); return de; } Expression right = transform(de.getRightExpression()); if (right == de.getRightExpression()) { fixDeclaringClass(de); return de; } DeclarationExpression newDeclExpr = new DeclarationExpression(left, de.getOperation(), right); newDeclExpr.setDeclaringClass(de.getDeclaringClass()); fixDeclaringClass(newDeclExpr); newDeclExpr.setSourcePosition(de); newDeclExpr.addAnnotations(de.getAnnotations()); return newDeclExpr; }
public Expression transform(Expression expr) { if (expr == null) return null; if (expr instanceof MethodCallExpression && candidate == null) { MethodCallExpression mce = (MethodCallExpression) expr; Expression args = transform(mce.getArguments()); if (isNewifyCandidate(mce)) { Expression transformed = transformMethodCall(mce, args); transformed.setSourcePosition(mce); return transformed; } Expression method = transform(mce.getMethod()); Expression object = transform(mce.getObjectExpression()); MethodCallExpression transformed = new MethodCallExpression(object, method, args); transformed.setSourcePosition(mce); return transformed; } else if (expr instanceof DeclarationExpression) { DeclarationExpression de = (DeclarationExpression) expr; if (de == candidate) { candidate = null; Expression left = de.getLeftExpression(); Expression right = transform(de.getRightExpression()); DeclarationExpression newDecl = new DeclarationExpression(left, de.getOperation(), right); newDecl.addAnnotations(de.getAnnotations()); return newDecl; } return de; } return expr.transformExpression(this); }
expression.addAnnotations(annotations); configureAST(expression, variableDef); ExpressionStatement expressionStatement = new ExpressionStatement(expression);