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

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

Issue 469673002: Add union types to the analysis server API spec. (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 5b70f1449015a9cb5b55ef7ab961454bd333842d..7c01e32f2914748eebdcf0f23161603bafa98015 100644
--- a/pkg/analysis_server/tool/spec/api.dart
+++ b/pkg/analysis_server/tool/spec/api.dart
@@ -17,6 +17,7 @@ import 'package:html5lib/dom.dart' as dom;
*/
abstract class ApiVisitor<T> {
T visitTypeReference(TypeReference typeReference);
+ T visitTypeUnion(TypeUnion typeUnion);
T visitTypeObject(TypeObject typeObject);
T visitTypeList(TypeList typeList);
T visitTypeMap(TypeMap typeMap);
@@ -118,6 +119,11 @@ class HierarchicalApiVisitor extends ApiVisitor {
void visitTypeReference(TypeReference typeReference) {
}
+ @override
+ void visitTypeUnion(TypeUnion typeUnion) {
+ typeUnion.choices.forEach(visitTypeDecl);
+ }
+
/**
* If [type] is a [TypeReference] that is defined in the API, follow the
* chain until a non-[TypeReference] is found, if possible.
@@ -366,6 +372,17 @@ class TypeReference extends TypeDecl {
}
/**
+ * Type which represents a union among multiple choices.
+ */
+class TypeUnion extends TypeDecl {
+ final List<TypeDecl> choices;
+
+ TypeUnion(this.choices, dom.Element html) : super(html);
+
+ accept(ApiVisitor visitor) => visitor.visitTypeUnion(this);
+}
+
+/**
* Type of a JSON object with specified fields, some of which may be optional.
*/
class TypeObject extends TypeDecl {

Powered by Google App Engine
This is Rietveld 408576698