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

Unified Diff: pkg/analysis_server/tool/spec/api.dart

Issue 479043002: Code generate Dart classes representing the analysis server API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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: pkg/analysis_server/tool/spec/api.dart
diff --git a/pkg/analysis_server/tool/spec/api.dart b/pkg/analysis_server/tool/spec/api.dart
index 7c01e32f2914748eebdcf0f23161603bafa98015..0c660a7f9d45acb85c762c879056bca73057736a 100644
--- a/pkg/analysis_server/tool/spec/api.dart
+++ b/pkg/analysis_server/tool/spec/api.dart
@@ -377,7 +377,12 @@ class TypeReference extends TypeDecl {
class TypeUnion extends TypeDecl {
final List<TypeDecl> choices;
- TypeUnion(this.choices, dom.Element html) : super(html);
+ /**
+ * The field that is used to disambiguate this union
+ */
+ final String field;
+
+ TypeUnion(this.choices, this.field, dom.Element html) : super(html);
accept(ApiVisitor visitor) => visitor.visitTypeUnion(this);
}
@@ -391,6 +396,18 @@ class TypeObject extends TypeDecl {
TypeObject(this.fields, dom.Element html) : super(html);
accept(ApiVisitor visitor) => visitor.visitTypeObject(this);
+
+ /**
+ * Return the field with the given [name], or null if there is no such field.
+ */
+ TypeObjectField getField(String name) {
+ for (TypeObjectField field in fields) {
+ if (field.name == name) {
+ return field;
+ }
+ }
+ return null;
+ }
}
/**

Powered by Google App Engine
This is Rietveld 408576698