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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java

Issue 10915031: Issue 4796. Support for renaming named parameters in invocations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java
index 1738d8ba03e3984e12b31bdd7ff2e0b5cb64b606..0fc3c8d1f22056bcb2821f9e7bb634d70ee09587 100644
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/ast/DartAstUtilities.java
@@ -17,6 +17,7 @@ import com.google.dart.compiler.ast.DartClass;
import com.google.dart.compiler.ast.DartExpression;
import com.google.dart.compiler.ast.DartIdentifier;
import com.google.dart.compiler.ast.DartMethodDefinition;
+import com.google.dart.compiler.ast.DartNamedExpression;
import com.google.dart.compiler.ast.DartNewExpression;
import com.google.dart.compiler.ast.DartNode;
import com.google.dart.compiler.ast.DartPropertyAccess;
@@ -25,6 +26,7 @@ import com.google.dart.compiler.ast.DartSuperConstructorInvocation;
import com.google.dart.compiler.ast.DartTypeNode;
import com.google.dart.compiler.resolver.Element;
import com.google.dart.compiler.resolver.MethodElement;
+import com.google.dart.compiler.resolver.VariableElement;
import com.google.dart.compiler.type.InterfaceType;
import com.google.dart.compiler.type.Type;
import com.google.dart.compiler.type.TypeKind;
@@ -45,6 +47,16 @@ public class DartAstUtilities {
public static Element getElement(DartNode node, boolean includeDeclarations) {
Element targetElement = node.getElement();
DartNode parent = node.getParent();
+ // name of named parameter in invocation
+ if (node instanceof DartIdentifier && node.getParent() instanceof DartNamedExpression) {
+ DartNamedExpression namedExpression = (DartNamedExpression) node.getParent();
+ if (namedExpression.getName() == node) {
+ Object parameterId = ((DartIdentifier) node).getInvocationParameterId();
+ if (parameterId instanceof VariableElement) {
+ targetElement = (VariableElement) parameterId;
+ }
+ }
+ }
// target of "new X()" or "new X.a()" is not just a type, it is a constructor
if (parent instanceof DartTypeNode || parent instanceof DartPropertyAccess) {
DartNode grandparent = parent.getParent();

Powered by Google App Engine
This is Rietveld 408576698