Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: dart/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java

Issue 56933002: Version 0.8.10.1 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java
===================================================================
--- dart/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java (revision 29785)
+++ dart/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java (working copy)
@@ -42,6 +42,7 @@
import com.google.dart.java2dart.Context;
import com.google.dart.java2dart.util.JavaUtils;
+import static com.google.dart.java2dart.util.ASTFactory.argumentList;
import static com.google.dart.java2dart.util.ASTFactory.assignmentExpression;
import static com.google.dart.java2dart.util.ASTFactory.binaryExpression;
import static com.google.dart.java2dart.util.ASTFactory.booleanLiteral;
@@ -156,6 +157,21 @@
return null;
}
}
+ // Dart has no "bool &=" operator
+ if (node.getOperator().getType() == TokenType.AMPERSAND_EQ) {
+ Expression leftExpr = node.getLeftHandSide();
+ ITypeBinding argTypeBinding = context.getNodeTypeBinding(leftExpr);
+ if (JavaUtils.isTypeNamed(argTypeBinding, "boolean")) {
+ Expression rightExpr = node.getRightHandSide();
+ replaceNode(
+ node,
+ assignmentExpression(
+ leftExpr,
+ TokenType.EQ,
+ methodInvocation("javaBooleanAnd", leftExpr, rightExpr)));
+ return null;
+ }
+ }
// String += 'c'
if (node.getOperator().getType() == TokenType.PLUS_EQ) {
Expression leftExpr = node.getLeftHandSide();
@@ -202,19 +218,30 @@
return null;
}
}
- // super
- super.visitBinaryExpression(node);
// in Java "true | false" will compute both operands
if (node.getOperator().getType() == TokenType.BAR) {
- Expression leftOperand = node.getLeftOperand();
- ITypeBinding argTypeBinding = context.getNodeTypeBinding(leftOperand);
+ ITypeBinding argTypeBinding = context.getNodeTypeBinding(node.getLeftOperand());
+ super.visitBinaryExpression(node);
if (JavaUtils.isTypeNamed(argTypeBinding, "boolean")) {
replaceNode(
node,
- methodInvocation("javaBooleanOr", leftOperand, node.getRightOperand()));
+ methodInvocation("javaBooleanOr", node.getLeftOperand(), node.getRightOperand()));
return null;
}
}
+ // in Java "true & false" will compute both operands
+ if (node.getOperator().getType() == TokenType.AMPERSAND) {
+ ITypeBinding argTypeBinding = context.getNodeTypeBinding(node.getLeftOperand());
+ super.visitBinaryExpression(node);
+ if (JavaUtils.isTypeNamed(argTypeBinding, "boolean")) {
+ replaceNode(
+ node,
+ methodInvocation("javaBooleanAnd", node.getLeftOperand(), node.getRightOperand()));
+ return null;
+ }
+ }
+ // super
+ super.visitBinaryExpression(node);
// done
return null;
}
@@ -583,10 +610,28 @@
@Override
public Void visitSuperConstructorInvocation(SuperConstructorInvocation node) {
super.visitSuperConstructorInvocation(node);
+ NodeList<Expression> args = node.getArgumentList().getArguments();
IMethodBinding binding = (IMethodBinding) context.getNodeBinding(node);
- if (isMethodInClass2(binding, "<init>(java.lang.Throwable)", "java.lang.Exception")) {
+ if (isMethodInExactClass(binding, "<init>(java.lang.Throwable)", "java.lang.Exception")) {
node.setConstructorName(identifier("withCause"));
}
+ if (isMethodInExactClass(
+ binding,
+ "<init>(java.lang.Throwable)",
+ "java.lang.RuntimeException")) {
+ node.setArgumentList(argumentList(namedExpression("cause", args.get(0))));
+ }
+ if (isMethodInExactClass(binding, "<init>(java.lang.String)", "java.lang.RuntimeException")) {
+ node.setArgumentList(argumentList(namedExpression("message", args.get(0))));
+ }
+ if (isMethodInExactClass(
+ binding,
+ "<init>(java.lang.String,java.lang.Throwable)",
+ "java.lang.RuntimeException")) {
+ node.setArgumentList(argumentList(
+ namedExpression("message", args.get(0)),
+ namedExpression("cause", args.get(0))));
+ }
return null;
}

Powered by Google App Engine
This is Rietveld 408576698