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

Side by Side 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 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 * Data structures representing an API definition, and visitor base classes 6 * Data structures representing an API definition, and visitor base classes
7 * for visiting those data structures. 7 * for visiting those data structures.
8 */ 8 */
9 library api; 9 library api;
10 10
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 370
371 accept(ApiVisitor visitor) => visitor.visitTypeReference(this); 371 accept(ApiVisitor visitor) => visitor.visitTypeReference(this);
372 } 372 }
373 373
374 /** 374 /**
375 * Type which represents a union among multiple choices. 375 * Type which represents a union among multiple choices.
376 */ 376 */
377 class TypeUnion extends TypeDecl { 377 class TypeUnion extends TypeDecl {
378 final List<TypeDecl> choices; 378 final List<TypeDecl> choices;
379 379
380 TypeUnion(this.choices, dom.Element html) : super(html); 380 /**
381 * The field that is used to disambiguate this union
382 */
383 final String field;
384
385 TypeUnion(this.choices, this.field, dom.Element html) : super(html);
381 386
382 accept(ApiVisitor visitor) => visitor.visitTypeUnion(this); 387 accept(ApiVisitor visitor) => visitor.visitTypeUnion(this);
383 } 388 }
384 389
385 /** 390 /**
386 * Type of a JSON object with specified fields, some of which may be optional. 391 * Type of a JSON object with specified fields, some of which may be optional.
387 */ 392 */
388 class TypeObject extends TypeDecl { 393 class TypeObject extends TypeDecl {
389 final List<TypeObjectField> fields; 394 final List<TypeObjectField> fields;
390 395
391 TypeObject(this.fields, dom.Element html) : super(html); 396 TypeObject(this.fields, dom.Element html) : super(html);
392 397
393 accept(ApiVisitor visitor) => visitor.visitTypeObject(this); 398 accept(ApiVisitor visitor) => visitor.visitTypeObject(this);
399
400 /**
401 * Return the field with the given [name], or null if there is no such field.
402 */
403 TypeObjectField getField(String name) {
404 for (TypeObjectField field in fields) {
405 if (field.name == name) {
406 return field;
407 }
408 }
409 return null;
410 }
394 } 411 }
395 412
396 /** 413 /**
397 * Description of a single field in a [TypeObject]. 414 * Description of a single field in a [TypeObject].
398 */ 415 */
399 class TypeObjectField extends ApiNode { 416 class TypeObjectField extends ApiNode {
400 final String name; 417 final String name;
401 final TypeDecl type; 418 final TypeDecl type;
402 final bool optional; 419 final bool optional;
403 420
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 472 }
456 473
457 /** 474 /**
458 * Description of a single allowed value for an enum. 475 * Description of a single allowed value for an enum.
459 */ 476 */
460 class TypeEnumValue extends ApiNode { 477 class TypeEnumValue extends ApiNode {
461 final String value; 478 final String value;
462 479
463 TypeEnumValue(this.value, dom.Element html) : super(html); 480 TypeEnumValue(this.value, dom.Element html) : super(html);
464 } 481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698