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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/ClassDeclaration.java

Issue 108173006: Add ClassDeclaration.getField(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: New ClassDeclarationTest file. Created 7 years 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
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/ast/ClassDeclarationTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/ClassDeclaration.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/ClassDeclaration.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/ClassDeclaration.java
index 43b0d35d65b0d2cf5ecb41ab4e212e2c8e296bae..9c05e0550edbd1f2e79678d1b21f9aa4a2056ca2 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/ClassDeclaration.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/ClassDeclaration.java
@@ -166,6 +166,28 @@ public class ClassDeclaration extends CompilationUnitMember {
}
/**
+ * Return the field declared in the class with the given name.
+ *
+ * @param name the name of the field to find
+ * @return the found field or {@code null} if not found
+ */
+ public VariableDeclaration getField(String name) {
+ for (ClassMember classMember : members) {
+ if (classMember instanceof FieldDeclaration) {
+ FieldDeclaration fieldDeclaration = (FieldDeclaration) classMember;
+ NodeList<VariableDeclaration> fields = fieldDeclaration.getFields().getVariables();
+ for (VariableDeclaration field : fields) {
+ SimpleIdentifier fieldName = field.getName();
+ if (fieldName != null && name.equals(fieldName.getName())) {
+ return field;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
* Return the implements clause for the class, or {@code null} if the class does not implement any
* interfaces.
*
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/ast/ClassDeclarationTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698