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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/MethodElementImplementation.java

Issue 9692002: Step back and remove more getNode() invocations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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: compiler/java/com/google/dart/compiler/resolver/MethodElementImplementation.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/MethodElementImplementation.java b/compiler/java/com/google/dart/compiler/resolver/MethodElementImplementation.java
index 382f7a6f8c00bf9fc394bb3e0440bce629190ea7..946ba1e5c045cd1e10a105e66600129be8e421e7 100644
--- a/compiler/java/com/google/dart/compiler/resolver/MethodElementImplementation.java
+++ b/compiler/java/com/google/dart/compiler/resolver/MethodElementImplementation.java
@@ -5,12 +5,14 @@
package com.google.dart.compiler.resolver;
import com.google.common.annotations.VisibleForTesting;
+import com.google.dart.compiler.ast.DartBlock;
import com.google.dart.compiler.ast.DartFunctionExpression;
import com.google.dart.compiler.ast.DartIdentifier;
import com.google.dart.compiler.ast.DartMethodDefinition;
+import com.google.dart.compiler.ast.DartNativeBlock;
import com.google.dart.compiler.ast.DartNode;
-import com.google.dart.compiler.ast.DartParameter;
import com.google.dart.compiler.ast.Modifiers;
+import com.google.dart.compiler.common.SourceInfo;
import com.google.dart.compiler.type.FunctionType;
import com.google.dart.compiler.type.Type;
@@ -24,44 +26,40 @@ class MethodElementImplementation extends AbstractElement implements MethodEleme
private final ElementKind kind;
private final List<VariableElement> parameters = new ArrayList<VariableElement>();
private FunctionType type;
+ private final SourceInfo nameLocation;
+ private final DartNode node;
// TODO(ngeoffray): name, return type, argument types.
@VisibleForTesting
MethodElementImplementation(DartFunctionExpression node, String name, Modifiers modifiers) {
super(node, name);
+ this.node = node;
this.modifiers = modifiers;
this.holder = findParentEnclosingElement(node);
this.kind = ElementKind.FUNCTION_OBJECT;
+ if (node != null && node.getName() != null) {
+ this.nameLocation = node.getName().getSourceInfo();
+ } else {
+ this.nameLocation = SourceInfo.UNKNOWN;
+ }
}
protected MethodElementImplementation(DartMethodDefinition node, String name,
EnclosingElement holder) {
super(node, name);
+ this.node = node;
// TODO(jgw): Pass in modifiers directly, not referencing node.
Brian Wilkerson 2012/03/12 19:09:26 Given that we're using the node for other things n
scheglov 2012/03/12 19:36:24 Done.
if (node != null) {
- modifiers = node.getModifiers();
+ this.modifiers = node.getModifiers();
+ this.nameLocation = node.getName().getSourceInfo();
} else {
- modifiers = Modifiers.NONE;
+ this.modifiers = Modifiers.NONE;
+ this.nameLocation = SourceInfo.UNKNOWN;
}
this.holder = holder;
this.kind = ElementKind.METHOD;
}
- protected MethodElementImplementation(String name, EnclosingElement holder,
- Modifiers modifiers) {
- super(null, name);
- this.modifiers = modifiers;
- this.holder = holder;
- this.kind = ElementKind.METHOD;
- }
-
- private MethodElementImplementation(DartParameter node) {
- super(node, "<anonymous>");
- this.holder = null;
- this.kind = ElementKind.FUNCTION_OBJECT;
- this.modifiers = Modifiers.NONE;
- }
-
@Override
public Modifiers getModifiers() {
return modifiers;
@@ -91,6 +89,16 @@ class MethodElementImplementation extends AbstractElement implements MethodEleme
public List<VariableElement> getParameters() {
return parameters;
}
+
+ @Override
+ public boolean hasBody() {
Brian Wilkerson 2012/03/12 19:09:26 As I said in the previous CL, I think we want to c
scheglov 2012/03/12 19:36:24 Done.
+ if (node instanceof DartMethodDefinition) {
+ DartMethodDefinition methodDefinition = (DartMethodDefinition) node;
+ DartBlock body = methodDefinition.getFunction().getBody();
+ return body != null && !(body instanceof DartNativeBlock);
+ }
+ return false;
+ }
void addParameter(VariableElement parameter) {
parameters.add(parameter);
@@ -161,4 +169,9 @@ class MethodElementImplementation extends AbstractElement implements MethodEleme
}
return null;
}
+
+ @Override
+ public SourceInfo getNameLocation() {
+ return nameLocation;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698