| Index: editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java
|
| ===================================================================
|
| --- editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java (revision 23549)
|
| +++ editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java (working copy)
|
| @@ -117,6 +117,31 @@
|
| return null;
|
| }
|
| }
|
| + // Dart has no "bool |=" operator
|
| + if (node.getOperator().getType() == TokenType.BAR_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("javaBooleanOr", leftExpr, rightExpr)));
|
| + return null;
|
| + }
|
| + }
|
| + // String += 'c'
|
| + if (node.getOperator().getType() == TokenType.PLUS_EQ) {
|
| + Expression leftExpr = node.getLeftHandSide();
|
| + ITypeBinding argTypeBinding = context.getNodeTypeBinding(leftExpr);
|
| + if (JavaUtils.isTypeNamed(argTypeBinding, "java.lang.String")) {
|
| + Expression rightExpr = node.getRightHandSide();
|
| + replaceCharLiteralWithStringliteral(rightExpr);
|
| + return null;
|
| + }
|
| + }
|
| return null;
|
| }
|
|
|
| @@ -258,6 +283,10 @@
|
| }
|
| return null;
|
| }
|
| + if (isMethodInClass(node, "getMessage", "java.lang.Throwable")) {
|
| + nameNode.setToken(token("toString"));
|
| + return null;
|
| + }
|
| if (isMethodInClass(node, "printStackTrace", "java.lang.Throwable")) {
|
| replaceNode(node, methodInvocation("print", node.getTarget()));
|
| return null;
|
| @@ -270,10 +299,19 @@
|
| nameNode.setToken(token("codeUnitAt"));
|
| return null;
|
| }
|
| - if (isMethodInClass(node, "replace", "java.lang.String")) {
|
| + if (isMethodInClass2(node, "replace(char,char)", "java.lang.String")) {
|
| nameNode.setToken(token("replaceAll"));
|
| + replaceCharLiteralWithStringliteral(args.get(0));
|
| + replaceCharLiteralWithStringliteral(args.get(1));
|
| return null;
|
| }
|
| + if (isMethodInClass2(
|
| + node,
|
| + "replace(java.lang.CharSequence,java.lang.CharSequence)",
|
| + "java.lang.String")) {
|
| + nameNode.setToken(token("replaceAll"));
|
| + return null;
|
| + }
|
| if (isMethodInClass(node, "equalsIgnoreCase", "java.lang.String")) {
|
| replaceNode(
|
| node,
|
| @@ -373,6 +411,10 @@
|
| replaceNode(node, node.getTarget());
|
| return null;
|
| }
|
| + if (isMethodInClass(node, "intValue", "java.lang.Number")) {
|
| + nameNode.setToken(token("toInt"));
|
| + return null;
|
| + }
|
| if (isMethodInClass(node, "doubleValue", "java.math.BigInteger")) {
|
| nameNode.setToken(token("toDouble"));
|
| return null;
|
| @@ -523,6 +565,16 @@
|
| }
|
| return null;
|
| }
|
| +
|
| + private void replaceCharLiteralWithStringliteral(Expression x) {
|
| + if (x instanceof IntegerLiteral) {
|
| + IntegerLiteral literal = (IntegerLiteral) x;
|
| + ITypeBinding typeBinding = context.getNodeTypeBinding(x);
|
| + if (JavaUtils.isTypeNamed(typeBinding, "char")) {
|
| + replaceNode(literal, string(String.valueOf((char) literal.getValue().intValue())));
|
| + }
|
| + }
|
| + }
|
| });
|
| }
|
| }
|
|
|