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

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

Issue 1416093007: Experimental `getDiagnostics` request (#24480). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Review fixes. Created 5 years, 1 month 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 * <notification event="...">...</notification> <!-- zero or more --> 133 * <notification event="...">...</notification> <!-- zero or more -->
134 * </domain> 134 * </domain>
135 * 135 *
136 * Child elements can occur in any order. 136 * Child elements can occur in any order.
137 */ 137 */
138 Domain domainFromHtml(dom.Element html) { 138 Domain domainFromHtml(dom.Element html) {
139 checkName(html, 'domain'); 139 checkName(html, 'domain');
140 String name = html.attributes['name']; 140 String name = html.attributes['name'];
141 String context = name ?? 'domain'; 141 String context = name ?? 'domain';
142 bool experimental = html.attributes['experimental'] == 'true'; 142 bool experimental = html.attributes['experimental'] == 'true';
143 checkAttributes(html, ['name'], context, optionalAttributes: ['experimental']) ; 143 checkAttributes(html, ['name'], context,
144 optionalAttributes: ['experimental']);
144 List<Request> requests = <Request>[]; 145 List<Request> requests = <Request>[];
145 List<Notification> notifications = <Notification>[]; 146 List<Notification> notifications = <Notification>[];
146 recurse(html, context, { 147 recurse(html, context, {
147 'request': (dom.Element child) { 148 'request': (dom.Element child) {
148 requests.add(requestFromHtml(child, context)); 149 requests.add(requestFromHtml(child, context));
149 }, 150 },
150 'notification': (dom.Element child) { 151 'notification': (dom.Element child) {
151 notifications.add(notificationFromHtml(child, context)); 152 notifications.add(notificationFromHtml(child, context));
152 } 153 }
153 }); 154 });
154 return new Domain(name, experimental, requests, notifications, html); 155 return new Domain(name, requests, notifications, html,
156 experimental: experimental);
155 } 157 }
156 158
157 dom.Element getAncestor(dom.Element html, String name, String context) { 159 dom.Element getAncestor(dom.Element html, String name, String context) {
158 dom.Element ancestor = html.parent; 160 dom.Element ancestor = html.parent;
159 while (ancestor != null) { 161 while (ancestor != null) {
160 if (ancestor.localName == name) { 162 if (ancestor.localName == name) {
161 return ancestor; 163 return ancestor;
162 } 164 }
163 ancestor = ancestor.parent; 165 ancestor = ancestor.parent;
164 } 166 }
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 * </type> 416 * </type>
415 * 417 *
416 * Where TYPE is any HTML that can be parsed by [typeDeclFromHtml]. 418 * Where TYPE is any HTML that can be parsed by [typeDeclFromHtml].
417 * 419 *
418 * Child elements can occur in any order. 420 * Child elements can occur in any order.
419 */ 421 */
420 TypeDefinition typeDefinitionFromHtml(dom.Element html) { 422 TypeDefinition typeDefinitionFromHtml(dom.Element html) {
421 checkName(html, 'type'); 423 checkName(html, 'type');
422 String name = html.attributes['name']; 424 String name = html.attributes['name'];
423 String context = name != null ? name : 'type'; 425 String context = name != null ? name : 'type';
424 checkAttributes(html, ['name'], context); 426 checkAttributes(html, ['name'], context, optionalAttributes: ['experimental']) ;
425 TypeDecl type = processContentsAsType(html, context); 427 TypeDecl type = processContentsAsType(html, context);
426 return new TypeDefinition(name, type, html); 428 bool experimental = html.attributes['experimental'] == 'true';
429 return new TypeDefinition(name, type, html, experimental: experimental);
427 } 430 }
428 431
429 /** 432 /**
430 * Create a [TypeEnum] from an HTML description. 433 * Create a [TypeEnum] from an HTML description.
431 */ 434 */
432 TypeEnum typeEnumFromHtml(dom.Element html, String context) { 435 TypeEnum typeEnumFromHtml(dom.Element html, String context) {
433 checkName(html, 'enum', context); 436 checkName(html, 'enum', context);
434 checkAttributes(html, [], context); 437 checkAttributes(html, [], context);
435 List<TypeEnumValue> values = <TypeEnumValue>[]; 438 List<TypeEnumValue> values = <TypeEnumValue>[];
436 recurse(html, context, { 439 recurse(html, context, {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 String value = html.attributes['value']; 510 String value = html.attributes['value'];
508 TypeDecl type = processContentsAsType(html, context); 511 TypeDecl type = processContentsAsType(html, context);
509 return new TypeObjectField(name, type, html, 512 return new TypeObjectField(name, type, html,
510 optional: optional, value: value); 513 optional: optional, value: value);
511 } 514 }
512 515
513 /** 516 /**
514 * Create a [TypeObject] from an HTML description. 517 * Create a [TypeObject] from an HTML description.
515 */ 518 */
516 TypeObject typeObjectFromHtml(dom.Element html, String context) { 519 TypeObject typeObjectFromHtml(dom.Element html, String context) {
517 checkAttributes(html, [], context); 520 checkAttributes(html, [], context, optionalAttributes: ['experimental']);
518 List<TypeObjectField> fields = <TypeObjectField>[]; 521 List<TypeObjectField> fields = <TypeObjectField>[];
519 recurse(html, context, { 522 recurse(html, context, {
520 'field': (dom.Element child) { 523 'field': (dom.Element child) {
521 fields.add(typeObjectFieldFromHtml(child, context)); 524 fields.add(typeObjectFieldFromHtml(child, context));
522 } 525 }
523 }); 526 });
524 return new TypeObject(fields, html); 527 bool experimental = html.attributes['experimental'] == 'true';
528 return new TypeObject(fields, html, experimental: experimental);
525 } 529 }
526 530
527 /** 531 /**
528 * Create a [Types] object from an HTML representation such as: 532 * Create a [Types] object from an HTML representation such as:
529 * 533 *
530 * <types> 534 * <types>
531 * <type name="...">...</type> <!-- zero or more --> 535 * <type name="...">...</type> <!-- zero or more -->
532 * </types> 536 * </types>
533 */ 537 */
534 Types typesFromHtml(dom.Element html) { 538 Types typesFromHtml(dom.Element html) {
535 checkName(html, 'types'); 539 checkName(html, 'types');
536 String context = 'types'; 540 String context = 'types';
537 checkAttributes(html, [], context); 541 checkAttributes(html, [], context);
538 Map<String, TypeDefinition> types = <String, TypeDefinition>{}; 542 Map<String, TypeDefinition> types = <String, TypeDefinition>{};
539 recurse(html, context, { 543 recurse(html, context, {
540 'type': (dom.Element child) { 544 'type': (dom.Element child) {
541 TypeDefinition typeDefinition = typeDefinitionFromHtml(child); 545 TypeDefinition typeDefinition = typeDefinitionFromHtml(child);
542 types[typeDefinition.name] = typeDefinition; 546 types[typeDefinition.name] = typeDefinition;
543 } 547 }
544 }); 548 });
545 return new Types(types, html); 549 return new Types(types, html);
546 } 550 }
547 551
548 typedef void ElementProcessor(dom.Element element); 552 typedef void ElementProcessor(dom.Element element);
549 553
550 typedef void TextProcessor(dom.Text text); 554 typedef void TextProcessor(dom.Text text);
OLDNEW
« no previous file with comments | « pkg/analysis_server/tool/spec/api.dart ('k') | pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698