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

Side by Side Diff: pkg/analysis_server/tool/spec/codegen_matchers.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Code generation for the file "matchers.dart". 6 * Code generation for the file "matchers.dart".
7 */ 7 */
8 library codegen.matchers; 8 library codegen.matchers;
9 9
10 import 'dart:convert'; 10 import 'dart:convert';
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 writeln(); 181 writeln();
182 }); 182 });
183 write('}'); 183 write('}');
184 } 184 }
185 185
186 @override 186 @override
187 void visitTypeReference(TypeReference typeReference) { 187 void visitTypeReference(TypeReference typeReference) {
188 write(camelJoin(['is', typeReference.typeName])); 188 write(camelJoin(['is', typeReference.typeName]));
189 } 189 }
190
191 @override
192 void visitTypeUnion(TypeUnion typeUnion) {
193 bool commaNeeded = false;
194 write('isOneOf([');
195 for (TypeDecl choice in typeUnion.choices) {
196 if (commaNeeded) {
197 write(', ');
198 }
199 visitTypeDecl(choice);
200 commaNeeded = true;
201 }
202 write('])');
203 }
190 } 204 }
191 205
192 /** 206 /**
193 * Translate spec_input.html into protocol_matchers.dart. 207 * Translate spec_input.html into protocol_matchers.dart.
194 */ 208 */
195 main() { 209 main() {
196 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi()); 210 CodegenMatchersVisitor visitor = new CodegenMatchersVisitor(readApi());
197 String code = visitor.collectCode(visitor.visitApi); 211 String code = visitor.collectCode(visitor.visitApi);
198 File outputFile = new File('../../test/integration/protocol_matchers.dart'); 212 File outputFile = new File('../../test/integration/protocol_matchers.dart');
199 outputFile.writeAsStringSync(code); 213 outputFile.writeAsStringSync(code);
200 } 214 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/tool/spec/codegen_java.dart ('k') | pkg/analysis_server/tool/spec/from_html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698