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

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

Issue 186153005: New analzyer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use meaningful name instead of '_' in predicate. 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/SemanticProcessor.java
diff --git a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/SemanticProcessor.java b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/SemanticProcessor.java
index 756e7a04f64ea040025e67bd0eb53ec204f896d1..356309f2884125168271619c4237a61c3ee7d27e 100644
--- a/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/SemanticProcessor.java
+++ b/editor/util/plugins/com.google.dart.java2dart/src/com/google/dart/java2dart/processor/SemanticProcessor.java
@@ -19,6 +19,7 @@ import com.google.dart.engine.ast.AstNode;
import com.google.dart.engine.ast.Block;
import com.google.dart.engine.ast.ClassDeclaration;
import com.google.dart.engine.ast.CompilationUnit;
+import com.google.dart.engine.ast.MethodDeclaration;
import com.google.dart.engine.ast.MethodInvocation;
import com.google.dart.java2dart.Context;
import com.google.dart.java2dart.SyntaxTranslator;
@@ -63,6 +64,22 @@ public abstract class SemanticProcessor {
SyntaxTranslator.replaceNode(node.getParent(), node, replacement);
}
+ /**
+ * Replaces "node" with "replacement" in parent of "node".
+ */
+ public static void replaceNode(AstNode parent, AstNode node, AstNode replacement) {
+ SyntaxTranslator.replaceNode(parent, node, replacement);
+ }
+
+ /**
+ * Checks if given {@link IMethodBinding} is method of given class with given name.
+ */
+ protected static boolean isMethodInClass(IMethodBinding binding, String reqName,
+ String reqClassName) {
+ return binding != null && Objects.equal(binding.getName(), reqName)
+ && JavaUtils.isMethodInClass(binding, reqClassName);
+ }
+
protected final Context context;
public SemanticProcessor(Context context) {
@@ -72,12 +89,17 @@ public abstract class SemanticProcessor {
abstract public void process(CompilationUnit unit);
/**
- * Checks if given {@link IMethodBinding} is method of given class with given name.
+ * Checks if {@link IMethodBinding} of the given {@link MethodDeclaration} is method of given
+ * class with given name.
*/
- protected final boolean isMethodInClass(IMethodBinding binding, String reqName,
+ protected final boolean isMethodInClass(MethodDeclaration node, String reqName,
String reqClassName) {
- return binding != null && Objects.equal(binding.getName(), reqName)
- && JavaUtils.isMethodInClass(binding, reqClassName);
+ Object nodeBinding = context.getNodeBinding(node);
+ if (nodeBinding instanceof IMethodBinding) {
+ IMethodBinding binding = (IMethodBinding) nodeBinding;
+ return isMethodInClass(binding, reqName, reqClassName);
+ }
+ return false;
}
/**

Powered by Google App Engine
This is Rietveld 408576698