| OLD | NEW |
| 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 | 3 |
| 4 library engine.html; | 4 library engine.html; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 8 import 'java_engine.dart'; |
| 8 import 'source.dart'; | 9 import 'source.dart'; |
| 9 import 'error.dart'; | 10 import 'error.dart'; |
| 10 import 'instrumentation.dart'; | 11 import 'instrumentation.dart'; |
| 11 import 'element.dart' show HtmlElementImpl; | 12 import 'element.dart' show HtmlElementImpl; |
| 12 | 13 |
| 13 /** | 14 /** |
| 14 * Instances of the class {@code Token} represent a token that was scanned from
the input. Each | 15 * Instances of the class {@code Token} represent a token that was scanned from
the input. Each |
| 15 * token knows which token follows it, acting as the head of a linked list of to
kens. | 16 * token knows which token follows it, acting as the head of a linked list of to
kens. |
| 16 * @coverage dart.engine.html | 17 * @coverage dart.engine.html |
| 17 */ | 18 */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 /** | 36 /** |
| 36 * The lexeme represented by this token. | 37 * The lexeme represented by this token. |
| 37 */ | 38 */ |
| 38 String _value; | 39 String _value; |
| 39 /** | 40 /** |
| 40 * Initialize a newly created token. | 41 * Initialize a newly created token. |
| 41 * @param type the token type (not {@code null}) | 42 * @param type the token type (not {@code null}) |
| 42 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 43 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 43 */ | 44 */ |
| 44 Token.con1(TokenType type, int offset) { | 45 Token.con1(TokenType type, int offset) { |
| 45 _jtd_constructor_148_impl(type, offset); | 46 _jtd_constructor_150_impl(type, offset); |
| 46 } | 47 } |
| 47 _jtd_constructor_148_impl(TokenType type, int offset) { | 48 _jtd_constructor_150_impl(TokenType type, int offset) { |
| 48 _jtd_constructor_149_impl(type, offset, type.lexeme); | 49 _jtd_constructor_151_impl(type, offset, type.lexeme); |
| 49 } | 50 } |
| 50 /** | 51 /** |
| 51 * Initialize a newly created token. | 52 * Initialize a newly created token. |
| 52 * @param type the token type (not {@code null}) | 53 * @param type the token type (not {@code null}) |
| 53 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 54 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 54 * @param value the lexeme represented by this token (not {@code null}) | 55 * @param value the lexeme represented by this token (not {@code null}) |
| 55 */ | 56 */ |
| 56 Token.con2(TokenType type4, int offset3, String value7) { | 57 Token.con2(TokenType type4, int offset3, String value7) { |
| 57 _jtd_constructor_149_impl(type4, offset3, value7); | 58 _jtd_constructor_151_impl(type4, offset3, value7); |
| 58 } | 59 } |
| 59 _jtd_constructor_149_impl(TokenType type4, int offset3, String value7) { | 60 _jtd_constructor_151_impl(TokenType type4, int offset3, String value7) { |
| 60 this._type = type4; | 61 this._type = type4; |
| 61 this._value = value7; | 62 this._value = StringUtilities.intern(value7); |
| 62 this._offset = offset3; | 63 this._offset = offset3; |
| 63 } | 64 } |
| 64 /** | 65 /** |
| 65 * Return the offset from the beginning of the file to the character after las
t character of the | 66 * Return the offset from the beginning of the file to the character after las
t character of the |
| 66 * token. | 67 * token. |
| 67 * @return the offset from the beginning of the file to the first character af
ter last character | 68 * @return the offset from the beginning of the file to the first character af
ter last character |
| 68 * of the token | 69 * of the token |
| 69 */ | 70 */ |
| 70 int get end => _offset + length; | 71 int get end => _offset + length; |
| 71 /** | 72 /** |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 128 } |
| 128 /** | 129 /** |
| 129 * Instances of {@code HtmlParseResult} hold the result of parsing an HTML file. | 130 * Instances of {@code HtmlParseResult} hold the result of parsing an HTML file. |
| 130 * @coverage dart.engine.html | 131 * @coverage dart.engine.html |
| 131 */ | 132 */ |
| 132 class HtmlParseResult extends HtmlScanResult { | 133 class HtmlParseResult extends HtmlScanResult { |
| 133 /** | 134 /** |
| 134 * The unit containing the parsed information (not {@code null}). | 135 * The unit containing the parsed information (not {@code null}). |
| 135 */ | 136 */ |
| 136 HtmlUnit _unit; | 137 HtmlUnit _unit; |
| 137 HtmlParseResult(Token token, List<int> lineStarts, HtmlUnit unit) : super(toke
n, lineStarts) { | 138 HtmlParseResult(int modificationTime, Token token, List<int> lineStarts, HtmlU
nit unit) : super(modificationTime, token, lineStarts) { |
| 138 this._unit = unit; | 139 this._unit = unit; |
| 139 } | 140 } |
| 140 /** | 141 /** |
| 141 * Answer the unit generated by parsing the source | 142 * Answer the unit generated by parsing the source |
| 142 * @return the unit (not {@code null}) | 143 * @return the unit (not {@code null}) |
| 143 */ | 144 */ |
| 144 HtmlUnit get htmlUnit => _unit; | 145 HtmlUnit get htmlUnit => _unit; |
| 145 } | 146 } |
| 146 /** | 147 /** |
| 147 * Instances of the class {@code RecursiveXmlVisitor} implement an XML visitor t
hat will recursively | 148 * Instances of the class {@code RecursiveXmlVisitor} implement an XML visitor t
hat will recursively |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 return beginToken.offset; | 226 return beginToken.offset; |
| 226 } | 227 } |
| 227 /** | 228 /** |
| 228 * Return this node's parent node, or {@code null} if this node is the root of
an AST structure. | 229 * Return this node's parent node, or {@code null} if this node is the root of
an AST structure. |
| 229 * <p> | 230 * <p> |
| 230 * Note that the relationship between an AST node and its parent node may chan
ge over the lifetime | 231 * Note that the relationship between an AST node and its parent node may chan
ge over the lifetime |
| 231 * of a node. | 232 * of a node. |
| 232 * @return the parent of this node, or {@code null} if none | 233 * @return the parent of this node, or {@code null} if none |
| 233 */ | 234 */ |
| 234 XmlNode get parent => _parent; | 235 XmlNode get parent => _parent; |
| 236 String toString() { |
| 237 PrintStringWriter writer = new PrintStringWriter(); |
| 238 accept(new ToSourceVisitor(writer)); |
| 239 return writer.toString(); |
| 240 } |
| 235 /** | 241 /** |
| 236 * Use the given visitor to visit all of the children of this node. The childr
en will be visited | 242 * Use the given visitor to visit all of the children of this node. The childr
en will be visited |
| 237 * in source order. | 243 * in source order. |
| 238 * @param visitor the visitor that will be used to visit the children of this
node | 244 * @param visitor the visitor that will be used to visit the children of this
node |
| 239 */ | 245 */ |
| 240 void visitChildren(XmlVisitor<Object> visitor); | 246 void visitChildren(XmlVisitor<Object> visitor); |
| 241 /** | 247 /** |
| 242 * Make this node the parent of the given child nodes. | 248 * Make this node the parent of the given child nodes. |
| 243 * @param children the nodes that will become the children of this node | 249 * @param children the nodes that will become the children of this node |
| 244 * @return the nodes that were made children of this node | 250 * @return the nodes that were made children of this node |
| 245 */ | 251 */ |
| 246 List<XmlNode> becomeParentOf(List<XmlNode> children) { | 252 List becomeParentOf(List children) { |
| 247 if (children != null) { | 253 if (children != null) { |
| 248 for (JavaIterator<XmlNode> iter = new JavaIterator(children); iter.hasNext
;) { | 254 for (JavaIterator iter = new JavaIterator(children); iter.hasNext;) { |
| 249 XmlNode node = iter.next(); | 255 XmlNode node = iter.next(); |
| 250 node.parent = this; | 256 node.parent = this; |
| 251 } | 257 } |
| 258 return new List.from(children); |
| 252 } | 259 } |
| 253 return children; | 260 return children; |
| 254 } | 261 } |
| 255 /** | 262 /** |
| 256 * Make this node the parent of the given child node. | 263 * Make this node the parent of the given child node. |
| 257 * @param child the node that will become a child of this node | 264 * @param child the node that will become a child of this node |
| 258 * @return the node that was made a child of this node | 265 * @return the node that was made a child of this node |
| 259 */ | 266 */ |
| 260 XmlNode becomeParentOf2(XmlNode child) { | 267 XmlNode becomeParentOf2(XmlNode child) { |
| 261 if (child != null) { | 268 if (child != null) { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 } | 548 } |
| 542 } | 549 } |
| 543 } | 550 } |
| 544 } | 551 } |
| 545 /** | 552 /** |
| 546 * Instances of {@code HtmlScanResult} hold the result of scanning an HTML file. | 553 * Instances of {@code HtmlScanResult} hold the result of scanning an HTML file. |
| 547 * @coverage dart.engine.html | 554 * @coverage dart.engine.html |
| 548 */ | 555 */ |
| 549 class HtmlScanResult { | 556 class HtmlScanResult { |
| 550 /** | 557 /** |
| 558 * The time at which the contents of the source were last set. |
| 559 */ |
| 560 int _modificationTime = 0; |
| 561 /** |
| 551 * The first token in the token stream (not {@code null}). | 562 * The first token in the token stream (not {@code null}). |
| 552 */ | 563 */ |
| 553 Token _token; | 564 Token _token; |
| 554 /** | 565 /** |
| 555 * The line start information that was produced. | 566 * The line start information that was produced. |
| 556 */ | 567 */ |
| 557 List<int> _lineStarts; | 568 List<int> _lineStarts; |
| 558 HtmlScanResult(Token token, List<int> lineStarts) { | 569 HtmlScanResult(int modificationTime, Token token, List<int> lineStarts) { |
| 570 this._modificationTime = modificationTime; |
| 559 this._token = token; | 571 this._token = token; |
| 560 this._lineStarts = lineStarts; | 572 this._lineStarts = lineStarts; |
| 561 } | 573 } |
| 562 /** | 574 /** |
| 563 * Answer the line start information that was produced. | 575 * Answer the line start information that was produced. |
| 564 * @return an array of line starts (not {@code null}) | 576 * @return an array of line starts (not {@code null}) |
| 565 */ | 577 */ |
| 566 List<int> get lineStarts => _lineStarts; | 578 List<int> get lineStarts => _lineStarts; |
| 567 /** | 579 /** |
| 580 * Return the time at which the contents of the source were last set. |
| 581 * @return the time at which the contents of the source were last set |
| 582 */ |
| 583 int get modificationTime => _modificationTime; |
| 584 /** |
| 568 * Answer the first token in the token stream. | 585 * Answer the first token in the token stream. |
| 569 * @return the token (not {@code null}) | 586 * @return the token (not {@code null}) |
| 570 */ | 587 */ |
| 571 Token get token => _token; | 588 Token get token => _token; |
| 572 } | 589 } |
| 573 /** | 590 /** |
| 574 * Instances of the class {@code StringScanner} implement a scanner that reads f
rom a string. The | 591 * Instances of the class {@code StringScanner} implement a scanner that reads f
rom a string. The |
| 575 * scanning logic is in the superclass. | 592 * scanning logic is in the superclass. |
| 576 * @coverage dart.engine.html | 593 * @coverage dart.engine.html |
| 577 */ | 594 */ |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 } | 672 } |
| 656 String getString(int start, int endDelta) => _buffer.subSequence(start, _charO
ffset + 1 + endDelta).toString(); | 673 String getString(int start, int endDelta) => _buffer.subSequence(start, _charO
ffset + 1 + endDelta).toString(); |
| 657 int peek() { | 674 int peek() { |
| 658 if (_charOffset + 1 < _bufferLength) { | 675 if (_charOffset + 1 < _bufferLength) { |
| 659 return _buffer.charAt(_charOffset + 1); | 676 return _buffer.charAt(_charOffset + 1); |
| 660 } | 677 } |
| 661 return -1; | 678 return -1; |
| 662 } | 679 } |
| 663 } | 680 } |
| 664 /** | 681 /** |
| 682 * Instances of the class {@code ToSourceVisitor} write a source representation
of a visited XML |
| 683 * node (and all of it's children) to a writer. |
| 684 * @coverage dart.engine.html |
| 685 */ |
| 686 class ToSourceVisitor implements XmlVisitor<Object> { |
| 687 /** |
| 688 * The writer to which the source is to be written. |
| 689 */ |
| 690 PrintWriter _writer; |
| 691 /** |
| 692 * Initialize a newly created visitor to write source code representing the vi
sited nodes to the |
| 693 * given writer. |
| 694 * @param writer the writer to which the source is to be written |
| 695 */ |
| 696 ToSourceVisitor(PrintWriter writer) { |
| 697 this._writer = writer; |
| 698 } |
| 699 Object visitHtmlUnit(HtmlUnit node) { |
| 700 for (XmlTagNode child in node.tagNodes) { |
| 701 visit(child); |
| 702 } |
| 703 return null; |
| 704 } |
| 705 Object visitXmlAttributeNode(XmlAttributeNode node) { |
| 706 String name11 = node.name.lexeme; |
| 707 Token value9 = node.value; |
| 708 if (name11.length == 0) { |
| 709 _writer.print("__"); |
| 710 } else { |
| 711 _writer.print(name11); |
| 712 } |
| 713 _writer.print("="); |
| 714 if (value9 == null) { |
| 715 _writer.print("__"); |
| 716 } else { |
| 717 _writer.print(value9.lexeme); |
| 718 } |
| 719 return null; |
| 720 } |
| 721 Object visitXmlTagNode(XmlTagNode node) { |
| 722 _writer.print("<"); |
| 723 String tagName = node.tag.lexeme; |
| 724 _writer.print(tagName); |
| 725 for (XmlAttributeNode attribute in node.attributes) { |
| 726 _writer.print(" "); |
| 727 visit(attribute); |
| 728 } |
| 729 _writer.print(node.attributeEnd.lexeme); |
| 730 if (node.closingTag != null) { |
| 731 for (XmlTagNode child in node.tagNodes) { |
| 732 visit(child); |
| 733 } |
| 734 _writer.print("</"); |
| 735 _writer.print(tagName); |
| 736 _writer.print(">"); |
| 737 } |
| 738 return null; |
| 739 } |
| 740 /** |
| 741 * Safely visit the given node. |
| 742 * @param node the node to be visited |
| 743 */ |
| 744 void visit(XmlNode node) { |
| 745 if (node != null) { |
| 746 node.accept(this); |
| 747 } |
| 748 } |
| 749 } |
| 750 /** |
| 665 * The enumeration {@code TokenType} defines the types of tokens that can be ret
urned by the | 751 * The enumeration {@code TokenType} defines the types of tokens that can be ret
urned by the |
| 666 * scanner. | 752 * scanner. |
| 667 * @coverage dart.engine.html | 753 * @coverage dart.engine.html |
| 668 */ | 754 */ |
| 669 class TokenType { | 755 class TokenType implements Comparable<TokenType> { |
| 670 /** | 756 /** |
| 671 * The type of the token that marks the end of the input. | 757 * The type of the token that marks the end of the input. |
| 672 */ | 758 */ |
| 673 static final TokenType EOF = new TokenType_EOF('EOF', 0, ""); | 759 static final TokenType EOF = new TokenType_EOF('EOF', 0, ""); |
| 674 static final TokenType EQ = new TokenType('EQ', 1, "="); | 760 static final TokenType EQ = new TokenType('EQ', 1, "="); |
| 675 static final TokenType GT = new TokenType('GT', 2, ">"); | 761 static final TokenType GT = new TokenType('GT', 2, ">"); |
| 676 static final TokenType LT_SLASH = new TokenType('LT_SLASH', 3, "</"); | 762 static final TokenType LT_SLASH = new TokenType('LT_SLASH', 3, "</"); |
| 677 static final TokenType LT = new TokenType('LT', 4, "<"); | 763 static final TokenType LT = new TokenType('LT', 4, "<"); |
| 678 static final TokenType SLASH_GT = new TokenType('SLASH_GT', 5, "/>"); | 764 static final TokenType SLASH_GT = new TokenType('SLASH_GT', 5, "/>"); |
| 679 static final TokenType COMMENT = new TokenType('COMMENT', 6, null); | 765 static final TokenType COMMENT = new TokenType('COMMENT', 6, null); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 693 String _lexeme; | 779 String _lexeme; |
| 694 TokenType(this.__name, this.__ordinal, String lexeme) { | 780 TokenType(this.__name, this.__ordinal, String lexeme) { |
| 695 this._lexeme = lexeme; | 781 this._lexeme = lexeme; |
| 696 } | 782 } |
| 697 /** | 783 /** |
| 698 * Return the lexeme that defines this type of token, or {@code null} if there
is more than one | 784 * Return the lexeme that defines this type of token, or {@code null} if there
is more than one |
| 699 * possible lexeme for this type of token. | 785 * possible lexeme for this type of token. |
| 700 * @return the lexeme that defines this type of token | 786 * @return the lexeme that defines this type of token |
| 701 */ | 787 */ |
| 702 String get lexeme => _lexeme; | 788 String get lexeme => _lexeme; |
| 789 int compareTo(TokenType other) => __ordinal - other.__ordinal; |
| 703 String toString() => __name; | 790 String toString() => __name; |
| 704 } | 791 } |
| 705 class TokenType_EOF extends TokenType { | 792 class TokenType_EOF extends TokenType { |
| 706 TokenType_EOF(String ___name, int ___ordinal, String arg0) : super(___name, __
_ordinal, arg0); | 793 TokenType_EOF(String ___name, int ___ordinal, String arg0) : super(___name, __
_ordinal, arg0); |
| 707 String toString() => "-eof-"; | 794 String toString() => "-eof-"; |
| 708 } | 795 } |
| 709 /** | 796 /** |
| 710 * Instances of {@code XmlAttributeNode} represent name/value pairs owned by an
{@link XmlTagNode}. | 797 * Instances of {@code XmlAttributeNode} represent name/value pairs owned by an
{@link XmlTagNode}. |
| 711 * @coverage dart.engine.html | 798 * @coverage dart.engine.html |
| 712 */ | 799 */ |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 * </pre> | 881 * </pre> |
| 795 * @coverage dart.engine.html | 882 * @coverage dart.engine.html |
| 796 */ | 883 */ |
| 797 class HtmlScanner implements Source_ContentReceiver { | 884 class HtmlScanner implements Source_ContentReceiver { |
| 798 List<String> _SCRIPT_TAG = <String> ["script"]; | 885 List<String> _SCRIPT_TAG = <String> ["script"]; |
| 799 /** | 886 /** |
| 800 * The source being scanned (not {@code null}) | 887 * The source being scanned (not {@code null}) |
| 801 */ | 888 */ |
| 802 Source _source; | 889 Source _source; |
| 803 /** | 890 /** |
| 891 * The time at which the contents of the source were last set. |
| 892 */ |
| 893 int _modificationTime = 0; |
| 894 /** |
| 804 * The scanner used to scan the source | 895 * The scanner used to scan the source |
| 805 */ | 896 */ |
| 806 AbstractScanner _scanner; | 897 AbstractScanner _scanner; |
| 807 /** | 898 /** |
| 808 * The first token in the token stream. | 899 * The first token in the token stream. |
| 809 */ | 900 */ |
| 810 Token _token; | 901 Token _token; |
| 811 /** | 902 /** |
| 812 * Construct a new instance to scan the specified source. | 903 * Construct a new instance to scan the specified source. |
| 813 * @param source the source to be scanned (not {@code null}) | 904 * @param source the source to be scanned (not {@code null}) |
| 814 */ | 905 */ |
| 815 HtmlScanner(Source source) { | 906 HtmlScanner(Source source) { |
| 816 this._source = source; | 907 this._source = source; |
| 817 } | 908 } |
| 818 accept(CharBuffer contents) { | 909 void accept(CharBuffer contents, int modificationTime2) { |
| 910 this._modificationTime = modificationTime2; |
| 819 _scanner = new CharBufferScanner(_source, contents); | 911 _scanner = new CharBufferScanner(_source, contents); |
| 820 _scanner.passThroughElements = _SCRIPT_TAG; | 912 _scanner.passThroughElements = _SCRIPT_TAG; |
| 821 _token = _scanner.tokenize(); | 913 _token = _scanner.tokenize(); |
| 822 } | 914 } |
| 823 void accept2(String contents) { | 915 void accept2(String contents, int modificationTime3) { |
| 916 this._modificationTime = modificationTime3; |
| 824 _scanner = new StringScanner(_source, contents); | 917 _scanner = new StringScanner(_source, contents); |
| 825 _scanner.passThroughElements = _SCRIPT_TAG; | 918 _scanner.passThroughElements = _SCRIPT_TAG; |
| 826 _token = _scanner.tokenize(); | 919 _token = _scanner.tokenize(); |
| 827 } | 920 } |
| 828 /** | 921 /** |
| 829 * Answer the result of scanning the source | 922 * Answer the result of scanning the source |
| 830 * @return the result (not {@code null}) | 923 * @return the result (not {@code null}) |
| 831 */ | 924 */ |
| 832 HtmlScanResult get result => new HtmlScanResult(_token, _scanner.lineStarts); | 925 HtmlScanResult get result => new HtmlScanResult(_modificationTime, _token, _sc
anner.lineStarts); |
| 833 } | 926 } |
| 834 /** | 927 /** |
| 835 * Instances of the class {@code XmlParser} are used to parse tokens into a AST
structure comprised | 928 * Instances of the class {@code XmlParser} are used to parse tokens into a AST
structure comprised |
| 836 * of {@link XmlNode}s. | 929 * of {@link XmlNode}s. |
| 837 * @coverage dart.engine.html | 930 * @coverage dart.engine.html |
| 838 */ | 931 */ |
| 839 class XmlParser { | 932 class XmlParser { |
| 840 /** | 933 /** |
| 841 * The source being parsed. | 934 * The source being parsed. |
| 842 */ | 935 */ |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 * <li>(3) {@link TokenType#EOF} if the node does not have a closing tag and i
s the last | 1208 * <li>(3) {@link TokenType#EOF} if the node does not have a closing tag and i
s the last |
| 1116 * 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> | 1209 * 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> |
| 1117 * </ul> | 1210 * </ul> |
| 1118 * @param closingTag the closing {@link TokenType#TAG} after the child element
s or {@code null} if | 1211 * @param closingTag the closing {@link TokenType#TAG} after the child element
s or {@code null} if |
| 1119 * there is no content and the attributes ended with {@link TokenType#SLASH_GT
} | 1212 * there is no content and the attributes ended with {@link TokenType#SLASH_GT
} |
| 1120 * @param nodeEnd the ending {@link TokenType#GT} or {@link TokenType#SLASH_GT
} token (not{@code null}) | 1213 * @param nodeEnd the ending {@link TokenType#GT} or {@link TokenType#SLASH_GT
} token (not{@code null}) |
| 1121 */ | 1214 */ |
| 1122 XmlTagNode(Token nodeStart, Token tag, List<XmlAttributeNode> attributes, Toke
n attributeEnd, List<XmlTagNode> tagNodes, Token contentEnd, Token closingTag, T
oken nodeEnd) { | 1215 XmlTagNode(Token nodeStart, Token tag, List<XmlAttributeNode> attributes, Toke
n attributeEnd, List<XmlTagNode> tagNodes, Token contentEnd, Token closingTag, T
oken nodeEnd) { |
| 1123 this._nodeStart = nodeStart; | 1216 this._nodeStart = nodeStart; |
| 1124 this._tag = tag; | 1217 this._tag = tag; |
| 1125 this._attributes = becomeParentOf(attributes); | 1218 this._attributes = becomeParentOfEmpty(attributes, NO_ATTRIBUTES); |
| 1126 this._attributeEnd = attributeEnd; | 1219 this._attributeEnd = attributeEnd; |
| 1127 this._tagNodes = becomeParentOf(tagNodes); | 1220 this._tagNodes = becomeParentOfEmpty(tagNodes, NO_TAG_NODES); |
| 1128 this._contentEnd = contentEnd; | 1221 this._contentEnd = contentEnd; |
| 1129 this._closingTag = closingTag; | 1222 this._closingTag = closingTag; |
| 1130 this._nodeEnd = nodeEnd; | 1223 this._nodeEnd = nodeEnd; |
| 1131 } | 1224 } |
| 1132 accept(XmlVisitor visitor) => visitor.visitXmlTagNode(this); | 1225 accept(XmlVisitor visitor) => visitor.visitXmlTagNode(this); |
| 1133 /** | 1226 /** |
| 1134 * 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}. | 1227 * 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}. |
| 1135 * @return the token (not {@code null}) | 1228 * @return the token (not {@code null}) |
| 1136 */ | 1229 */ |
| 1137 Token get attributeEnd => _attributeEnd; | 1230 Token get attributeEnd => _attributeEnd; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 */ | 1320 */ |
| 1228 List<XmlTagNode> get tagNodes => _tagNodes; | 1321 List<XmlTagNode> get tagNodes => _tagNodes; |
| 1229 void visitChildren(XmlVisitor<Object> visitor) { | 1322 void visitChildren(XmlVisitor<Object> visitor) { |
| 1230 for (XmlAttributeNode node in _attributes) { | 1323 for (XmlAttributeNode node in _attributes) { |
| 1231 node.accept(visitor); | 1324 node.accept(visitor); |
| 1232 } | 1325 } |
| 1233 for (XmlTagNode node in _tagNodes) { | 1326 for (XmlTagNode node in _tagNodes) { |
| 1234 node.accept(visitor); | 1327 node.accept(visitor); |
| 1235 } | 1328 } |
| 1236 } | 1329 } |
| 1330 /** |
| 1331 * Same as {@link #becomeParentOf(List)}, but returns given "ifEmpty" if "chil
dren" is empty |
| 1332 */ |
| 1333 List becomeParentOfEmpty(List children, List ifEmpty) { |
| 1334 if (children != null && children.isEmpty) { |
| 1335 return ifEmpty; |
| 1336 } |
| 1337 return becomeParentOf(children); |
| 1338 } |
| 1237 } | 1339 } |
| 1238 /** | 1340 /** |
| 1239 * Instances of the class {@code HtmlParser} are used to parse tokens into a AST
structure comprised | 1341 * Instances of the class {@code HtmlParser} are used to parse tokens into a AST
structure comprised |
| 1240 * of {@link XmlNode}s. | 1342 * of {@link XmlNode}s. |
| 1241 * @coverage dart.engine.html | 1343 * @coverage dart.engine.html |
| 1242 */ | 1344 */ |
| 1243 class HtmlParser extends XmlParser { | 1345 class HtmlParser extends XmlParser { |
| 1244 static Set<String> SELF_CLOSING = new Set<String>(); | 1346 static Set<String> SELF_CLOSING = new Set<String>(); |
| 1245 /** | 1347 /** |
| 1246 * Construct a parser for the specified source. | 1348 * Construct a parser for the specified source. |
| 1247 * @param source the source being parsed | 1349 * @param source the source being parsed |
| 1248 */ | 1350 */ |
| 1249 HtmlParser(Source source) : super(source) { | 1351 HtmlParser(Source source) : super(source) { |
| 1250 } | 1352 } |
| 1251 /** | 1353 /** |
| 1252 * Parse the tokens specified by the given scan result. | 1354 * Parse the tokens specified by the given scan result. |
| 1253 * @param scanResult the result of scanning an HTML source (not {@code null}) | 1355 * @param scanResult the result of scanning an HTML source (not {@code null}) |
| 1254 * @return the parse result (not {@code null}) | 1356 * @return the parse result (not {@code null}) |
| 1255 */ | 1357 */ |
| 1256 HtmlParseResult parse(HtmlScanResult scanResult) { | 1358 HtmlParseResult parse(HtmlScanResult scanResult) { |
| 1257 Token firstToken = scanResult.token; | 1359 Token firstToken = scanResult.token; |
| 1258 List<XmlTagNode> tagNodes = parseTopTagNodes(firstToken); | 1360 List<XmlTagNode> tagNodes = parseTopTagNodes(firstToken); |
| 1259 HtmlUnit unit = new HtmlUnit(firstToken, tagNodes, currentToken); | 1361 HtmlUnit unit = new HtmlUnit(firstToken, tagNodes, currentToken); |
| 1260 return new HtmlParseResult(firstToken, scanResult.lineStarts, unit); | 1362 return new HtmlParseResult(scanResult.modificationTime, firstToken, scanResu
lt.lineStarts, unit); |
| 1261 } | 1363 } |
| 1262 /** | 1364 /** |
| 1263 * Scan then parse the specified source. | 1365 * Scan then parse the specified source. |
| 1264 * @param source the source to be scanned and parsed (not {@code null}) | 1366 * @param source the source to be scanned and parsed (not {@code null}) |
| 1265 * @return the parse result (not {@code null}) | 1367 * @return the parse result (not {@code null}) |
| 1266 */ | 1368 */ |
| 1267 HtmlParseResult parse2(Source source) { | 1369 HtmlParseResult parse2(Source source) { |
| 1268 HtmlScanner scanner = new HtmlScanner(source); | 1370 HtmlScanner scanner = new HtmlScanner(source); |
| 1269 source.getContents(scanner); | 1371 source.getContents(scanner); |
| 1270 return parse(scanner.result); | 1372 return parse(scanner.result); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 */ | 1426 */ |
| 1325 void set element(HtmlElementImpl element18) { | 1427 void set element(HtmlElementImpl element18) { |
| 1326 this._element = element18; | 1428 this._element = element18; |
| 1327 } | 1429 } |
| 1328 void visitChildren(XmlVisitor<Object> visitor) { | 1430 void visitChildren(XmlVisitor<Object> visitor) { |
| 1329 for (XmlTagNode node in _tagNodes) { | 1431 for (XmlTagNode node in _tagNodes) { |
| 1330 node.accept(visitor); | 1432 node.accept(visitor); |
| 1331 } | 1433 } |
| 1332 } | 1434 } |
| 1333 } | 1435 } |
| OLD | NEW |