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

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

Issue 2800283002: updates to the analysis server generated spec doc (Closed)
Patch Set: revert a change from a separate CL Created 3 years, 8 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 * Code for reading an HTML API description. 6 * Code for reading an HTML API description.
7 */ 7 */
8 library from.html; 8 library from.html;
9 9
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 * [typeDeclFromHtml]. 388 * [typeDeclFromHtml].
389 * 389 *
390 * Child elements can occur in any order. 390 * Child elements can occur in any order.
391 */ 391 */
392 Request requestFromHtml(dom.Element html, String context) { 392 Request requestFromHtml(dom.Element html, String context) {
393 String domainName = getAncestor(html, 'domain', context).attributes['name']; 393 String domainName = getAncestor(html, 'domain', context).attributes['name'];
394 checkName(html, 'request', context); 394 checkName(html, 'request', context);
395 String method = html.attributes['method']; 395 String method = html.attributes['method'];
396 context = '$context.${method != null ? method : 'method'}'; 396 context = '$context.${method != null ? method : 'method'}';
397 checkAttributes(html, ['method'], context, 397 checkAttributes(html, ['method'], context,
398 optionalAttributes: ['experimental']); 398 optionalAttributes: ['experimental', 'deprecated']);
399 bool experimental = html.attributes['experimental'] == 'true'; 399 bool experimental = html.attributes['experimental'] == 'true';
400 bool deprecated = html.attributes['deprecated'] == 'true';
400 TypeDecl params; 401 TypeDecl params;
401 TypeDecl result; 402 TypeDecl result;
402 recurse(html, context, { 403 recurse(html, context, {
403 'params': (dom.Element child) { 404 'params': (dom.Element child) {
404 params = typeObjectFromHtml(child, '$context.params'); 405 params = typeObjectFromHtml(child, '$context.params');
405 }, 406 },
406 'result': (dom.Element child) { 407 'result': (dom.Element child) {
407 result = typeObjectFromHtml(child, '$context.result'); 408 result = typeObjectFromHtml(child, '$context.result');
408 } 409 }
409 }); 410 });
410 return new Request(domainName, method, params, result, html, 411 return new Request(domainName, method, params, result, html,
411 experimental: experimental); 412 experimental: experimental, deprecated: deprecated);
412 } 413 }
413 414
414 /** 415 /**
415 * Create a [TypeDefinition] object from an HTML representation such as: 416 * Create a [TypeDefinition] object from an HTML representation such as:
416 * 417 *
417 * <type name="typeName"> 418 * <type name="typeName">
418 * TYPE 419 * TYPE
419 * </type> 420 * </type>
420 * 421 *
421 * Where TYPE is any HTML that can be parsed by [typeDeclFromHtml]. 422 * Where TYPE is any HTML that can be parsed by [typeDeclFromHtml].
422 * 423 *
423 * Child elements can occur in any order. 424 * Child elements can occur in any order.
424 */ 425 */
425 TypeDefinition typeDefinitionFromHtml(dom.Element html) { 426 TypeDefinition typeDefinitionFromHtml(dom.Element html) {
426 checkName(html, 'type'); 427 checkName(html, 'type');
427 String name = html.attributes['name']; 428 String name = html.attributes['name'];
428 String context = name != null ? name : 'type'; 429 String context = name != null ? name : 'type';
429 checkAttributes(html, ['name'], context, 430 checkAttributes(html, ['name'], context,
430 optionalAttributes: ['experimental']); 431 optionalAttributes: ['experimental', 'deprecated']);
431 TypeDecl type = processContentsAsType(html, context); 432 TypeDecl type = processContentsAsType(html, context);
432 bool experimental = html.attributes['experimental'] == 'true'; 433 bool experimental = html.attributes['experimental'] == 'true';
433 return new TypeDefinition(name, type, html, experimental: experimental); 434 bool deprecated = html.attributes['deprecated'] == 'true';
435 return new TypeDefinition(name, type, html,
436 experimental: experimental, deprecated: deprecated);
434 } 437 }
435 438
436 /** 439 /**
437 * Create a [TypeEnum] from an HTML description. 440 * Create a [TypeEnum] from an HTML description.
438 */ 441 */
439 TypeEnum typeEnumFromHtml(dom.Element html, String context) { 442 TypeEnum typeEnumFromHtml(dom.Element html, String context) {
440 checkName(html, 'enum', context); 443 checkName(html, 'enum', context);
441 checkAttributes(html, [], context); 444 checkAttributes(html, [], context);
442 List<TypeEnumValue> values = <TypeEnumValue>[]; 445 List<TypeEnumValue> values = <TypeEnumValue>[];
443 recurse(html, context, { 446 recurse(html, context, {
(...skipping 10 matching lines...) Expand all
454 * <enum> 457 * <enum>
455 * <code>VALUE</code> 458 * <code>VALUE</code>
456 * </enum> 459 * </enum>
457 * 460 *
458 * Where VALUE is the text of the enumerated value. 461 * Where VALUE is the text of the enumerated value.
459 * 462 *
460 * Child elements can occur in any order. 463 * Child elements can occur in any order.
461 */ 464 */
462 TypeEnumValue typeEnumValueFromHtml(dom.Element html, String context) { 465 TypeEnumValue typeEnumValueFromHtml(dom.Element html, String context) {
463 checkName(html, 'value', context); 466 checkName(html, 'value', context);
464 checkAttributes(html, [], context); 467 checkAttributes(html, [], context, optionalAttributes: ['deprecated']);
468 bool deprecated = html.attributes['deprecated'] == 'true';
465 List<String> values = <String>[]; 469 List<String> values = <String>[];
466 recurse(html, context, { 470 recurse(html, context, {
467 'code': (dom.Element child) { 471 'code': (dom.Element child) {
468 String text = innerText(child).trim(); 472 String text = innerText(child).trim();
469 values.add(text); 473 values.add(text);
470 } 474 }
471 }); 475 });
472 if (values.length != 1) { 476 if (values.length != 1) {
473 throw new Exception('$context: Exactly one value must be specified'); 477 throw new Exception('$context: Exactly one value must be specified');
474 } 478 }
475 return new TypeEnumValue(values[0], html); 479 return new TypeEnumValue(values[0], html, deprecated: deprecated);
476 } 480 }
477 481
478 /** 482 /**
479 * Create a [TypeObjectField] from an HTML description such as: 483 * Create a [TypeObjectField] from an HTML description such as:
480 * 484 *
481 * <field name="fieldName"> 485 * <field name="fieldName">
482 * TYPE 486 * TYPE
483 * </field> 487 * </field>
484 * 488 *
485 * Where TYPE is any HTML that can be parsed by [typeDeclFromHtml]. 489 * Where TYPE is any HTML that can be parsed by [typeDeclFromHtml].
486 * 490 *
487 * In addition, the attribute optional="true" may be used to specify that the 491 * In addition, the attribute optional="true" may be used to specify that the
488 * field is optional, and the attribute value="..." may be used to specify that 492 * field is optional, and the attribute value="..." may be used to specify that
489 * the field is required to have a certain value. 493 * the field is required to have a certain value.
490 * 494 *
491 * Child elements can occur in any order. 495 * Child elements can occur in any order.
492 */ 496 */
493 TypeObjectField typeObjectFieldFromHtml(dom.Element html, String context) { 497 TypeObjectField typeObjectFieldFromHtml(dom.Element html, String context) {
494 checkName(html, 'field', context); 498 checkName(html, 'field', context);
495 String name = html.attributes['name']; 499 String name = html.attributes['name'];
496 context = '$context.${name != null ? name : 'field'}'; 500 context = '$context.${name != null ? name : 'field'}';
497 checkAttributes(html, ['name'], context, 501 checkAttributes(html, ['name'], context,
498 optionalAttributes: ['optional', 'value']); 502 optionalAttributes: ['optional', 'value', 'deprecated']);
503 bool deprecated = html.attributes['deprecated'] == 'true';
499 bool optional = false; 504 bool optional = false;
500 String optionalString = html.attributes['optional']; 505 String optionalString = html.attributes['optional'];
501 if (optionalString != null) { 506 if (optionalString != null) {
502 switch (optionalString) { 507 switch (optionalString) {
503 case 'true': 508 case 'true':
504 optional = true; 509 optional = true;
505 break; 510 break;
506 case 'false': 511 case 'false':
507 optional = false; 512 optional = false;
508 break; 513 break;
509 default: 514 default:
510 throw new Exception( 515 throw new Exception(
511 '$context: field contains invalid "optional" attribute: "$optionalSt ring"'); 516 '$context: field contains invalid "optional" attribute: "$optionalSt ring"');
512 } 517 }
513 } 518 }
514 String value = html.attributes['value']; 519 String value = html.attributes['value'];
515 TypeDecl type = processContentsAsType(html, context); 520 TypeDecl type = processContentsAsType(html, context);
516 return new TypeObjectField(name, type, html, 521 return new TypeObjectField(name, type, html,
517 optional: optional, value: value); 522 optional: optional, value: value, deprecated: deprecated);
518 } 523 }
519 524
520 /** 525 /**
521 * Create a [TypeObject] from an HTML description. 526 * Create a [TypeObject] from an HTML description.
522 */ 527 */
523 TypeObject typeObjectFromHtml(dom.Element html, String context) { 528 TypeObject typeObjectFromHtml(dom.Element html, String context) {
524 checkAttributes(html, [], context, optionalAttributes: ['experimental']); 529 checkAttributes(html, [], context, optionalAttributes: ['experimental']);
525 List<TypeObjectField> fields = <TypeObjectField>[]; 530 List<TypeObjectField> fields = <TypeObjectField>[];
526 recurse(html, context, { 531 recurse(html, context, {
527 'field': (dom.Element child) { 532 'field': (dom.Element child) {
(...skipping 21 matching lines...) Expand all
549 TypeDefinition typeDefinition = typeDefinitionFromHtml(child); 554 TypeDefinition typeDefinition = typeDefinitionFromHtml(child);
550 types[typeDefinition.name] = typeDefinition; 555 types[typeDefinition.name] = typeDefinition;
551 } 556 }
552 }); 557 });
553 return new Types(types, html); 558 return new Types(types, html);
554 } 559 }
555 560
556 typedef void ElementProcessor(dom.Element element); 561 typedef void ElementProcessor(dom.Element element);
557 562
558 typedef void TextProcessor(dom.Text text); 563 typedef void TextProcessor(dom.Text text);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698