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

Side by Side Diff: pkg/analysis_server/tool/spec/api.dart

Issue 2844273003: Unify the server and plugin versions of the generators (Closed)
Patch Set: add missed files Created 3 years, 7 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
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;
10
11 import 'dart:collection'; 9 import 'dart:collection';
12 10
13 import 'package:html/dom.dart' as dom; 11 import 'package:html/dom.dart' as dom;
14 12
15 /** 13 /**
16 * Toplevel container for the API. 14 * Toplevel container for the API.
17 */ 15 */
18 class Api extends ApiNode { 16 class Api extends ApiNode {
19 final String version; 17 final String version;
20 final List<Domain> domains; 18 final List<Domain> domains;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void visitRefactoring(Refactoring refactoring) { 124 void visitRefactoring(Refactoring refactoring) {
127 if (refactoring.feedback != null) { 125 if (refactoring.feedback != null) {
128 visitTypeDecl(refactoring.feedback); 126 visitTypeDecl(refactoring.feedback);
129 } 127 }
130 if (refactoring.options != null) { 128 if (refactoring.options != null) {
131 visitTypeDecl(refactoring.options); 129 visitTypeDecl(refactoring.options);
132 } 130 }
133 } 131 }
134 132
135 void visitRefactorings(Refactorings refactorings) { 133 void visitRefactorings(Refactorings refactorings) {
136 refactorings.forEach(visitRefactoring); 134 refactorings?.forEach(visitRefactoring);
137 } 135 }
138 136
139 void visitRequest(Request request) { 137 void visitRequest(Request request) {
140 if (request.params != null) { 138 if (request.params != null) {
141 visitTypeDecl(request.params); 139 visitTypeDecl(request.params);
142 } 140 }
143 if (request.result != null) { 141 if (request.result != null) {
144 visitTypeDecl(request.result); 142 visitTypeDecl(request.result);
145 } 143 }
146 } 144 }
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 fields.add(new TypeObjectField('result', result, null)); 338 fields.add(new TypeObjectField('result', result, null));
341 } 339 }
342 return new TypeObject(fields, null); 340 return new TypeObject(fields, null);
343 } 341 }
344 } 342 }
345 343
346 /** 344 /**
347 * Base class for all possible types. 345 * Base class for all possible types.
348 */ 346 */
349 abstract class TypeDecl extends ApiNode { 347 abstract class TypeDecl extends ApiNode {
350 TypeDecl(dom.Element html, bool experimental) 348 TypeDecl(dom.Element html, bool experimental, bool deprecated)
351 : super(html, experimental, false); 349 : super(html, experimental, deprecated);
352 350
353 accept(ApiVisitor visitor); 351 accept(ApiVisitor visitor);
354 } 352 }
355 353
356 /** 354 /**
357 * Description of a named type definition. 355 * Description of a named type definition.
358 */ 356 */
359 class TypeDefinition extends ApiNode { 357 class TypeDefinition extends ApiNode {
360 final String name; 358 final String name;
361 final TypeDecl type; 359 final TypeDecl type;
362 360
363 TypeDefinition(this.name, this.type, dom.Element html, 361 TypeDefinition(this.name, this.type, dom.Element html,
364 {bool experimental, bool deprecated}) 362 {bool experimental, bool deprecated})
365 : super(html, experimental, deprecated); 363 : super(html, experimental, deprecated);
366 } 364 }
367 365
368 /** 366 /**
369 * Type of an enum. We represent enums in JSON as strings, so this type 367 * Type of an enum. We represent enums in JSON as strings, so this type
370 * declaration simply lists the allowed values. 368 * declaration simply lists the allowed values.
371 */ 369 */
372 class TypeEnum extends TypeDecl { 370 class TypeEnum extends TypeDecl {
373 final List<TypeEnumValue> values; 371 final List<TypeEnumValue> values;
374 372
375 TypeEnum(this.values, dom.Element html, {bool experimental}) 373 TypeEnum(this.values, dom.Element html, {bool experimental, bool deprecated})
376 : super(html, experimental); 374 : super(html, experimental, deprecated);
377 375
376 @override
378 accept(ApiVisitor visitor) => visitor.visitTypeEnum(this); 377 accept(ApiVisitor visitor) => visitor.visitTypeEnum(this);
379 } 378 }
380 379
381 /** 380 /**
382 * Description of a single allowed value for an enum. 381 * Description of a single allowed value for an enum.
383 */ 382 */
384 class TypeEnumValue extends ApiNode { 383 class TypeEnumValue extends ApiNode {
385 final String value; 384 final String value;
386 385
387 TypeEnumValue(this.value, dom.Element html, 386 TypeEnumValue(this.value, dom.Element html,
388 {bool experimental, bool deprecated}) 387 {bool experimental, bool deprecated})
389 : super(html, experimental, deprecated); 388 : super(html, experimental, deprecated);
390 } 389 }
391 390
392 /** 391 /**
393 * Type of a JSON list. 392 * Type of a JSON list.
394 */ 393 */
395 class TypeList extends TypeDecl { 394 class TypeList extends TypeDecl {
396 final TypeDecl itemType; 395 final TypeDecl itemType;
397 396
398 TypeList(this.itemType, dom.Element html, {bool experimental}) 397 TypeList(this.itemType, dom.Element html, {bool experimental})
399 : super(html, experimental); 398 : super(html, experimental, false);
400 399
400 @override
401 accept(ApiVisitor visitor) => visitor.visitTypeList(this); 401 accept(ApiVisitor visitor) => visitor.visitTypeList(this);
402 } 402 }
403 403
404 /** 404 /**
405 * Type of a JSON map. 405 * Type of a JSON map.
406 */ 406 */
407 class TypeMap extends TypeDecl { 407 class TypeMap extends TypeDecl {
408 /** 408 /**
409 * Type of map keys. Note that since JSON map keys must always be strings, 409 * Type of map keys. Note that since JSON map keys must always be strings,
410 * this must either be a [TypeReference] for [String], or a [TypeReference] 410 * this must either be a [TypeReference] for [String], or a [TypeReference]
411 * to a type which is defined in the API as an enum or a synonym for [String]. 411 * to a type which is defined in the API as an enum or a synonym for [String].
412 */ 412 */
413 final TypeReference keyType; 413 final TypeReference keyType;
414 414
415 /** 415 /**
416 * Type of map values. 416 * Type of map values.
417 */ 417 */
418 final TypeDecl valueType; 418 final TypeDecl valueType;
419 419
420 TypeMap(this.keyType, this.valueType, dom.Element html, {bool experimental}) 420 TypeMap(this.keyType, this.valueType, dom.Element html, {bool experimental})
421 : super(html, experimental); 421 : super(html, experimental, false);
422 422
423 @override
423 accept(ApiVisitor visitor) => visitor.visitTypeMap(this); 424 accept(ApiVisitor visitor) => visitor.visitTypeMap(this);
424 } 425 }
425 426
426 /** 427 /**
427 * Type of a JSON object with specified fields, some of which may be optional. 428 * Type of a JSON object with specified fields, some of which may be optional.
428 */ 429 */
429 class TypeObject extends TypeDecl { 430 class TypeObject extends TypeDecl {
430 final List<TypeObjectField> fields; 431 final List<TypeObjectField> fields;
431 432
432 TypeObject(this.fields, dom.Element html, {bool experimental}) 433 TypeObject(this.fields, dom.Element html,
433 : super(html, experimental); 434 {bool experimental, bool deprecated})
435 : super(html, experimental, deprecated);
434 436
437 @override
435 accept(ApiVisitor visitor) => visitor.visitTypeObject(this); 438 accept(ApiVisitor visitor) => visitor.visitTypeObject(this);
436 439
437 /** 440 /**
438 * Return the field with the given [name], or null if there is no such field. 441 * Return the field with the given [name], or null if there is no such field.
439 */ 442 */
440 TypeObjectField getField(String name) { 443 TypeObjectField getField(String name) {
441 for (TypeObjectField field in fields) { 444 for (TypeObjectField field in fields) {
442 if (field.name == name) { 445 if (field.name == name) {
443 return field; 446 return field;
444 } 447 }
(...skipping 21 matching lines...) Expand all
466 } 469 }
467 470
468 /** 471 /**
469 * A reference to a type which is either defined elsewhere in the API or which 472 * A reference to a type which is either defined elsewhere in the API or which
470 * is built-in ([String], [bool], or [int]). 473 * is built-in ([String], [bool], or [int]).
471 */ 474 */
472 class TypeReference extends TypeDecl { 475 class TypeReference extends TypeDecl {
473 final String typeName; 476 final String typeName;
474 477
475 TypeReference(this.typeName, dom.Element html, {bool experimental}) 478 TypeReference(this.typeName, dom.Element html, {bool experimental})
476 : super(html, experimental) { 479 : super(html, experimental, false) {
477 if (typeName.isEmpty) { 480 if (typeName.isEmpty) {
478 throw new Exception('Empty type name'); 481 throw new Exception('Empty type name');
479 } 482 }
480 } 483 }
481 484
485 @override
482 accept(ApiVisitor visitor) => visitor.visitTypeReference(this); 486 accept(ApiVisitor visitor) => visitor.visitTypeReference(this);
483 } 487 }
484 488
485 /** 489 /**
486 * A collection of type definitions. 490 * A collection of type definitions.
487 */ 491 */
488 class Types extends ApiNode with IterableMixin<TypeDefinition> { 492 class Types extends ApiNode with IterableMixin<TypeDefinition> {
489 final Map<String, TypeDefinition> types; 493 final Map<String, TypeDefinition> types;
490 494
491 Types(this.types, dom.Element html, {bool experimental}) 495 Types(this.types, dom.Element html, {bool experimental})
(...skipping 14 matching lines...) Expand all
506 */ 510 */
507 class TypeUnion extends TypeDecl { 511 class TypeUnion extends TypeDecl {
508 final List<TypeDecl> choices; 512 final List<TypeDecl> choices;
509 513
510 /** 514 /**
511 * The field that is used to disambiguate this union 515 * The field that is used to disambiguate this union
512 */ 516 */
513 final String field; 517 final String field;
514 518
515 TypeUnion(this.choices, this.field, dom.Element html, {bool experimental}) 519 TypeUnion(this.choices, this.field, dom.Element html, {bool experimental})
516 : super(html, experimental); 520 : super(html, experimental, false);
517 521
522 @override
518 accept(ApiVisitor visitor) => visitor.visitTypeUnion(this); 523 accept(ApiVisitor visitor) => visitor.visitTypeUnion(this);
519 } 524 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/timing/timing_framework.dart ('k') | pkg/analysis_server/tool/spec/check_all_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698