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

Unified Diff: pkg/analysis_server/tool/spec/from_html.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
« no previous file with comments | « pkg/analysis_server/tool/spec/codegen_matchers.dart ('k') | pkg/analysis_server/tool/spec/spec_input.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/tool/spec/from_html.dart
diff --git a/pkg/analysis_server/tool/spec/from_html.dart b/pkg/analysis_server/tool/spec/from_html.dart
index 868f17efa70ee9f3058e9f9cc6b1155af497905a..c1513b8e14908fbdb0f985db266c2ce7e9532649 100644
--- a/pkg/analysis_server/tool/spec/from_html.dart
+++ b/pkg/analysis_server/tool/spec/from_html.dart
@@ -51,7 +51,7 @@ void checkAttributes(dom.Element element, List<String>
const List<String> specialElements = const ['domain', 'feedback',
'object', 'refactorings', 'refactoring', 'type', 'types', 'request',
'notification', 'params', 'result', 'field', 'list', 'map', 'enum', 'key',
- 'value', 'options', 'ref', 'code', 'version'];
+ 'value', 'options', 'ref', 'code', 'version', 'union'];
typedef void ElementProcessor(dom.Element element);
typedef void TextProcessor(dom.Text text);
@@ -303,10 +303,21 @@ Notification notificationFromHtml(dom.Element html) {
});
return new Notification(domainName, event, params, html);
}
+/**
+ * Create a single of [TypeDecl] corresponding to the type defined inside the
+ * given HTML element.
+ */
+TypeDecl processContentsAsType(dom.Element html) {
+ List<TypeDecl> types = processContentsAsTypes(html);
+ if (types.length != 1) {
+ throw new Exception('Exactly one type must be specified');
+ }
+ return types[0];
+}
/**
- * Create a [TypeDecl] from an HTML description. The following forms are
- * supported.
+ * Create a list of [TypeDecl]s corresponding to the types defined inside the
+ * given HTML element. The following forms are supported.
*
* To refer to a type declared elsewhere (or a built-in type):
*
@@ -327,8 +338,13 @@ Notification notificationFromHtml(dom.Element html) {
* <enum>
* <value>...</value> <!-- zero or more -->
* </enum>
+ *
+ * For a union type:
+ * <union>
+ * TYPE <!-- zero or more -->
+ * </union>
*/
-TypeDecl processContentsAsType(dom.Element html) {
+List<TypeDecl> processContentsAsTypes(dom.Element html) {
List<TypeDecl> types = <TypeDecl>[];
recurse(html, {
'object': (dom.Element child) {
@@ -370,12 +386,13 @@ TypeDecl processContentsAsType(dom.Element html) {
'ref': (dom.Element child) {
checkAttributes(child, []);
types.add(new TypeReference(innerText(child), child));
+ },
+ 'union': (dom.Element child) {
+ checkAttributes(child, []);
+ types.add(new TypeUnion(processContentsAsTypes(child), child));
}
});
- if (types.length != 1) {
- throw new Exception('Exactly one type must be specified');
- }
- return types[0];
+ return types;
}
/**
« no previous file with comments | « pkg/analysis_server/tool/spec/codegen_matchers.dart ('k') | pkg/analysis_server/tool/spec/spec_input.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698