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

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

Issue 156763002: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months 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: 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);
- }
- }
- }
}

Powered by Google App Engine
This is Rietveld 408576698