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

Side by Side Diff: utils/template/htmltree.dart

Issue 137013002: Removed obsolete code (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed libraries not used Created 6 years, 11 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
« no previous file with comments | « utils/template/codegen.dart ('k') | utils/template/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
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.
4 // Generated by scripts/tree_gen.py.
5
6 /////////////////////////////////////////////////////////////////////////
7 // CSS specific types:
8 /////////////////////////////////////////////////////////////////////////
9
10 class Identifier extends ASTNode {
11 String name;
12
13 Identifier(this.name, SourceSpan span): super(span);
14
15 visit(TreeVisitor visitor) => visitor.visitIdentifier(this);
16
17 String toString() => name;
18 }
19
20 class StringValue extends ASTNode {
21 String value;
22
23 StringValue(this.value, SourceSpan span): super(span);
24
25 visit(TreeVisitor visitor) => visitor.visitStringValue(this);
26
27 String toString() => value;
28 }
29
30 // CDO/CDC (Comment Definition Open <!-- and Comment Definition Close -->).
31 class CommentDefinition extends ASTNode {
32 String comment;
33
34 CommentDefinition(this.comment, SourceSpan span): super(span);
35
36 visit(TreeVisitor visitor) => visitor.visitCommentDefinition(this);
37
38 String toString() => '<!-- ${comment} -->';
39 }
40
41 class Template extends ASTNode {
42 TemplateSignature signature;
43 TemplateContent content;
44
45 Template(this.signature, this.content, SourceSpan span):
46 super(span);
47
48 visit(TreeVisitor visitor) => visitor.visitTemplate(this);
49
50 String toString() => "${signature.toString()} \r{\r${content.toString()}\r}\r" ;
51 }
52
53 class TemplateSignature extends ASTNode {
54 String name;
55 List<Map<Identifier, Identifier>> params; // Map of {type:, name:}
56
57 TemplateSignature(this.name, this.params, SourceSpan span): super(span);
58
59 visit(TreeVisitor visitor) => visitor.visitTemplateSignature(this);
60
61 String paramsAsString() {
62 StringBuffer buff = new StringBuffer();
63 bool first = true;
64 for (final param in params) {
65 if (!first) {
66 buff.write(", ");
67 }
68 if (param['type'] != null) {
69 buff.write(param['type']);
70 buff.write(' ');
71 }
72 buff.write(param['name']);
73 first = false;
74 }
75
76 return buff.toString();
77 }
78
79 String toString() => "template ${name}(${paramsAsString()})";
80 }
81
82 class TemplateChildren extends ASTNode {
83 List<ASTNode> children;
84
85 TemplateChildren(this.children, SourceSpan span): super(span);
86 TemplateChildren.empty(SourceSpan span): children = [], super(span);
87
88 add(var child) {
89 if (children == null) {
90 children = new List<ASTNode>();
91 }
92 children.add(child);
93 }
94
95 ASTNode get last => children.last;
96 ASTNode removeLast() => children.removeLast();
97 bool get anyChildren => children != null && children.length > 0;
98
99 visit(TreeVisitor visitor) => visitor.visitTemplateChildren(this);
100
101 String toString() {
102 StringBuffer buff = new StringBuffer();
103 if (children != null) {
104 for (final child in children) {
105 buff.write(child.toString());
106 }
107 }
108
109 return buff.toString();
110 }
111 }
112
113 class TemplateGetter extends ASTNode {
114 String name;
115 List<Map<Identifier, Identifier>> params;
116 TemplateDocument docFrag;
117
118 TemplateGetter(this.name, this.params, this.docFrag, SourceSpan span) :
119 super(span);
120
121 visit(TreeVisitor visitor) => visitor.visitTemplateGetter(this);
122
123 String paramsAsString() {
124 StringBuffer buff = new StringBuffer();
125 bool first = true;
126 for (final param in params) {
127 if (!first) {
128 buff.write(", ");
129 }
130 if (param['type'] != null && param['type'].length > 0) {
131 buff.write(param['type']);
132 buff.write(' ');
133 }
134 buff.write(param['name']);
135 first = false;
136 }
137
138 return buff.toString();
139 }
140
141 String getterSignatureAsString() => "${name}(${paramsAsString()})";
142 }
143
144 class TemplateContent extends ASTNode {
145 css.Stylesheet css;
146 TemplateDocument html;
147 List<TemplateGetter> getters;
148
149 TemplateContent(this.css, this.html, this.getters, SourceSpan span) :
150 super(span);
151
152 visit(TreeVisitor visitor) => visitor.visitTemplateContent(this);
153 }
154
155 class TemplateDocument extends TemplateChildren {
156 TemplateDocument(List<ASTNode> children, SourceSpan span):
157 super(children, span);
158
159 visit(TreeVisitor visitor) => visitor.visitTemplateDocument(this);
160 }
161
162 class TemplateElement extends TemplateChildren {
163 int tagTokenId;
164 List<TemplateAttribute> attributes;
165 StringValue _varName;
166
167 TemplateElement(this.tagTokenId, SourceSpan span): super.empty(span);
168 TemplateElement.fragment(SourceSpan span) : super.empty(span), tagTokenId = -1 ;
169 TemplateElement.attributes(this.tagTokenId, this.attributes, this._varName,
170 SourceSpan span): super.empty(span);
171
172 bool get isFragment => tagTokenId == -1;
173 bool get anyAttributes => attributes != null;
174
175 visit(TreeVisitor visitor) => visitor.visitTemplateElement(this);
176
177 bool get hasVar => _varName != null;
178 String get varName => hasVar ? _varName.value : null;
179
180 String attributesToString() {
181 StringBuffer buff = new StringBuffer();
182
183 if (attributes != null) {
184 for (final attr in attributes) {
185 buff.write(' ${attr.toString()}');
186 }
187 }
188
189 return buff.toString();
190 }
191
192 String get tagName => isFragment ?
193 'root' : TokenKind.tagNameFromTokenId(tagTokenId);
194
195 bool get scoped => !TokenKind.unscopedTag(tagTokenId);
196
197 String tagStartToString() => "<${tagName}${attributesToString()}>";
198
199 String tagEndToString() => "</${tagName}>";
200
201 String toString() {
202 StringBuffer buff = new StringBuffer(tagStartToString());
203
204 if (children != null) {
205 for (final child in children) {
206 buff.write(child.toString());
207 }
208
209 buff.write(tagEndToString());
210 }
211
212 return buff.toString();
213 }
214 }
215
216 class TemplateAttribute extends ASTNode {
217 String name;
218 String value;
219
220 TemplateAttribute(this.name, this.value, SourceSpan span): super(span);
221
222 visit(TreeVisitor visitor) => visitor.visitTemplateAttribute(this);
223
224 String toString() => "${name}=\"${value}\"";
225 }
226
227 class TemplateText extends ASTNode {
228 String value;
229
230 TemplateText(this.value, SourceSpan span): super(span);
231
232 visit(TreeVisitor visitor) => visitor.visitTemplateText(this);
233
234 String toString() => value;
235 }
236
237 class TemplateExpression extends ASTNode {
238 String expression;
239
240 TemplateExpression(this.expression, SourceSpan span): super(span);
241
242 visit(TreeVisitor visitor) => visitor.visitTemplateExpression(this);
243
244 String toString() => "\$\{${expression}}";
245 }
246
247 class TemplateEachCommand extends ASTNode {
248 String listName;
249 String loopItem;
250 TemplateDocument documentFragment;
251
252 TemplateEachCommand(this.listName, this.loopItem, this.documentFragment,
253 SourceSpan span): super(span);
254
255 bool get hasLoopItem => loopItem != null;
256 String get loopNameOptional => hasLoopItem ? " ${loopItem}" : "";
257
258 visit(TreeVisitor visitor) => visitor.visitTemplateEachCommand(this);
259
260 String toString() => "\$\{#each ${listName}${loopNameOptional}}";
261 }
262
263 class TemplateWithCommand extends ASTNode {
264 String objectName;
265 String blockItem;
266 TemplateDocument documentFragment;
267
268 TemplateWithCommand(this.objectName, this.blockItem, this.documentFragment,
269 SourceSpan span): super(span);
270
271 bool get hasBlockItem => blockItem != null;
272 String get blockNameOptional => hasBlockItem ? " ${blockItem}" : "";
273
274 visit(TreeVisitor visitor) => visitor.visitTemplateWithCommand(this);
275
276 String toString() => "\$\{#with ${objectName}${blockNameOptional}}";
277 }
278
279 class TemplateCall extends ASTNode {
280 String toCall;
281 String params;
282
283 TemplateCall(this.toCall, this.params, SourceSpan span): super(span);
284
285 visit(TreeVisitor visitor) => visitor.visitTemplateCall(this);
286
287 String toString() => "\$\{#${toCall}${params}}";
288 }
289
290 abstract class TreeVisitor {
291 void visitIdentifier(Identifier node);
292 void visitStringValue(StringValue node);
293 void visitCommentDefinition(CommentDefinition node);
294 void visitTemplate(Template node);
295 void visitTemplateSignature(TemplateSignature node);
296 void visitTemplateChildren(TemplateChildren node);
297 void visitTemplateDocument(TemplateDocument node);
298 void visitTemplateContent(TemplateContent node);
299 void visitTemplateElement(TemplateElement node);
300 void visitTemplateAttribute(TemplateAttribute node);
301 void visitTemplateText(TemplateText node);
302 void visitTemplateExpression(TemplateExpression node);
303 void visitTemplateEachCommand(TemplateEachCommand node);
304 void visitTemplateWithCommand(TemplateWithCommand node);
305 void visitTemplateCall(TemplateCall node);
306 void visitTemplateGetter(TemplateGetter node);
307 }
308
309 class TreePrinter implements TreeVisitor {
310 var output;
311 TreePrinter(this.output) { output.printer = this; }
312
313 void visitIdentifier(Identifier node) {
314 output.heading('Identifier(${output.toValue(node.name)})', node.span);
315 }
316
317 void visitStringValue(StringValue node) {
318 output.heading('"${output.toValue(node.value)}"', node.span);
319 }
320
321 void visitCommentDefinition(CommentDefinition node) {
322 output.heading('CommentDefinition (CDO/CDC)', node.span);
323 output.depth++;
324 output.writeValue('comment value', node.comment);
325 output.depth--;
326 }
327
328 void visitTemplate(Template node) {
329 output.heading('Template', node.span);
330 output.depth++;
331 visitTemplateSignature(node.signature);
332 visitTemplateContent(node.content);
333 output.depth--;
334 }
335
336 void visitTemplateSignature(TemplateSignature node) {
337 output.heading('TemplateSignature', node.span);
338 output.depth++;
339 output.writeValue('Template', node);
340 output.depth--;
341 }
342
343 void visitTemplateChildren(TemplateChildren node) {
344 output.writeNodeList('children', node.children);
345 }
346
347 void visitTemplateContent(TemplateContent node) {
348 visitTemplateDocument(node.html);
349 if (node.css != null) {
350 output.depth++;
351 output.writeValue('---CSS---', node.css.toString());
352 output.depth--;
353 }
354 if (node.getters != null) {
355 output.depth++;
356 output.writeNodeList('---GETTERS---', node.getters);
357 output.depth--;
358 }
359 }
360
361 void visitTemplateDocument(TemplateDocument node) {
362 output.heading('Content', node.span);
363 output.depth++;
364 // TODO(terry): Ugly use of 'as dynamic' instead of children[0] to
365 // surpress warning.
366 assert(node.children.length == 1 &&
367 (node.children as dynamic)[0].tagTokenId == -1);
368 output.writeNodeList("document", node.children);
369 output.depth--;
370 }
371
372 void visitTemplateElement(TemplateElement node) {
373 output.heading('Element', node.span);
374 output.depth++;
375 output.writeValue('tag', node.tagName);
376 if (node.attributes != null && (node.attributes.length > 0)) {
377 output.writeNodeList("attributes", node.attributes);
378 }
379 visitTemplateChildren(node);
380 output.depth--;
381 }
382
383 void visitTemplateAttribute(TemplateAttribute node) {
384 output.heading('Attribute', node.span);
385 output.depth++;
386 output.writeValue('name', node.name);
387 output.writeValue('value', node.value);
388 output.depth--;
389 }
390
391 void visitTemplateText(TemplateText node) {
392 output.heading('Text', node.span);
393 output.writeValue('value', node.value);
394 }
395
396 void visitTemplateExpression(TemplateExpression node) {
397 output.heading('Interpolate', node.span);
398 output.writeValue('expression', "\$\{${node.expression}\}");
399 }
400
401 void visitTemplateEachCommand(TemplateEachCommand node) {
402 output.heading('#each', node.span);
403 output.writeValue('list', node.listName);
404 visitTemplateDocument(node.documentFragment);
405 }
406
407 void visitTemplateWithCommand(TemplateWithCommand node) {
408 output.heading('#with', node.span);
409 output.writeValue('object', node.objectName);
410 visitTemplateDocument(node.documentFragment);
411 }
412
413 void visitTemplateCall(TemplateCall node) {
414 output.heading('#call template', node.span);
415 output.writeValue('templateToCall', node.toCall);
416 output.writeValue('params', node.params);
417 }
418
419 void visitTemplateGetter(TemplateGetter node) {
420 output.heading('template getter', node.span);
421 output.writeValue('getter Signature', node.getterSignatureAsString());
422 visitTemplateDocument(node.docFrag);
423 }
424 }
425
OLDNEW
« no previous file with comments | « utils/template/codegen.dart ('k') | utils/template/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698