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

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/html.dart

Issue 17249003: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine.html; 3 library engine.html;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'java_core.dart'; 5 import 'java_core.dart';
6 import 'java_engine.dart'; 6 import 'java_engine.dart';
7 import 'source.dart'; 7 import 'source.dart';
8 import 'error.dart'; 8 import 'error.dart';
9 import 'instrumentation.dart'; 9 import 'instrumentation.dart';
10 import 'element.dart' show HtmlElementImpl; 10 import 'element.dart' show HtmlElementImpl;
11 import 'engine.dart' show AnalysisEngine; 11 import 'engine.dart' show AnalysisEngine;
12 /** 12 /**
13 * Instances of the class {@code Token} represent a token that was scanned from the input. Each 13 * Instances of the class `Token` represent a token that was scanned from the in put. Each
14 * token knows which token follows it, acting as the head of a linked list of to kens. 14 * token knows which token follows it, acting as the head of a linked list of to kens.
15 * @coverage dart.engine.html 15 * @coverage dart.engine.html
16 */ 16 */
17 class Token { 17 class Token {
18 18
19 /** 19 /**
20 * The offset from the beginning of the file to the first character in the tok en. 20 * The offset from the beginning of the file to the first character in the tok en.
21 */ 21 */
22 int _offset = 0; 22 int _offset = 0;
23 23
(...skipping 12 matching lines...) Expand all
36 */ 36 */
37 TokenType _type; 37 TokenType _type;
38 38
39 /** 39 /**
40 * The lexeme represented by this token. 40 * The lexeme represented by this token.
41 */ 41 */
42 String _value; 42 String _value;
43 43
44 /** 44 /**
45 * Initialize a newly created token. 45 * Initialize a newly created token.
46 * @param type the token type (not {@code null}) 46 * @param type the token type (not `null`)
47 * @param offset the offset from the beginning of the file to the first charac ter in the token 47 * @param offset the offset from the beginning of the file to the first charac ter in the token
48 */ 48 */
49 Token.con1(TokenType type, int offset) { 49 Token.con1(TokenType type, int offset) {
50 _jtd_constructor_155_impl(type, offset); 50 _jtd_constructor_155_impl(type, offset);
51 } 51 }
52 _jtd_constructor_155_impl(TokenType type, int offset) { 52 _jtd_constructor_155_impl(TokenType type, int offset) {
53 _jtd_constructor_156_impl(type, offset, type.lexeme); 53 _jtd_constructor_156_impl(type, offset, type.lexeme);
54 } 54 }
55 55
56 /** 56 /**
57 * Initialize a newly created token. 57 * Initialize a newly created token.
58 * @param type the token type (not {@code null}) 58 * @param type the token type (not `null`)
59 * @param offset the offset from the beginning of the file to the first charac ter in the token 59 * @param offset the offset from the beginning of the file to the first charac ter in the token
60 * @param value the lexeme represented by this token (not {@code null}) 60 * @param value the lexeme represented by this token (not `null`)
61 */ 61 */
62 Token.con2(TokenType type2, int offset2, String value2) { 62 Token.con2(TokenType type2, int offset2, String value2) {
63 _jtd_constructor_156_impl(type2, offset2, value2); 63 _jtd_constructor_156_impl(type2, offset2, value2);
64 } 64 }
65 _jtd_constructor_156_impl(TokenType type2, int offset2, String value2) { 65 _jtd_constructor_156_impl(TokenType type2, int offset2, String value2) {
66 this._type = type2; 66 this._type = type2;
67 this._value = StringUtilities.intern(value2); 67 this._value = StringUtilities.intern(value2);
68 this._offset = offset2; 68 this._offset = offset2;
69 } 69 }
70 70
71 /** 71 /**
72 * Return the offset from the beginning of the file to the character after las t character of the 72 * Return the offset from the beginning of the file to the character after las t character of the
73 * token. 73 * token.
74 * @return the offset from the beginning of the file to the first character af ter last character 74 * @return the offset from the beginning of the file to the first character af ter last character
75 * of the token 75 * of the token
76 */ 76 */
77 int get end => _offset + length; 77 int get end => _offset + length;
78 78
79 /** 79 /**
80 * Return the number of characters in the node's source range. 80 * Return the number of characters in the node's source range.
81 * @return the number of characters in the node's source range 81 * @return the number of characters in the node's source range
82 */ 82 */
83 int get length => lexeme.length; 83 int get length => lexeme.length;
84 84
85 /** 85 /**
86 * Return the lexeme that represents this token. 86 * Return the lexeme that represents this token.
87 * @return the lexeme (not {@code null}) 87 * @return the lexeme (not `null`)
88 */ 88 */
89 String get lexeme => _value; 89 String get lexeme => _value;
90 90
91 /** 91 /**
92 * Return the next token in the token stream. 92 * Return the next token in the token stream.
93 * @return the next token in the token stream 93 * @return the next token in the token stream
94 */ 94 */
95 Token get next => _next; 95 Token get next => _next;
96 96
97 /** 97 /**
98 * Return the offset from the beginning of the file to the first character in the token. 98 * Return the offset from the beginning of the file to the first character in the token.
99 * @return the offset from the beginning of the file to the first character in the token 99 * @return the offset from the beginning of the file to the first character in the token
100 */ 100 */
101 int get offset => _offset; 101 int get offset => _offset;
102 102
103 /** 103 /**
104 * Return the previous token in the token stream. 104 * Return the previous token in the token stream.
105 * @return the previous token in the token stream 105 * @return the previous token in the token stream
106 */ 106 */
107 Token get previous => _previous; 107 Token get previous => _previous;
108 108
109 /** 109 /**
110 * Answer the token type for the receiver. 110 * Answer the token type for the receiver.
111 * @return the token type (not {@code null}) 111 * @return the token type (not `null`)
112 */ 112 */
113 TokenType get type => _type; 113 TokenType get type => _type;
114 114
115 /** 115 /**
116 * Return {@code true} if this token is a synthetic token. A synthetic token i s a token that was 116 * Return `true` if this token is a synthetic token. A synthetic token is a to ken that was
117 * introduced by the parser in order to recover from an error in the code. Syn thetic tokens always 117 * introduced by the parser in order to recover from an error in the code. Syn thetic tokens always
118 * have a length of zero ({@code 0}). 118 * have a length of zero (`0`).
119 * @return {@code true} if this token is a synthetic token 119 * @return `true` if this token is a synthetic token
120 */ 120 */
121 bool isSynthetic() => length == 0; 121 bool isSynthetic() => length == 0;
122 122
123 /** 123 /**
124 * Set the next token in the token stream to the given token. This has the sid e-effect of setting 124 * Set the next token in the token stream to the given token. This has the sid e-effect of setting
125 * this token to be the previous token for the given token. 125 * this token to be the previous token for the given token.
126 * @param token the next token in the token stream 126 * @param token the next token in the token stream
127 * @return the token that was passed in 127 * @return the token that was passed in
128 */ 128 */
129 Token setNext(Token token) { 129 Token setNext(Token token) {
130 _next = token; 130 _next = token;
131 token.previous = this; 131 token.previous = this;
132 return token; 132 return token;
133 } 133 }
134 String toString() => lexeme; 134 String toString() => lexeme;
135 135
136 /** 136 /**
137 * Set the previous token in the token stream to the given token. 137 * Set the previous token in the token stream to the given token.
138 * @param previous the previous token in the token stream 138 * @param previous the previous token in the token stream
139 */ 139 */
140 void set previous(Token previous2) { 140 void set previous(Token previous2) {
141 this._previous = previous2; 141 this._previous = previous2;
142 } 142 }
143 } 143 }
144 /** 144 /**
145 * Instances of {@code HtmlParseResult} hold the result of parsing an HTML file. 145 * Instances of `HtmlParseResult` hold the result of parsing an HTML file.
146 * @coverage dart.engine.html 146 * @coverage dart.engine.html
147 */ 147 */
148 class HtmlParseResult extends HtmlScanResult { 148 class HtmlParseResult extends HtmlScanResult {
149 149
150 /** 150 /**
151 * The unit containing the parsed information (not {@code null}). 151 * The unit containing the parsed information (not `null`).
152 */ 152 */
153 HtmlUnit _unit; 153 HtmlUnit _unit;
154 HtmlParseResult(int modificationTime, Token token, List<int> lineStarts, HtmlU nit unit) : super(modificationTime, token, lineStarts) { 154 HtmlParseResult(int modificationTime, Token token, List<int> lineStarts, HtmlU nit unit) : super(modificationTime, token, lineStarts) {
155 this._unit = unit; 155 this._unit = unit;
156 } 156 }
157 157
158 /** 158 /**
159 * Answer the unit generated by parsing the source 159 * Answer the unit generated by parsing the source
160 * @return the unit (not {@code null}) 160 * @return the unit (not `null`)
161 */ 161 */
162 HtmlUnit get htmlUnit => _unit; 162 HtmlUnit get htmlUnit => _unit;
163 } 163 }
164 /** 164 /**
165 * Instances of the class {@code RecursiveXmlVisitor} implement an XML visitor t hat will recursively 165 * Instances of the class `RecursiveXmlVisitor` implement an XML visitor that wi ll recursively
166 * visit all of the nodes in an XML structure. For example, using an instance of this class to visit 166 * visit all of the nodes in an XML structure. For example, using an instance of this class to visit
167 * a {@link XmlTagNode} will also cause all of the contained {@link XmlAttribute Node}s and{@link XmlTagNode}s to be visited. 167 * a [XmlTagNode] will also cause all of the contained [XmlAttributeNode]s and[X mlTagNode]s to be visited.
168 * <p> 168 *
169 * Subclasses that override a visit method must either invoke the overridden vis it method or must 169 * Subclasses that override a visit method must either invoke the overridden vis it method or must
170 * explicitly ask the visited node to visit its children. Failure to do so will cause the children 170 * explicitly ask the visited node to visit its children. Failure to do so will cause the children
171 * of the visited node to not be visited. 171 * of the visited node to not be visited.
172 * @coverage dart.engine.html 172 * @coverage dart.engine.html
173 */ 173 */
174 class RecursiveXmlVisitor<R> implements XmlVisitor<R> { 174 class RecursiveXmlVisitor<R> implements XmlVisitor<R> {
175 R visitHtmlUnit(HtmlUnit node) { 175 R visitHtmlUnit(HtmlUnit node) {
176 node.visitChildren(this); 176 node.visitChildren(this);
177 return null; 177 return null;
178 } 178 }
179 R visitXmlAttributeNode(XmlAttributeNode node) { 179 R visitXmlAttributeNode(XmlAttributeNode node) {
180 node.visitChildren(this); 180 node.visitChildren(this);
181 return null; 181 return null;
182 } 182 }
183 R visitXmlTagNode(XmlTagNode node) { 183 R visitXmlTagNode(XmlTagNode node) {
184 node.visitChildren(this); 184 node.visitChildren(this);
185 return null; 185 return null;
186 } 186 }
187 } 187 }
188 /** 188 /**
189 * The abstract class {@code XmlNode} defines behavior common to all XML/HTML no des. 189 * The abstract class `XmlNode` defines behavior common to all XML/HTML nodes.
190 * @coverage dart.engine.html 190 * @coverage dart.engine.html
191 */ 191 */
192 abstract class XmlNode { 192 abstract class XmlNode {
193 193
194 /** 194 /**
195 * The parent of the node, or {@code null} if the node is the root of an AST s tructure. 195 * The parent of the node, or `null` if the node is the root of an AST structu re.
196 */ 196 */
197 XmlNode _parent; 197 XmlNode _parent;
198 198
199 /** 199 /**
200 * Use the given visitor to visit this node. 200 * Use the given visitor to visit this node.
201 * @param visitor the visitor that will visit this node 201 * @param visitor the visitor that will visit this node
202 * @return the value returned by the visitor as a result of visiting this node 202 * @return the value returned by the visitor as a result of visiting this node
203 */ 203 */
204 accept(XmlVisitor visitor); 204 accept(XmlVisitor visitor);
205 205
206 /** 206 /**
207 * Return the first token included in this node's source range. 207 * Return the first token included in this node's source range.
208 * @return the first token or {@code null} if none 208 * @return the first token or `null` if none
209 */ 209 */
210 Token get beginToken; 210 Token get beginToken;
211 211
212 /** 212 /**
213 * Return the offset of the character immediately following the last character of this node's 213 * Return the offset of the character immediately following the last character of this node's
214 * source range. This is equivalent to {@code node.getOffset() + node.getLengt h()}. For an html 214 * source range. This is equivalent to `node.getOffset() + node.getLength()`. For an html
215 * unit this will be equal to the length of the unit's source. 215 * unit this will be equal to the length of the unit's source.
216 * @return the offset of the character just past the node's source range 216 * @return the offset of the character just past the node's source range
217 */ 217 */
218 int get end => offset + length; 218 int get end => offset + length;
219 219
220 /** 220 /**
221 * Return the last token included in this node's source range. 221 * Return the last token included in this node's source range.
222 * @return the last token or {@code null} if none 222 * @return the last token or `null` if none
223 */ 223 */
224 Token get endToken; 224 Token get endToken;
225 225
226 /** 226 /**
227 * Return the number of characters in the node's source range. 227 * Return the number of characters in the node's source range.
228 * @return the number of characters in the node's source range 228 * @return the number of characters in the node's source range
229 */ 229 */
230 int get length { 230 int get length {
231 Token beginToken = this.beginToken; 231 Token beginToken = this.beginToken;
232 Token endToken = this.endToken; 232 Token endToken = this.endToken;
(...skipping 11 matching lines...) Expand all
244 */ 244 */
245 int get offset { 245 int get offset {
246 Token beginToken = this.beginToken; 246 Token beginToken = this.beginToken;
247 if (beginToken == null) { 247 if (beginToken == null) {
248 return -1; 248 return -1;
249 } 249 }
250 return beginToken.offset; 250 return beginToken.offset;
251 } 251 }
252 252
253 /** 253 /**
254 * Return this node's parent node, or {@code null} if this node is the root of an AST structure. 254 * Return this node's parent node, or `null` if this node is the root of an AS T structure.
255 * <p> 255 *
256 * Note that the relationship between an AST node and its parent node may chan ge over the lifetime 256 * Note that the relationship between an AST node and its parent node may chan ge over the lifetime
257 * of a node. 257 * of a node.
258 * @return the parent of this node, or {@code null} if none 258 * @return the parent of this node, or `null` if none
259 */ 259 */
260 XmlNode get parent => _parent; 260 XmlNode get parent => _parent;
261 String toString() { 261 String toString() {
262 PrintStringWriter writer = new PrintStringWriter(); 262 PrintStringWriter writer = new PrintStringWriter();
263 accept(new ToSourceVisitor(writer)); 263 accept(new ToSourceVisitor(writer));
264 return writer.toString(); 264 return writer.toString();
265 } 265 }
266 266
267 /** 267 /**
268 * Use the given visitor to visit all of the children of this node. The childr en will be visited 268 * Use the given visitor to visit all of the children of this node. The childr en will be visited
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 if (identical(current, this)) { 346 if (identical(current, this)) {
347 AnalysisEngine.instance.logger.logError3(new IllegalArgumentException(bu ildRecursiveStructureMessage(newParent))); 347 AnalysisEngine.instance.logger.logError3(new IllegalArgumentException(bu ildRecursiveStructureMessage(newParent)));
348 return; 348 return;
349 } 349 }
350 current = current.parent; 350 current = current.parent;
351 } 351 }
352 _parent = newParent; 352 _parent = newParent;
353 } 353 }
354 } 354 }
355 /** 355 /**
356 * Instances of the class {@code SimpleXmlVisitor} implement an AST visitor that will do nothing 356 * Instances of the class `SimpleXmlVisitor` implement an AST visitor that will do nothing
357 * when visiting an AST node. It is intended to be a superclass for classes that use the visitor 357 * when visiting an AST node. It is intended to be a superclass for classes that use the visitor
358 * pattern primarily as a dispatch mechanism (and hence don't need to recursivel y visit a whole 358 * pattern primarily as a dispatch mechanism (and hence don't need to recursivel y visit a whole
359 * structure) and that only need to visit a small number of node types. 359 * structure) and that only need to visit a small number of node types.
360 */ 360 */
361 class SimpleXmlVisitor<R> implements XmlVisitor<R> { 361 class SimpleXmlVisitor<R> implements XmlVisitor<R> {
362 R visitHtmlUnit(HtmlUnit htmlUnit) => null; 362 R visitHtmlUnit(HtmlUnit htmlUnit) => null;
363 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode) => null; 363 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode) => null;
364 R visitXmlTagNode(XmlTagNode xmlTagNode) => null; 364 R visitXmlTagNode(XmlTagNode xmlTagNode) => null;
365 } 365 }
366 /** 366 /**
367 * The abstract class {@code AbstractScanner} implements a scanner for HTML code . Subclasses are 367 * The abstract class `AbstractScanner` implements a scanner for HTML code. Subc lasses are
368 * required to implement the interface used to access the characters being scann ed. 368 * required to implement the interface used to access the characters being scann ed.
369 * @coverage dart.engine.html 369 * @coverage dart.engine.html
370 */ 370 */
371 abstract class AbstractScanner { 371 abstract class AbstractScanner {
372 static List<String> _NO_PASS_THROUGH_ELEMENTS = <String> []; 372 static List<String> _NO_PASS_THROUGH_ELEMENTS = <String> [];
373 373
374 /** 374 /**
375 * The source being scanned. 375 * The source being scanned.
376 */ 376 */
377 Source _source; 377 Source _source;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 /** 417 /**
418 * Return the current offset relative to the beginning of the file. Return the initial offset if 418 * Return the current offset relative to the beginning of the file. Return the initial offset if
419 * the scanner has not yet scanned the source code, and one (1) past the end o f the source code if 419 * the scanner has not yet scanned the source code, and one (1) past the end o f the source code if
420 * the source code has been scanned. 420 * the source code has been scanned.
421 * @return the current offset of the scanner in the source 421 * @return the current offset of the scanner in the source
422 */ 422 */
423 int get offset; 423 int get offset;
424 424
425 /** 425 /**
426 * Answer the source being scanned. 426 * Answer the source being scanned.
427 * @return the source or {@code null} if undefined 427 * @return the source or `null` if undefined
428 */ 428 */
429 Source get source => _source; 429 Source get source => _source;
430 430
431 /** 431 /**
432 * Set array of element tags for which the content between tags should be cons ider a single token. 432 * Set array of element tags for which the content between tags should be cons ider a single token.
433 */ 433 */
434 void set passThroughElements(List<String> passThroughElements2) { 434 void set passThroughElements(List<String> passThroughElements2) {
435 this._passThroughElements = passThroughElements2 != null ? passThroughElemen ts2 : _NO_PASS_THROUGH_ELEMENTS; 435 this._passThroughElements = passThroughElements2 != null ? passThroughElemen ts2 : _NO_PASS_THROUGH_ELEMENTS;
436 } 436 }
437 437
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 631 }
632 emit3(TokenType.TAG, start, -1); 632 emit3(TokenType.TAG, start, -1);
633 } else { 633 } else {
634 emit3(TokenType.TEXT, start, 0); 634 emit3(TokenType.TEXT, start, 0);
635 c = advance(); 635 c = advance();
636 } 636 }
637 } 637 }
638 } 638 }
639 } 639 }
640 /** 640 /**
641 * Instances of {@code HtmlScanResult} hold the result of scanning an HTML file. 641 * Instances of `HtmlScanResult` hold the result of scanning an HTML file.
642 * @coverage dart.engine.html 642 * @coverage dart.engine.html
643 */ 643 */
644 class HtmlScanResult { 644 class HtmlScanResult {
645 645
646 /** 646 /**
647 * The time at which the contents of the source were last set. 647 * The time at which the contents of the source were last set.
648 */ 648 */
649 int _modificationTime = 0; 649 int _modificationTime = 0;
650 650
651 /** 651 /**
652 * The first token in the token stream (not {@code null}). 652 * The first token in the token stream (not `null`).
653 */ 653 */
654 Token _token; 654 Token _token;
655 655
656 /** 656 /**
657 * The line start information that was produced. 657 * The line start information that was produced.
658 */ 658 */
659 List<int> _lineStarts; 659 List<int> _lineStarts;
660 HtmlScanResult(int modificationTime, Token token, List<int> lineStarts) { 660 HtmlScanResult(int modificationTime, Token token, List<int> lineStarts) {
661 this._modificationTime = modificationTime; 661 this._modificationTime = modificationTime;
662 this._token = token; 662 this._token = token;
663 this._lineStarts = lineStarts; 663 this._lineStarts = lineStarts;
664 } 664 }
665 665
666 /** 666 /**
667 * Answer the line start information that was produced. 667 * Answer the line start information that was produced.
668 * @return an array of line starts (not {@code null}) 668 * @return an array of line starts (not `null`)
669 */ 669 */
670 List<int> get lineStarts => _lineStarts; 670 List<int> get lineStarts => _lineStarts;
671 671
672 /** 672 /**
673 * Return the time at which the contents of the source were last set. 673 * Return the time at which the contents of the source were last set.
674 * @return the time at which the contents of the source were last set 674 * @return the time at which the contents of the source were last set
675 */ 675 */
676 int get modificationTime => _modificationTime; 676 int get modificationTime => _modificationTime;
677 677
678 /** 678 /**
679 * Answer the first token in the token stream. 679 * Answer the first token in the token stream.
680 * @return the token (not {@code null}) 680 * @return the token (not `null`)
681 */ 681 */
682 Token get token => _token; 682 Token get token => _token;
683 } 683 }
684 /** 684 /**
685 * Instances of the class {@code StringScanner} implement a scanner that reads f rom a string. The 685 * Instances of the class `StringScanner` implement a scanner that reads from a string. The
686 * scanning logic is in the superclass. 686 * scanning logic is in the superclass.
687 * @coverage dart.engine.html 687 * @coverage dart.engine.html
688 */ 688 */
689 class StringScanner extends AbstractScanner { 689 class StringScanner extends AbstractScanner {
690 690
691 /** 691 /**
692 * The string from which characters will be read. 692 * The string from which characters will be read.
693 */ 693 */
694 String _string; 694 String _string;
695 695
(...skipping 30 matching lines...) Expand all
726 } 726 }
727 String getString(int start, int endDelta) => _string.substring(start, _charOff set + 1 + endDelta); 727 String getString(int start, int endDelta) => _string.substring(start, _charOff set + 1 + endDelta);
728 int peek() { 728 int peek() {
729 if (_charOffset + 1 < _stringLength) { 729 if (_charOffset + 1 < _stringLength) {
730 return _string.codeUnitAt(_charOffset + 1); 730 return _string.codeUnitAt(_charOffset + 1);
731 } 731 }
732 return -1; 732 return -1;
733 } 733 }
734 } 734 }
735 /** 735 /**
736 * Instances of the class {@code CharBufferScanner} implement a scanner that rea ds from a character 736 * Instances of the class `CharBufferScanner` implement a scanner that reads fro m a character
737 * buffer. The scanning logic is in the superclass. 737 * buffer. The scanning logic is in the superclass.
738 * @coverage dart.engine.html 738 * @coverage dart.engine.html
739 */ 739 */
740 class CharBufferScanner extends AbstractScanner { 740 class CharBufferScanner extends AbstractScanner {
741 741
742 /** 742 /**
743 * The buffer from which characters will be read. 743 * The buffer from which characters will be read.
744 */ 744 */
745 CharSequence _buffer; 745 CharSequence _buffer;
746 746
(...skipping 27 matching lines...) Expand all
774 } 774 }
775 String getString(int start, int endDelta) => _buffer.subSequence(start, _charO ffset + 1 + endDelta).toString(); 775 String getString(int start, int endDelta) => _buffer.subSequence(start, _charO ffset + 1 + endDelta).toString();
776 int peek() { 776 int peek() {
777 if (_charOffset + 1 < _bufferLength) { 777 if (_charOffset + 1 < _bufferLength) {
778 return _buffer.charAt(_charOffset + 1); 778 return _buffer.charAt(_charOffset + 1);
779 } 779 }
780 return -1; 780 return -1;
781 } 781 }
782 } 782 }
783 /** 783 /**
784 * Instances of the class {@code ToSourceVisitor} write a source representation of a visited XML 784 * Instances of the class `ToSourceVisitor` write a source representation of a v isited XML
785 * node (and all of it's children) to a writer. 785 * node (and all of it's children) to a writer.
786 * @coverage dart.engine.html 786 * @coverage dart.engine.html
787 */ 787 */
788 class ToSourceVisitor implements XmlVisitor<Object> { 788 class ToSourceVisitor implements XmlVisitor<Object> {
789 789
790 /** 790 /**
791 * The writer to which the source is to be written. 791 * The writer to which the source is to be written.
792 */ 792 */
793 PrintWriter _writer; 793 PrintWriter _writer;
794 794
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 * Safely visit the given node. 846 * Safely visit the given node.
847 * @param node the node to be visited 847 * @param node the node to be visited
848 */ 848 */
849 void visit(XmlNode node) { 849 void visit(XmlNode node) {
850 if (node != null) { 850 if (node != null) {
851 node.accept(this); 851 node.accept(this);
852 } 852 }
853 } 853 }
854 } 854 }
855 /** 855 /**
856 * The enumeration {@code TokenType} defines the types of tokens that can be ret urned by the 856 * The enumeration `TokenType` defines the types of tokens that can be returned by the
857 * scanner. 857 * scanner.
858 * @coverage dart.engine.html 858 * @coverage dart.engine.html
859 */ 859 */
860 class TokenType implements Comparable<TokenType> { 860 class TokenType implements Comparable<TokenType> {
861 861
862 /** 862 /**
863 * The type of the token that marks the end of the input. 863 * The type of the token that marks the end of the input.
864 */ 864 */
865 static final TokenType EOF = new TokenType_EOF('EOF', 0, ""); 865 static final TokenType EOF = new TokenType_EOF('EOF', 0, "");
866 static final TokenType EQ = new TokenType('EQ', 1, "="); 866 static final TokenType EQ = new TokenType('EQ', 1, "=");
867 static final TokenType GT = new TokenType('GT', 2, ">"); 867 static final TokenType GT = new TokenType('GT', 2, ">");
868 static final TokenType LT_SLASH = new TokenType('LT_SLASH', 3, "</"); 868 static final TokenType LT_SLASH = new TokenType('LT_SLASH', 3, "</");
869 static final TokenType LT = new TokenType('LT', 4, "<"); 869 static final TokenType LT = new TokenType('LT', 4, "<");
870 static final TokenType SLASH_GT = new TokenType('SLASH_GT', 5, "/>"); 870 static final TokenType SLASH_GT = new TokenType('SLASH_GT', 5, "/>");
871 static final TokenType COMMENT = new TokenType('COMMENT', 6, null); 871 static final TokenType COMMENT = new TokenType('COMMENT', 6, null);
872 static final TokenType DECLARATION = new TokenType('DECLARATION', 7, null); 872 static final TokenType DECLARATION = new TokenType('DECLARATION', 7, null);
873 static final TokenType DIRECTIVE = new TokenType('DIRECTIVE', 8, null); 873 static final TokenType DIRECTIVE = new TokenType('DIRECTIVE', 8, null);
874 static final TokenType STRING = new TokenType('STRING', 9, null); 874 static final TokenType STRING = new TokenType('STRING', 9, null);
875 static final TokenType TAG = new TokenType('TAG', 10, null); 875 static final TokenType TAG = new TokenType('TAG', 10, null);
876 static final TokenType TEXT = new TokenType('TEXT', 11, null); 876 static final TokenType TEXT = new TokenType('TEXT', 11, null);
877 static final List<TokenType> values = [EOF, EQ, GT, LT_SLASH, LT, SLASH_GT, CO MMENT, DECLARATION, DIRECTIVE, STRING, TAG, TEXT]; 877 static final List<TokenType> values = [EOF, EQ, GT, LT_SLASH, LT, SLASH_GT, CO MMENT, DECLARATION, DIRECTIVE, STRING, TAG, TEXT];
878 878
879 /// The name of this enum constant, as declared in the enum declaration. 879 /// The name of this enum constant, as declared in the enum declaration.
880 final String name; 880 final String name;
881 881
882 /// The position in the enum declaration. 882 /// The position in the enum declaration.
883 final int ordinal; 883 final int ordinal;
884 884
885 /** 885 /**
886 * The lexeme that defines this type of token, or {@code null} if there is mor e than one possible 886 * The lexeme that defines this type of token, or `null` if there is more than one possible
887 * lexeme for this type of token. 887 * lexeme for this type of token.
888 */ 888 */
889 String _lexeme; 889 String _lexeme;
890 TokenType(this.name, this.ordinal, String lexeme) { 890 TokenType(this.name, this.ordinal, String lexeme) {
891 this._lexeme = lexeme; 891 this._lexeme = lexeme;
892 } 892 }
893 893
894 /** 894 /**
895 * Return the lexeme that defines this type of token, or {@code null} if there is more than one 895 * Return the lexeme that defines this type of token, or `null` if there is mo re than one
896 * possible lexeme for this type of token. 896 * possible lexeme for this type of token.
897 * @return the lexeme that defines this type of token 897 * @return the lexeme that defines this type of token
898 */ 898 */
899 String get lexeme => _lexeme; 899 String get lexeme => _lexeme;
900 int compareTo(TokenType other) => ordinal - other.ordinal; 900 int compareTo(TokenType other) => ordinal - other.ordinal;
901 int get hashCode => ordinal; 901 int get hashCode => ordinal;
902 String toString() => name; 902 String toString() => name;
903 } 903 }
904 class TokenType_EOF extends TokenType { 904 class TokenType_EOF extends TokenType {
905 TokenType_EOF(String name, int ordinal, String arg0) : super(name, ordinal, ar g0); 905 TokenType_EOF(String name, int ordinal, String arg0) : super(name, ordinal, ar g0);
906 String toString() => "-eof-"; 906 String toString() => "-eof-";
907 } 907 }
908 /** 908 /**
909 * Instances of {@code XmlAttributeNode} represent name/value pairs owned by an {@link XmlTagNode}. 909 * Instances of `XmlAttributeNode` represent name/value pairs owned by an [XmlTa gNode].
910 * @coverage dart.engine.html 910 * @coverage dart.engine.html
911 */ 911 */
912 class XmlAttributeNode extends XmlNode { 912 class XmlAttributeNode extends XmlNode {
913 Token _name; 913 Token _name;
914 Token _equals; 914 Token _equals;
915 Token _value; 915 Token _value;
916 916
917 /** 917 /**
918 * Construct a new instance representing an XML attribute. 918 * Construct a new instance representing an XML attribute.
919 * @param name the name token (not {@code null}). This may be a zero length to ken if the attribute 919 * @param name the name token (not `null`). This may be a zero length token if the attribute
920 * is badly formed. 920 * is badly formed.
921 * @param equals the equals sign or {@code null} if none 921 * @param equals the equals sign or `null` if none
922 * @param value the value token (not {@code null}) 922 * @param value the value token (not `null`)
923 */ 923 */
924 XmlAttributeNode(Token name, Token equals, Token value) { 924 XmlAttributeNode(Token name, Token equals, Token value) {
925 this._name = name; 925 this._name = name;
926 this._equals = equals; 926 this._equals = equals;
927 this._value = value; 927 this._value = value;
928 } 928 }
929 accept(XmlVisitor visitor) => visitor.visitXmlAttributeNode(this); 929 accept(XmlVisitor visitor) => visitor.visitXmlAttributeNode(this);
930 Token get beginToken => _name; 930 Token get beginToken => _name;
931 Token get endToken => _value; 931 Token get endToken => _value;
932 932
933 /** 933 /**
934 * Answer the equals sign token that appears between the name and value tokens . This may be{@code null} if the attribute is badly formed. 934 * Answer the equals sign token that appears between the name and value tokens . This may be`null` if the attribute is badly formed.
935 * @return the token or {@code null} if there is no equals sign between the na me and value 935 * @return the token or `null` if there is no equals sign between the name and value
936 */ 936 */
937 Token get equals => _equals; 937 Token get equals => _equals;
938 938
939 /** 939 /**
940 * Answer the attribute name. This may be a zero length token if the attribute is badly formed. 940 * Answer the attribute name. This may be a zero length token if the attribute is badly formed.
941 * @return the name (not {@code null}) 941 * @return the name (not `null`)
942 */ 942 */
943 Token get name => _name; 943 Token get name => _name;
944 944
945 /** 945 /**
946 * Answer the lexeme for the value token without the leading and trailing quot es. 946 * Answer the lexeme for the value token without the leading and trailing quot es.
947 * @return the text or {@code null} if the value is not specified 947 * @return the text or `null` if the value is not specified
948 */ 948 */
949 String get text { 949 String get text {
950 if (_value == null) { 950 if (_value == null) {
951 return null; 951 return null;
952 } 952 }
953 String text = _value.lexeme; 953 String text = _value.lexeme;
954 int len = text.length; 954 int len = text.length;
955 if (len > 0) { 955 if (len > 0) {
956 if (text.codeUnitAt(0) == 0x22) { 956 if (text.codeUnitAt(0) == 0x22) {
957 if (len > 1 && text.codeUnitAt(len - 1) == 0x22) { 957 if (len > 1 && text.codeUnitAt(len - 1) == 0x22) {
958 return text.substring(1, len - 1); 958 return text.substring(1, len - 1);
959 } else { 959 } else {
960 return text.substring(1); 960 return text.substring(1);
961 } 961 }
962 } else if (text.codeUnitAt(0) == 0x27) { 962 } else if (text.codeUnitAt(0) == 0x27) {
963 if (len > 1 && text.codeUnitAt(len - 1) == 0x27) { 963 if (len > 1 && text.codeUnitAt(len - 1) == 0x27) {
964 return text.substring(1, len - 1); 964 return text.substring(1, len - 1);
965 } else { 965 } else {
966 return text.substring(1); 966 return text.substring(1);
967 } 967 }
968 } 968 }
969 } 969 }
970 return text; 970 return text;
971 } 971 }
972 972
973 /** 973 /**
974 * Answer the attribute value. A properly formed value will start and end with matching quote 974 * Answer the attribute value. A properly formed value will start and end with matching quote
975 * characters, but the value returned may not be properly formed. 975 * characters, but the value returned may not be properly formed.
976 * @return the value or {@code null} if this represents a badly formed attribu te 976 * @return the value or `null` if this represents a badly formed attribute
977 */ 977 */
978 Token get value => _value; 978 Token get value => _value;
979 void visitChildren(XmlVisitor<Object> visitor) { 979 void visitChildren(XmlVisitor<Object> visitor) {
980 } 980 }
981 } 981 }
982 /** 982 /**
983 * The interface {@code XmlVisitor} defines the behavior of objects that can be used to visit an{@link XmlNode} structure. 983 * The interface `XmlVisitor` defines the behavior of objects that can be used t o visit an[XmlNode] structure.
984 * @coverage dart.engine.html 984 * @coverage dart.engine.html
985 */ 985 */
986 abstract class XmlVisitor<R> { 986 abstract class XmlVisitor<R> {
987 R visitHtmlUnit(HtmlUnit htmlUnit); 987 R visitHtmlUnit(HtmlUnit htmlUnit);
988 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode); 988 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode);
989 R visitXmlTagNode(XmlTagNode xmlTagNode); 989 R visitXmlTagNode(XmlTagNode xmlTagNode);
990 } 990 }
991 /** 991 /**
992 * Instances of {@code HtmlScanner} receive and scan HTML content from a {@link Source}.<br/> 992 * Instances of `HtmlScanner` receive and scan HTML content from a [Source].<br/ >
993 * For example, the following code scans HTML source and returns the result: 993 * For example, the following code scans HTML source and returns the result:
994 * <pre> 994 * <pre>
995 * HtmlScanner scanner = new HtmlScanner(source); 995 * HtmlScanner scanner = new HtmlScanner(source);
996 * source.getContents(scanner); 996 * source.getContents(scanner);
997 * return scanner.getResult(); 997 * return scanner.getResult();
998 * </pre> 998 * </pre>
999 * @coverage dart.engine.html 999 * @coverage dart.engine.html
1000 */ 1000 */
1001 class HtmlScanner implements Source_ContentReceiver { 1001 class HtmlScanner implements Source_ContentReceiver {
1002 List<String> _SCRIPT_TAG = <String> ["script"]; 1002 List<String> _SCRIPT_TAG = <String> ["script"];
1003 1003
1004 /** 1004 /**
1005 * The source being scanned (not {@code null}) 1005 * The source being scanned (not `null`)
1006 */ 1006 */
1007 Source _source; 1007 Source _source;
1008 1008
1009 /** 1009 /**
1010 * The time at which the contents of the source were last set. 1010 * The time at which the contents of the source were last set.
1011 */ 1011 */
1012 int _modificationTime = 0; 1012 int _modificationTime = 0;
1013 1013
1014 /** 1014 /**
1015 * The scanner used to scan the source 1015 * The scanner used to scan the source
1016 */ 1016 */
1017 AbstractScanner _scanner; 1017 AbstractScanner _scanner;
1018 1018
1019 /** 1019 /**
1020 * The first token in the token stream. 1020 * The first token in the token stream.
1021 */ 1021 */
1022 Token _token; 1022 Token _token;
1023 1023
1024 /** 1024 /**
1025 * Construct a new instance to scan the specified source. 1025 * Construct a new instance to scan the specified source.
1026 * @param source the source to be scanned (not {@code null}) 1026 * @param source the source to be scanned (not `null`)
1027 */ 1027 */
1028 HtmlScanner(Source source) { 1028 HtmlScanner(Source source) {
1029 this._source = source; 1029 this._source = source;
1030 } 1030 }
1031 void accept(CharBuffer contents, int modificationTime2) { 1031 void accept(CharBuffer contents, int modificationTime2) {
1032 this._modificationTime = modificationTime2; 1032 this._modificationTime = modificationTime2;
1033 _scanner = new CharBufferScanner(_source, contents); 1033 _scanner = new CharBufferScanner(_source, contents);
1034 _scanner.passThroughElements = _SCRIPT_TAG; 1034 _scanner.passThroughElements = _SCRIPT_TAG;
1035 _token = _scanner.tokenize(); 1035 _token = _scanner.tokenize();
1036 } 1036 }
1037 void accept2(String contents, int modificationTime2) { 1037 void accept2(String contents, int modificationTime2) {
1038 this._modificationTime = modificationTime2; 1038 this._modificationTime = modificationTime2;
1039 _scanner = new StringScanner(_source, contents); 1039 _scanner = new StringScanner(_source, contents);
1040 _scanner.passThroughElements = _SCRIPT_TAG; 1040 _scanner.passThroughElements = _SCRIPT_TAG;
1041 _token = _scanner.tokenize(); 1041 _token = _scanner.tokenize();
1042 } 1042 }
1043 1043
1044 /** 1044 /**
1045 * Answer the result of scanning the source 1045 * Answer the result of scanning the source
1046 * @return the result (not {@code null}) 1046 * @return the result (not `null`)
1047 */ 1047 */
1048 HtmlScanResult get result => new HtmlScanResult(_modificationTime, _token, _sc anner.lineStarts); 1048 HtmlScanResult get result => new HtmlScanResult(_modificationTime, _token, _sc anner.lineStarts);
1049 } 1049 }
1050 /** 1050 /**
1051 * Instances of the class {@code XmlParser} are used to parse tokens into a AST structure comprised 1051 * Instances of the class `XmlParser` are used to parse tokens into a AST struct ure comprised
1052 * of {@link XmlNode}s. 1052 * of [XmlNode]s.
1053 * @coverage dart.engine.html 1053 * @coverage dart.engine.html
1054 */ 1054 */
1055 class XmlParser { 1055 class XmlParser {
1056 1056
1057 /** 1057 /**
1058 * The source being parsed. 1058 * The source being parsed.
1059 */ 1059 */
1060 Source _source; 1060 Source _source;
1061 1061
1062 /** 1062 /**
1063 * The next token to be parsed. 1063 * The next token to be parsed.
1064 */ 1064 */
1065 Token _currentToken; 1065 Token _currentToken;
1066 1066
1067 /** 1067 /**
1068 * Construct a parser for the specified source. 1068 * Construct a parser for the specified source.
1069 * @param source the source being parsed 1069 * @param source the source being parsed
1070 */ 1070 */
1071 XmlParser(Source source) { 1071 XmlParser(Source source) {
1072 this._source = source; 1072 this._source = source;
1073 } 1073 }
1074 1074
1075 /** 1075 /**
1076 * Answer the source being parsed. 1076 * Answer the source being parsed.
1077 * @return the source 1077 * @return the source
1078 */ 1078 */
1079 Source get source => _source; 1079 Source get source => _source;
1080 1080
1081 /** 1081 /**
1082 * Answer {@code true} if the specified tag is self closing and thus should ne ver have content or 1082 * Answer `true` if the specified tag is self closing and thus should never ha ve content or
1083 * child tag nodes. 1083 * child tag nodes.
1084 * @param tag the tag (not {@code null}) 1084 * @param tag the tag (not `null`)
1085 * @return {@code true} if self closing 1085 * @return `true` if self closing
1086 */ 1086 */
1087 bool isSelfClosing(Token tag) => false; 1087 bool isSelfClosing(Token tag) => false;
1088 1088
1089 /** 1089 /**
1090 * Parse the entire token stream and in the process, advance the current token to the end of the 1090 * Parse the entire token stream and in the process, advance the current token to the end of the
1091 * token stream. 1091 * token stream.
1092 * @return the list of tag nodes found (not {@code null}, contains no {@code n ull}) 1092 * @return the list of tag nodes found (not `null`, contains no `null`)
1093 */ 1093 */
1094 List<XmlTagNode> parseTopTagNodes(Token firstToken) { 1094 List<XmlTagNode> parseTopTagNodes(Token firstToken) {
1095 _currentToken = firstToken; 1095 _currentToken = firstToken;
1096 List<XmlTagNode> tagNodes = new List<XmlTagNode>(); 1096 List<XmlTagNode> tagNodes = new List<XmlTagNode>();
1097 while (true) { 1097 while (true) {
1098 while (true) { 1098 while (true) {
1099 if (_currentToken.type == TokenType.LT) { 1099 if (_currentToken.type == TokenType.LT) {
1100 tagNodes.add(parseTagNode()); 1100 tagNodes.add(parseTagNode());
1101 } else if (_currentToken.type == TokenType.DECLARATION || _currentToken. type == TokenType.DIRECTIVE || _currentToken.type == TokenType.COMMENT) { 1101 } else if (_currentToken.type == TokenType.DECLARATION || _currentToken. type == TokenType.DIRECTIVE || _currentToken.type == TokenType.COMMENT) {
1102 _currentToken = _currentToken.next; 1102 _currentToken = _currentToken.next;
1103 } else if (_currentToken.type == TokenType.EOF) { 1103 } else if (_currentToken.type == TokenType.EOF) {
1104 return tagNodes; 1104 return tagNodes;
1105 } else { 1105 } else {
1106 reportUnexpectedToken(); 1106 reportUnexpectedToken();
1107 _currentToken = _currentToken.next; 1107 _currentToken = _currentToken.next;
1108 } 1108 }
1109 break; 1109 break;
1110 } 1110 }
1111 } 1111 }
1112 } 1112 }
1113 1113
1114 /** 1114 /**
1115 * Answer the current token. 1115 * Answer the current token.
1116 * @return the current token 1116 * @return the current token
1117 */ 1117 */
1118 Token get currentToken => _currentToken; 1118 Token get currentToken => _currentToken;
1119 1119
1120 /** 1120 /**
1121 * Insert a synthetic token of the specified type before the current token 1121 * Insert a synthetic token of the specified type before the current token
1122 * @param type the type of token to be inserted (not {@code null}) 1122 * @param type the type of token to be inserted (not `null`)
1123 * @return the synthetic token that was inserted (not {@code null}) 1123 * @return the synthetic token that was inserted (not `null`)
1124 */ 1124 */
1125 Token insertSyntheticToken(TokenType type) { 1125 Token insertSyntheticToken(TokenType type) {
1126 Token token = new Token.con2(type, _currentToken.offset, ""); 1126 Token token = new Token.con2(type, _currentToken.offset, "");
1127 _currentToken.previous.setNext(token); 1127 _currentToken.previous.setNext(token);
1128 token.setNext(_currentToken); 1128 token.setNext(_currentToken);
1129 return token; 1129 return token;
1130 } 1130 }
1131 1131
1132 /** 1132 /**
1133 * Parse the token stream for an attribute. This method advances the current t oken over the 1133 * Parse the token stream for an attribute. This method advances the current t oken over the
1134 * attribute, but should not be called if the {@link #currentToken} is not {@l ink TokenType#TAG}. 1134 * attribute, but should not be called if the [currentToken] is not [TokenType #TAG].
1135 * @return the attribute (not {@code null}) 1135 * @return the attribute (not `null`)
1136 */ 1136 */
1137 XmlAttributeNode parseAttribute() { 1137 XmlAttributeNode parseAttribute() {
1138 Token name = _currentToken; 1138 Token name = _currentToken;
1139 _currentToken = _currentToken.next; 1139 _currentToken = _currentToken.next;
1140 Token equals; 1140 Token equals;
1141 if (identical(_currentToken.type, TokenType.EQ)) { 1141 if (identical(_currentToken.type, TokenType.EQ)) {
1142 equals = _currentToken; 1142 equals = _currentToken;
1143 _currentToken = _currentToken.next; 1143 _currentToken = _currentToken.next;
1144 } else { 1144 } else {
1145 reportUnexpectedToken(); 1145 reportUnexpectedToken();
1146 equals = insertSyntheticToken(TokenType.EQ); 1146 equals = insertSyntheticToken(TokenType.EQ);
1147 } 1147 }
1148 Token value; 1148 Token value;
1149 if (identical(_currentToken.type, TokenType.STRING)) { 1149 if (identical(_currentToken.type, TokenType.STRING)) {
1150 value = _currentToken; 1150 value = _currentToken;
1151 _currentToken = _currentToken.next; 1151 _currentToken = _currentToken.next;
1152 } else { 1152 } else {
1153 reportUnexpectedToken(); 1153 reportUnexpectedToken();
1154 value = insertSyntheticToken(TokenType.STRING); 1154 value = insertSyntheticToken(TokenType.STRING);
1155 } 1155 }
1156 return new XmlAttributeNode(name, equals, value); 1156 return new XmlAttributeNode(name, equals, value);
1157 } 1157 }
1158 1158
1159 /** 1159 /**
1160 * Parse the stream for a sequence of attributes. This method advances the cur rent token to the 1160 * Parse the stream for a sequence of attributes. This method advances the cur rent token to the
1161 * next {@link TokenType#GT}, {@link TokenType#SLASH_GT}, or {@link TokenType# EOF}. 1161 * next [TokenType#GT], [TokenType#SLASH_GT], or [TokenType#EOF].
1162 * @return a collection of zero or more attributes (not {@code null}, contains no {@code null}s) 1162 * @return a collection of zero or more attributes (not `null`, contains no `n ull`s)
1163 */ 1163 */
1164 List<XmlAttributeNode> parseAttributes() { 1164 List<XmlAttributeNode> parseAttributes() {
1165 TokenType type = _currentToken.type; 1165 TokenType type = _currentToken.type;
1166 if (identical(type, TokenType.GT) || identical(type, TokenType.SLASH_GT) || identical(type, TokenType.EOF)) { 1166 if (identical(type, TokenType.GT) || identical(type, TokenType.SLASH_GT) || identical(type, TokenType.EOF)) {
1167 return XmlTagNode.NO_ATTRIBUTES; 1167 return XmlTagNode.NO_ATTRIBUTES;
1168 } 1168 }
1169 List<XmlAttributeNode> attributes = new List<XmlAttributeNode>(); 1169 List<XmlAttributeNode> attributes = new List<XmlAttributeNode>();
1170 while (true) { 1170 while (true) {
1171 while (true) { 1171 while (true) {
1172 if (_currentToken.type == TokenType.GT || _currentToken.type == TokenTyp e.SLASH_GT || _currentToken.type == TokenType.EOF) { 1172 if (_currentToken.type == TokenType.GT || _currentToken.type == TokenTyp e.SLASH_GT || _currentToken.type == TokenType.EOF) {
1173 return attributes; 1173 return attributes;
1174 } else if (_currentToken.type == TokenType.TAG) { 1174 } else if (_currentToken.type == TokenType.TAG) {
1175 attributes.add(parseAttribute()); 1175 attributes.add(parseAttribute());
1176 } else { 1176 } else {
1177 reportUnexpectedToken(); 1177 reportUnexpectedToken();
1178 _currentToken = _currentToken.next; 1178 _currentToken = _currentToken.next;
1179 } 1179 }
1180 break; 1180 break;
1181 } 1181 }
1182 } 1182 }
1183 } 1183 }
1184 1184
1185 /** 1185 /**
1186 * Parse the stream for a sequence of tag nodes existing within a parent tag n ode. This method 1186 * Parse the stream for a sequence of tag nodes existing within a parent tag n ode. This method
1187 * advances the current token to the next {@link TokenType#LT_SLASH} or {@link TokenType#EOF}. 1187 * advances the current token to the next [TokenType#LT_SLASH] or [TokenType#E OF].
1188 * @return a list of nodes (not {@code null}, contains no {@code null}s) 1188 * @return a list of nodes (not `null`, contains no `null`s)
1189 */ 1189 */
1190 List<XmlTagNode> parseChildTagNodes() { 1190 List<XmlTagNode> parseChildTagNodes() {
1191 TokenType type = _currentToken.type; 1191 TokenType type = _currentToken.type;
1192 if (identical(type, TokenType.LT_SLASH) || identical(type, TokenType.EOF)) { 1192 if (identical(type, TokenType.LT_SLASH) || identical(type, TokenType.EOF)) {
1193 return XmlTagNode.NO_TAG_NODES; 1193 return XmlTagNode.NO_TAG_NODES;
1194 } 1194 }
1195 List<XmlTagNode> nodes = new List<XmlTagNode>(); 1195 List<XmlTagNode> nodes = new List<XmlTagNode>();
1196 while (true) { 1196 while (true) {
1197 while (true) { 1197 while (true) {
1198 if (_currentToken.type == TokenType.LT) { 1198 if (_currentToken.type == TokenType.LT) {
1199 nodes.add(parseTagNode()); 1199 nodes.add(parseTagNode());
1200 } else if (_currentToken.type == TokenType.LT_SLASH || _currentToken.typ e == TokenType.EOF) { 1200 } else if (_currentToken.type == TokenType.LT_SLASH || _currentToken.typ e == TokenType.EOF) {
1201 return nodes; 1201 return nodes;
1202 } else if (_currentToken.type == TokenType.COMMENT) { 1202 } else if (_currentToken.type == TokenType.COMMENT) {
1203 _currentToken = _currentToken.next; 1203 _currentToken = _currentToken.next;
1204 } else { 1204 } else {
1205 reportUnexpectedToken(); 1205 reportUnexpectedToken();
1206 _currentToken = _currentToken.next; 1206 _currentToken = _currentToken.next;
1207 } 1207 }
1208 break; 1208 break;
1209 } 1209 }
1210 } 1210 }
1211 } 1211 }
1212 1212
1213 /** 1213 /**
1214 * Parse the token stream for the next tag node. This method advances current token over the 1214 * Parse the token stream for the next tag node. This method advances current token over the
1215 * parsed tag node, but should only be called if the current token is {@link T okenType#LT} 1215 * parsed tag node, but should only be called if the current token is [TokenTy pe#LT]
1216 * @return the tag node or {@code null} if none found 1216 * @return the tag node or `null` if none found
1217 */ 1217 */
1218 XmlTagNode parseTagNode() { 1218 XmlTagNode parseTagNode() {
1219 Token nodeStart = _currentToken; 1219 Token nodeStart = _currentToken;
1220 _currentToken = _currentToken.next; 1220 _currentToken = _currentToken.next;
1221 Token tag; 1221 Token tag;
1222 if (identical(_currentToken.type, TokenType.TAG)) { 1222 if (identical(_currentToken.type, TokenType.TAG)) {
1223 tag = _currentToken; 1223 tag = _currentToken;
1224 _currentToken = _currentToken.next; 1224 _currentToken = _currentToken.next;
1225 } else { 1225 } else {
1226 reportUnexpectedToken(); 1226 reportUnexpectedToken();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 return new XmlTagNode(nodeStart, tag, attributes, attributeEnd, tagNodes, co ntentEnd, closingTag, nodeEnd); 1266 return new XmlTagNode(nodeStart, tag, attributes, attributeEnd, tagNodes, co ntentEnd, closingTag, nodeEnd);
1267 } 1267 }
1268 1268
1269 /** 1269 /**
1270 * Report the current token as unexpected 1270 * Report the current token as unexpected
1271 */ 1271 */
1272 void reportUnexpectedToken() { 1272 void reportUnexpectedToken() {
1273 } 1273 }
1274 } 1274 }
1275 /** 1275 /**
1276 * Instances of {@code XmlTagNode} represent XML or HTML elements such as {@code <p>} and{@code <body foo="bar"> ... </body>}. 1276 * Instances of `XmlTagNode` represent XML or HTML elements such as `` and`<body foo="bar"> ... </body>`.
1277 * @coverage dart.engine.html 1277 * @coverage dart.engine.html
1278 */ 1278 */
1279 class XmlTagNode extends XmlNode { 1279 class XmlTagNode extends XmlNode {
1280 1280
1281 /** 1281 /**
1282 * Constant representing empty list of attributes. 1282 * Constant representing empty list of attributes.
1283 */ 1283 */
1284 static List<XmlAttributeNode> NO_ATTRIBUTES = new UnmodifiableListView(new Lis t<XmlAttributeNode>()); 1284 static List<XmlAttributeNode> NO_ATTRIBUTES = new UnmodifiableListView(new Lis t<XmlAttributeNode>());
1285 1285
1286 /** 1286 /**
1287 * Constant representing empty list of tag nodes. 1287 * Constant representing empty list of tag nodes.
1288 */ 1288 */
1289 static List<XmlTagNode> NO_TAG_NODES = new UnmodifiableListView(new List<XmlTa gNode>()); 1289 static List<XmlTagNode> NO_TAG_NODES = new UnmodifiableListView(new List<XmlTa gNode>());
1290 1290
1291 /** 1291 /**
1292 * The starting {@link TokenType#LT} token (not {@code null}). 1292 * The starting [TokenType#LT] token (not `null`).
1293 */ 1293 */
1294 Token _nodeStart; 1294 Token _nodeStart;
1295 1295
1296 /** 1296 /**
1297 * The {@link TokenType#TAG} token after the starting '&lt;' (not {@code null} ). 1297 * The [TokenType#TAG] token after the starting '&lt;' (not `null`).
1298 */ 1298 */
1299 Token _tag; 1299 Token _tag;
1300 1300
1301 /** 1301 /**
1302 * The attributes contained by the receiver (not {@code null}, contains no {@c ode null}s). 1302 * The attributes contained by the receiver (not `null`, contains no `null`s).
1303 */ 1303 */
1304 List<XmlAttributeNode> _attributes; 1304 List<XmlAttributeNode> _attributes;
1305 1305
1306 /** 1306 /**
1307 * The {@link TokenType#GT} or {@link TokenType#SLASH_GT} token after the attr ibutes (not{@code null}). The token may be the same token as {@link #nodeEnd} if there are no child{@link #tagNodes}. 1307 * The [TokenType#GT] or [TokenType#SLASH_GT] token after the attributes (not` null`). The token may be the same token as [nodeEnd] if there are no child[tagNo des].
1308 */ 1308 */
1309 Token _attributeEnd; 1309 Token _attributeEnd;
1310 1310
1311 /** 1311 /**
1312 * The tag nodes contained in the receiver (not {@code null}, contains no {@co de null}s). 1312 * The tag nodes contained in the receiver (not `null`, contains no `null`s).
1313 */ 1313 */
1314 List<XmlTagNode> _tagNodes; 1314 List<XmlTagNode> _tagNodes;
1315 1315
1316 /** 1316 /**
1317 * The token (not {@code null}) after the content, which may be 1317 * The token (not `null`) after the content, which may be
1318 * <ul> 1318 *
1319 * <li>(1) {@link TokenType#LT_SLASH} for nodes with open and close tags, or</ li> 1319 * * (1) [TokenType#LT_SLASH] for nodes with open and close tags, or
1320 * <li>(2) the {@link TokenType#LT} nodeStart of the next sibling node if this node is self 1320 * * (2) the [TokenType#LT] nodeStart of the next sibling node if this node is self
1321 * closing or the attributeEnd is {@link TokenType#SLASH_GT}, or</li> 1321 * closing or the attributeEnd is [TokenType#SLASH_GT], or
1322 * <li>(3) {@link TokenType#EOF} if the node does not have a closing tag and i s the last node in 1322 * * (3) [TokenType#EOF] if the node does not have a closing tag and is the la st node in
1323 * the stream {@link TokenType#LT_SLASH} token after the content, or {@code nu ll} if there is no 1323 * the stream [TokenType#LT_SLASH] token after the content, or `null` if there is no
1324 * content and the attributes ended with {@link TokenType#SLASH_GT}.</li> 1324 * content and the attributes ended with [TokenType#SLASH_GT].
1325 * </ul> 1325 *
1326 */ 1326 */
1327 Token _contentEnd; 1327 Token _contentEnd;
1328 1328
1329 /** 1329 /**
1330 * The closing {@link TokenType#TAG} after the child elements or {@code null} if there is no 1330 * The closing [TokenType#TAG] after the child elements or `null` if there is no
1331 * content and the attributes ended with {@link TokenType#SLASH_GT} 1331 * content and the attributes ended with [TokenType#SLASH_GT]
1332 */ 1332 */
1333 Token _closingTag; 1333 Token _closingTag;
1334 1334
1335 /** 1335 /**
1336 * The ending {@link TokenType#GT} or {@link TokenType#SLASH_GT} token (not {@ code null}). 1336 * The ending [TokenType#GT] or [TokenType#SLASH_GT] token (not `null`).
1337 */ 1337 */
1338 Token _nodeEnd; 1338 Token _nodeEnd;
1339 1339
1340 /** 1340 /**
1341 * Construct a new instance representing an XML or HTML element 1341 * Construct a new instance representing an XML or HTML element
1342 * @param nodeStart the starting {@link TokenType#LT} token (not {@code null}) 1342 * @param nodeStart the starting [TokenType#LT] token (not `null`)
1343 * @param tag the {@link TokenType#TAG} token after the starting '&lt;' (not { @code null}). 1343 * @param tag the [TokenType#TAG] token after the starting '&lt;' (not `null`) .
1344 * @param attributes the attributes associated with this element or {@link #NO _ATTRIBUTES} (not{@code null}, contains no {@code null}s) 1344 * @param attributes the attributes associated with this element or [NO_ATTRIB UTES] (not`null`, contains no `null`s)
1345 * @param attributeEnd The {@link TokenType#GT} or {@link TokenType#SLASH_GT} token after the 1345 * @param attributeEnd The [TokenType#GT] or [TokenType#SLASH_GT] token after the
1346 * attributes (not {@code null}). The token may be the same token as {@link #n odeEnd} if 1346 * attributes (not `null`). The token may be the same token as [nodeEnd] if
1347 * there are no child {@link #tagNodes}. 1347 * there are no child [tagNodes].
1348 * @param tagNodes child tag nodes of the receiver or {@link #NO_TAG_NODES} (n ot {@code null}, 1348 * @param tagNodes child tag nodes of the receiver or [NO_TAG_NODES] (not `nul l`,
1349 * contains no {@code null}s) 1349 * contains no `null`s)
1350 * @param contentEnd the token (not {@code null}) after the content, which may be 1350 * @param contentEnd the token (not `null`) after the content, which may be
1351 * <ul> 1351 *
1352 * <li>(1) {@link TokenType#LT_SLASH} for nodes with open and close tags, or</ li> 1352 * * (1) [TokenType#LT_SLASH] for nodes with open and close tags, or
1353 * <li>(2) the {@link TokenType#LT} nodeStart of the next sibling node if this node is 1353 * * (2) the [TokenType#LT] nodeStart of the next sibling node if this node is
1354 * self closing or the attributeEnd is {@link TokenType#SLASH_GT}, or</li> 1354 * self closing or the attributeEnd is [TokenType#SLASH_GT], or
1355 * <li>(3) {@link TokenType#EOF} if the node does not have a closing tag and i s the last 1355 * * (3) [TokenType#EOF] if the node does not have a closing tag and is the la st
1356 * node in the stream {@link TokenType#LT_SLASH} token after the content, or { @code null}if there is no content and the attributes ended with {@link TokenType #SLASH_GT}.</li> 1356 * node in the stream [TokenType#LT_SLASH] token after the content, or `null`i f there is no content and the attributes ended with [TokenType#SLASH_GT].
1357 * </ul> 1357 *
1358 * @param closingTag the closing {@link TokenType#TAG} after the child element s or {@code null} if 1358 * @param closingTag the closing [TokenType#TAG] after the child elements or ` null` if
1359 * there is no content and the attributes ended with {@link TokenType#SLASH_GT } 1359 * there is no content and the attributes ended with [TokenType#SLASH_GT]
1360 * @param nodeEnd the ending {@link TokenType#GT} or {@link TokenType#SLASH_GT } token (not{@code null}) 1360 * @param nodeEnd the ending [TokenType#GT] or [TokenType#SLASH_GT] token (not `null`)
1361 */ 1361 */
1362 XmlTagNode(Token nodeStart, Token tag, List<XmlAttributeNode> attributes, Toke n attributeEnd, List<XmlTagNode> tagNodes, Token contentEnd, Token closingTag, T oken nodeEnd) { 1362 XmlTagNode(Token nodeStart, Token tag, List<XmlAttributeNode> attributes, Toke n attributeEnd, List<XmlTagNode> tagNodes, Token contentEnd, Token closingTag, T oken nodeEnd) {
1363 this._nodeStart = nodeStart; 1363 this._nodeStart = nodeStart;
1364 this._tag = tag; 1364 this._tag = tag;
1365 this._attributes = becomeParentOfEmpty(attributes, NO_ATTRIBUTES); 1365 this._attributes = becomeParentOfEmpty(attributes, NO_ATTRIBUTES);
1366 this._attributeEnd = attributeEnd; 1366 this._attributeEnd = attributeEnd;
1367 this._tagNodes = becomeParentOfEmpty(tagNodes, NO_TAG_NODES); 1367 this._tagNodes = becomeParentOfEmpty(tagNodes, NO_TAG_NODES);
1368 this._contentEnd = contentEnd; 1368 this._contentEnd = contentEnd;
1369 this._closingTag = closingTag; 1369 this._closingTag = closingTag;
1370 this._nodeEnd = nodeEnd; 1370 this._nodeEnd = nodeEnd;
1371 } 1371 }
1372 accept(XmlVisitor visitor) => visitor.visitXmlTagNode(this); 1372 accept(XmlVisitor visitor) => visitor.visitXmlTagNode(this);
1373 1373
1374 /** 1374 /**
1375 * Answer the attribute with the specified name. 1375 * Answer the attribute with the specified name.
1376 * @param name the attribute name 1376 * @param name the attribute name
1377 * @return the attribute or {@code null} if no matching attribute is found 1377 * @return the attribute or `null` if no matching attribute is found
1378 */ 1378 */
1379 XmlAttributeNode getAttribute(String name2) { 1379 XmlAttributeNode getAttribute(String name2) {
1380 for (XmlAttributeNode attribute in _attributes) { 1380 for (XmlAttributeNode attribute in _attributes) {
1381 if (attribute.name.lexeme == name2) { 1381 if (attribute.name.lexeme == name2) {
1382 return attribute; 1382 return attribute;
1383 } 1383 }
1384 } 1384 }
1385 return null; 1385 return null;
1386 } 1386 }
1387 1387
1388 /** 1388 /**
1389 * The {@link TokenType#GT} or {@link TokenType#SLASH_GT} token after the attr ibutes (not{@code null}). The token may be the same token as {@link #nodeEnd} if there are no child{@link #tagNodes}. 1389 * The [TokenType#GT] or [TokenType#SLASH_GT] token after the attributes (not` null`). The token may be the same token as [nodeEnd] if there are no child[tagNo des].
1390 * @return the token (not {@code null}) 1390 * @return the token (not `null`)
1391 */ 1391 */
1392 Token get attributeEnd => _attributeEnd; 1392 Token get attributeEnd => _attributeEnd;
1393 1393
1394 /** 1394 /**
1395 * Answer the receiver's attributes. Callers should not manipulate the returne d list to edit the 1395 * Answer the receiver's attributes. Callers should not manipulate the returne d list to edit the
1396 * AST structure. 1396 * AST structure.
1397 * @return the attributes (not {@code null}, contains no {@code null}s) 1397 * @return the attributes (not `null`, contains no `null`s)
1398 */ 1398 */
1399 List<XmlAttributeNode> get attributes => _attributes; 1399 List<XmlAttributeNode> get attributes => _attributes;
1400 1400
1401 /** 1401 /**
1402 * Find the attribute with the given name (see {@link #getAttribute(String)} a nd answer the lexeme 1402 * Find the attribute with the given name (see [getAttribute] and answer the l exeme
1403 * for the attribute's value token without the leading and trailing quotes (se e{@link XmlAttributeNode#getText()}). 1403 * for the attribute's value token without the leading and trailing quotes (se e[XmlAttributeNode#getText]).
1404 * @param name the attribute name 1404 * @param name the attribute name
1405 * @return the attribute text or {@code null} if no matching attribute is foun d 1405 * @return the attribute text or `null` if no matching attribute is found
1406 */ 1406 */
1407 String getAttributeText(String name) { 1407 String getAttributeText(String name) {
1408 XmlAttributeNode attribute = getAttribute(name); 1408 XmlAttributeNode attribute = getAttribute(name);
1409 return attribute != null ? attribute.text : null; 1409 return attribute != null ? attribute.text : null;
1410 } 1410 }
1411 Token get beginToken => _nodeStart; 1411 Token get beginToken => _nodeStart;
1412 1412
1413 /** 1413 /**
1414 * The the closing {@link TokenType#TAG} after the child elements or {@code nu ll} if there is no 1414 * The the closing [TokenType#TAG] after the child elements or `null` if there is no
1415 * content and the attributes ended with {@link TokenType#SLASH_GT} 1415 * content and the attributes ended with [TokenType#SLASH_GT]
1416 * @return the closing tag or {@code null} 1416 * @return the closing tag or `null`
1417 */ 1417 */
1418 Token get closingTag => _closingTag; 1418 Token get closingTag => _closingTag;
1419 1419
1420 /** 1420 /**
1421 * Answer a string representing the content contained in the receiver. This in cludes the textual 1421 * Answer a string representing the content contained in the receiver. This in cludes the textual
1422 * representation of any child tag nodes ({@link #getTagNodes()}). Whitespace between '&lt;', 1422 * representation of any child tag nodes ([getTagNodes]). Whitespace between ' &lt;',
1423 * '&lt;/', and '>', '/>' is discarded, but all other whitespace is preserved. 1423 * '&lt;/', and '>', '/>' is discarded, but all other whitespace is preserved.
1424 * @return the content (not {@code null}) 1424 * @return the content (not `null`)
1425 */ 1425 */
1426 String get content { 1426 String get content {
1427 Token token = _attributeEnd.next; 1427 Token token = _attributeEnd.next;
1428 if (identical(token, _contentEnd)) { 1428 if (identical(token, _contentEnd)) {
1429 return ""; 1429 return "";
1430 } 1430 }
1431 String content = token.lexeme; 1431 String content = token.lexeme;
1432 token = token.next; 1432 token = token.next;
1433 if (identical(token, _contentEnd)) { 1433 if (identical(token, _contentEnd)) {
1434 return content; 1434 return content;
1435 } 1435 }
1436 JavaStringBuilder buffer = new JavaStringBuilder(); 1436 JavaStringBuilder buffer = new JavaStringBuilder();
1437 while (token != _contentEnd) { 1437 while (token != _contentEnd) {
1438 buffer.append(token.lexeme); 1438 buffer.append(token.lexeme);
1439 token = token.next; 1439 token = token.next;
1440 } 1440 }
1441 return buffer.toString(); 1441 return buffer.toString();
1442 } 1442 }
1443 1443
1444 /** 1444 /**
1445 * Answer the token (not {@code null}) after the content, which may be 1445 * Answer the token (not `null`) after the content, which may be
1446 * <ul> 1446 *
1447 * <li>(1) {@link TokenType#LT_SLASH} for nodes with open and close tags, or</ li> 1447 * * (1) [TokenType#LT_SLASH] for nodes with open and close tags, or
1448 * <li>(2) the {@link TokenType#LT} nodeStart of the next sibling node if this node is self 1448 * * (2) the [TokenType#LT] nodeStart of the next sibling node if this node is self
1449 * closing or the attributeEnd is {@link TokenType#SLASH_GT}, or</li> 1449 * closing or the attributeEnd is [TokenType#SLASH_GT], or
1450 * <li>(3) {@link TokenType#EOF} if the node does not have a closing tag and i s the last node in 1450 * * (3) [TokenType#EOF] if the node does not have a closing tag and is the la st node in
1451 * the stream {@link TokenType#LT_SLASH} token after the content, or {@code nu ll} if there is no 1451 * the stream [TokenType#LT_SLASH] token after the content, or `null` if there is no
1452 * content and the attributes ended with {@link TokenType#SLASH_GT}.</li> 1452 * content and the attributes ended with [TokenType#SLASH_GT].
1453 * </ul> 1453 *
1454 * @return the token (not {@code null}) 1454 * @return the token (not `null`)
1455 */ 1455 */
1456 Token get contentEnd => _contentEnd; 1456 Token get contentEnd => _contentEnd;
1457 Token get endToken { 1457 Token get endToken {
1458 if (_nodeEnd != null) { 1458 if (_nodeEnd != null) {
1459 return _nodeEnd; 1459 return _nodeEnd;
1460 } 1460 }
1461 if (_closingTag != null) { 1461 if (_closingTag != null) {
1462 return _closingTag; 1462 return _closingTag;
1463 } 1463 }
1464 if (_contentEnd != null) { 1464 if (_contentEnd != null) {
1465 return _contentEnd; 1465 return _contentEnd;
1466 } 1466 }
1467 if (!_tagNodes.isEmpty) { 1467 if (!_tagNodes.isEmpty) {
1468 return _tagNodes[_tagNodes.length - 1].endToken; 1468 return _tagNodes[_tagNodes.length - 1].endToken;
1469 } 1469 }
1470 if (_attributeEnd != null) { 1470 if (_attributeEnd != null) {
1471 return _attributeEnd; 1471 return _attributeEnd;
1472 } 1472 }
1473 if (!_attributes.isEmpty) { 1473 if (!_attributes.isEmpty) {
1474 return _attributes[_attributes.length - 1].endToken; 1474 return _attributes[_attributes.length - 1].endToken;
1475 } 1475 }
1476 return _tag; 1476 return _tag;
1477 } 1477 }
1478 1478
1479 /** 1479 /**
1480 * Answer the ending {@link TokenType#GT} or {@link TokenType#SLASH_GT} token. 1480 * Answer the ending [TokenType#GT] or [TokenType#SLASH_GT] token.
1481 * @return the token (not {@code null}) 1481 * @return the token (not `null`)
1482 */ 1482 */
1483 Token get nodeEnd => _nodeEnd; 1483 Token get nodeEnd => _nodeEnd;
1484 1484
1485 /** 1485 /**
1486 * Answer the starting {@link TokenType#LT} token. 1486 * Answer the starting [TokenType#LT] token.
1487 * @return the token (not {@code null}) 1487 * @return the token (not `null`)
1488 */ 1488 */
1489 Token get nodeStart => _nodeStart; 1489 Token get nodeStart => _nodeStart;
1490 1490
1491 /** 1491 /**
1492 * Answer the {@link TokenType#TAG} token after the starting '&lt;'. 1492 * Answer the [TokenType#TAG] token after the starting '&lt;'.
1493 * @return the token (not {@code null}) 1493 * @return the token (not `null`)
1494 */ 1494 */
1495 Token get tag => _tag; 1495 Token get tag => _tag;
1496 1496
1497 /** 1497 /**
1498 * Answer the tag nodes contained in the receiver. Callers should not manipula te the returned list 1498 * Answer the tag nodes contained in the receiver. Callers should not manipula te the returned list
1499 * to edit the AST structure. 1499 * to edit the AST structure.
1500 * @return the children (not {@code null}, contains no {@code null}s) 1500 * @return the children (not `null`, contains no `null`s)
1501 */ 1501 */
1502 List<XmlTagNode> get tagNodes => _tagNodes; 1502 List<XmlTagNode> get tagNodes => _tagNodes;
1503 void visitChildren(XmlVisitor<Object> visitor) { 1503 void visitChildren(XmlVisitor<Object> visitor) {
1504 for (XmlAttributeNode node in _attributes) { 1504 for (XmlAttributeNode node in _attributes) {
1505 node.accept(visitor); 1505 node.accept(visitor);
1506 } 1506 }
1507 for (XmlTagNode node in _tagNodes) { 1507 for (XmlTagNode node in _tagNodes) {
1508 node.accept(visitor); 1508 node.accept(visitor);
1509 } 1509 }
1510 } 1510 }
1511 1511
1512 /** 1512 /**
1513 * Same as {@link #becomeParentOf(List)}, but returns given "ifEmpty" if "chil dren" is empty 1513 * Same as [becomeParentOf], but returns given "ifEmpty" if "children" is empt y
1514 */ 1514 */
1515 List becomeParentOfEmpty(List children, List ifEmpty) { 1515 List becomeParentOfEmpty(List children, List ifEmpty) {
1516 if (children != null && children.isEmpty) { 1516 if (children != null && children.isEmpty) {
1517 return ifEmpty; 1517 return ifEmpty;
1518 } 1518 }
1519 return becomeParentOf(children); 1519 return becomeParentOf(children);
1520 } 1520 }
1521 } 1521 }
1522 /** 1522 /**
1523 * Instances of the class {@code HtmlParser} are used to parse tokens into a AST structure comprised 1523 * Instances of the class `HtmlParser` are used to parse tokens into a AST struc ture comprised
1524 * of {@link XmlNode}s. 1524 * of [XmlNode]s.
1525 * @coverage dart.engine.html 1525 * @coverage dart.engine.html
1526 */ 1526 */
1527 class HtmlParser extends XmlParser { 1527 class HtmlParser extends XmlParser {
1528 static Set<String> SELF_CLOSING = new Set<String>(); 1528 static Set<String> SELF_CLOSING = new Set<String>();
1529 1529
1530 /** 1530 /**
1531 * Construct a parser for the specified source. 1531 * Construct a parser for the specified source.
1532 * @param source the source being parsed 1532 * @param source the source being parsed
1533 */ 1533 */
1534 HtmlParser(Source source) : super(source) { 1534 HtmlParser(Source source) : super(source) {
1535 } 1535 }
1536 1536
1537 /** 1537 /**
1538 * Parse the tokens specified by the given scan result. 1538 * Parse the tokens specified by the given scan result.
1539 * @param scanResult the result of scanning an HTML source (not {@code null}) 1539 * @param scanResult the result of scanning an HTML source (not `null`)
1540 * @return the parse result (not {@code null}) 1540 * @return the parse result (not `null`)
1541 */ 1541 */
1542 HtmlParseResult parse(HtmlScanResult scanResult) { 1542 HtmlParseResult parse(HtmlScanResult scanResult) {
1543 Token firstToken = scanResult.token; 1543 Token firstToken = scanResult.token;
1544 List<XmlTagNode> tagNodes = parseTopTagNodes(firstToken); 1544 List<XmlTagNode> tagNodes = parseTopTagNodes(firstToken);
1545 HtmlUnit unit = new HtmlUnit(firstToken, tagNodes, currentToken); 1545 HtmlUnit unit = new HtmlUnit(firstToken, tagNodes, currentToken);
1546 return new HtmlParseResult(scanResult.modificationTime, firstToken, scanResu lt.lineStarts, unit); 1546 return new HtmlParseResult(scanResult.modificationTime, firstToken, scanResu lt.lineStarts, unit);
1547 } 1547 }
1548 1548
1549 /** 1549 /**
1550 * Scan then parse the specified source. 1550 * Scan then parse the specified source.
1551 * @param source the source to be scanned and parsed (not {@code null}) 1551 * @param source the source to be scanned and parsed (not `null`)
1552 * @return the parse result (not {@code null}) 1552 * @return the parse result (not `null`)
1553 */ 1553 */
1554 HtmlParseResult parse2(Source source) { 1554 HtmlParseResult parse2(Source source) {
1555 HtmlScanner scanner = new HtmlScanner(source); 1555 HtmlScanner scanner = new HtmlScanner(source);
1556 source.getContents(scanner); 1556 source.getContents(scanner);
1557 return parse(scanner.result); 1557 return parse(scanner.result);
1558 } 1558 }
1559 bool isSelfClosing(Token tag) => SELF_CLOSING.contains(tag.lexeme); 1559 bool isSelfClosing(Token tag) => SELF_CLOSING.contains(tag.lexeme);
1560 } 1560 }
1561 /** 1561 /**
1562 * Instances of the class {@code HtmlUnit} represent the contents of an HTML fil e. 1562 * Instances of the class `HtmlUnit` represent the contents of an HTML file.
1563 * @coverage dart.engine.html 1563 * @coverage dart.engine.html
1564 */ 1564 */
1565 class HtmlUnit extends XmlNode { 1565 class HtmlUnit extends XmlNode {
1566 1566
1567 /** 1567 /**
1568 * The first token in the token stream that was parsed to form this HTML unit. 1568 * The first token in the token stream that was parsed to form this HTML unit.
1569 */ 1569 */
1570 Token _beginToken; 1570 Token _beginToken;
1571 1571
1572 /** 1572 /**
1573 * The last token in the token stream that was parsed to form this compilation unit. This token 1573 * The last token in the token stream that was parsed to form this compilation unit. This token
1574 * should always have a type of {@link TokenType.EOF}. 1574 * should always have a type of [TokenType.EOF].
1575 */ 1575 */
1576 Token _endToken; 1576 Token _endToken;
1577 1577
1578 /** 1578 /**
1579 * The tag nodes contained in the receiver (not {@code null}, contains no {@co de null}s). 1579 * The tag nodes contained in the receiver (not `null`, contains no `null`s).
1580 */ 1580 */
1581 List<XmlTagNode> _tagNodes; 1581 List<XmlTagNode> _tagNodes;
1582 1582
1583 /** 1583 /**
1584 * The element associated with this HTML unit or {@code null} if the receiver is not resolved. 1584 * The element associated with this HTML unit or `null` if the receiver is not resolved.
1585 */ 1585 */
1586 HtmlElementImpl _element; 1586 HtmlElementImpl _element;
1587 1587
1588 /** 1588 /**
1589 * Construct a new instance representing the content of an HTML file. 1589 * Construct a new instance representing the content of an HTML file.
1590 * @param beginToken the first token in the file (not {@code null}) 1590 * @param beginToken the first token in the file (not `null`)
1591 * @param tagNodes child tag nodes of the receiver (not {@code null}, contains no {@code null}s) 1591 * @param tagNodes child tag nodes of the receiver (not `null`, contains no `n ull`s)
1592 * @param endToken the last token in the token stream which should be of type{ @link TokenType.EOF} 1592 * @param endToken the last token in the token stream which should be of type[ TokenType.EOF]
1593 */ 1593 */
1594 HtmlUnit(Token beginToken, List<XmlTagNode> tagNodes, Token endToken) { 1594 HtmlUnit(Token beginToken, List<XmlTagNode> tagNodes, Token endToken) {
1595 this._beginToken = beginToken; 1595 this._beginToken = beginToken;
1596 this._tagNodes = becomeParentOf(tagNodes); 1596 this._tagNodes = becomeParentOf(tagNodes);
1597 this._endToken = endToken; 1597 this._endToken = endToken;
1598 } 1598 }
1599 accept(XmlVisitor visitor) => visitor.visitHtmlUnit(this); 1599 accept(XmlVisitor visitor) => visitor.visitHtmlUnit(this);
1600 Token get beginToken => _beginToken; 1600 Token get beginToken => _beginToken;
1601 1601
1602 /** 1602 /**
1603 * Return the element associated with this HTML unit. 1603 * Return the element associated with this HTML unit.
1604 * @return the element or {@code null} if the receiver is not resolved 1604 * @return the element or `null` if the receiver is not resolved
1605 */ 1605 */
1606 HtmlElementImpl get element => _element; 1606 HtmlElementImpl get element => _element;
1607 Token get endToken => _endToken; 1607 Token get endToken => _endToken;
1608 1608
1609 /** 1609 /**
1610 * Answer the tag nodes contained in the receiver. Callers should not manipula te the returned list 1610 * Answer the tag nodes contained in the receiver. Callers should not manipula te the returned list
1611 * to edit the AST structure. 1611 * to edit the AST structure.
1612 * @return the children (not {@code null}, contains no {@code null}s) 1612 * @return the children (not `null`, contains no `null`s)
1613 */ 1613 */
1614 List<XmlTagNode> get tagNodes => _tagNodes; 1614 List<XmlTagNode> get tagNodes => _tagNodes;
1615 1615
1616 /** 1616 /**
1617 * Set the element associated with this HTML unit. 1617 * Set the element associated with this HTML unit.
1618 * @param element the element 1618 * @param element the element
1619 */ 1619 */
1620 void set element(HtmlElementImpl element2) { 1620 void set element(HtmlElementImpl element2) {
1621 this._element = element2; 1621 this._element = element2;
1622 } 1622 }
1623 void visitChildren(XmlVisitor<Object> visitor) { 1623 void visitChildren(XmlVisitor<Object> visitor) {
1624 for (XmlTagNode node in _tagNodes) { 1624 for (XmlTagNode node in _tagNodes) {
1625 node.accept(visitor); 1625 node.accept(visitor);
1626 } 1626 }
1627 } 1627 }
1628 } 1628 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698