Index: editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java |
diff --git a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java |
index 3c43360291f7d293228af43f8997f1ef419c70d8..f7d03a38d633ee680b0d7eb8d21628ea68f08fab 100644 |
--- a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java |
+++ b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/ObjectSemanticProcessor.java |
@@ -271,7 +271,6 @@ public class ObjectSemanticProcessor extends SemanticProcessor { |
namedExpression("radix", args.get(1)))); |
} |
} |
- replaceStringWithCharSequence(binding, args); |
return null; |
} |
@@ -312,6 +311,7 @@ public class ObjectSemanticProcessor extends SemanticProcessor { |
// |
if (args.isEmpty()) { |
if ("hashCode".equals(name) || isMethodInClass(node, "length", "java.lang.String") |
+ || isMethodInClass(node, "length", "java.lang.CharSequence") |
|| isMethodInClass(node, "isEmpty", "java.lang.String") |
|| isMethodInClass(node, "name", "java.lang.Enum") |
|| isMethodInClass(node, "ordinal", "java.lang.Enum") |
@@ -443,6 +443,14 @@ public class ObjectSemanticProcessor extends SemanticProcessor { |
replaceNode(target, identifier("JavaString")); |
return null; |
} |
+ if (isMethodInClass(node, "charAt", "java.lang.CharSequence")) { |
+ nameNode.setToken(token("codeUnitAt")); |
+ return null; |
+ } |
+ if (isMethodInClass(node, "subSequence", "java.lang.CharSequence")) { |
+ nameNode.setToken(token("substring")); |
+ return null; |
+ } |
if (isMethodInClass(node, "compile", "java.util.regex.Pattern")) { |
replaceNode( |
node, |
@@ -577,7 +585,6 @@ public class ObjectSemanticProcessor extends SemanticProcessor { |
assignmentExpression(propertyAccess(target, nameNode), TokenType.EQ, args.get(0))); |
return null; |
} |
- replaceStringWithCharSequence(binding, args); |
return null; |
} |
@@ -664,6 +671,9 @@ public class ObjectSemanticProcessor extends SemanticProcessor { |
if (name.equals("StringBuilder")) { |
replaceNode(nameNode, identifier("JavaStringBuilder")); |
} |
+ if (name.equals("CharSequence")) { |
+ replaceNode(nameNode, identifier("String")); |
+ } |
// java.util.regex.* |
if (JavaUtils.isTypeNamed(typeBinding, "java.util.regex.Pattern")) { |
replaceNode(nameNode, identifier("RegExp")); |
@@ -721,22 +731,4 @@ public class ObjectSemanticProcessor extends SemanticProcessor { |
} |
}); |
} |
- |
- private void replaceStringWithCharSequence(IMethodBinding methodBinding, List<Expression> args) { |
- if (methodBinding == null) { |
- return; |
- } |
- ITypeBinding[] parameterTypes = methodBinding.getParameterTypes(); |
- for (int i = 0; i < parameterTypes.length; i++) { |
- ITypeBinding parameterType = parameterTypes[i]; |
- Expression arg = args.get(i); |
- ITypeBinding leftBinding = parameterType; |
- ITypeBinding rightBinding = context.getNodeTypeBinding(arg); |
- if (JavaUtils.isTypeNamed(leftBinding, "java.lang.CharSequence") |
- && JavaUtils.isTypeNamed(rightBinding, "java.lang.String")) { |
- arg = instanceCreationExpression(Keyword.NEW, typeName("CharSequence"), arg); |
- args.set(i, arg); |
- } |
- } |
- } |
} |