| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.html; | 8 library engine.html; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } else { | 334 } else { |
| 335 // a non-char token | 335 // a non-char token |
| 336 _emitWithOffsetAndLength(TokenType.TEXT, start, 0); | 336 _emitWithOffsetAndLength(TokenType.TEXT, start, 0); |
| 337 c = advance(); | 337 c = advance(); |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 class ExpressionVisitor_HtmlUnitUtils_getExpression extends ExpressionVisitor { | 343 class ExpressionVisitor_HtmlUnitUtils_getExpression extends ExpressionVisitor { |
| 344 int offset = 0; | 344 final int offset; |
| 345 | 345 |
| 346 List<Expression> result; | 346 Expression result; |
| 347 | 347 |
| 348 ExpressionVisitor_HtmlUnitUtils_getExpression(this.offset, this.result) : supe
r(); | 348 ExpressionVisitor_HtmlUnitUtils_getExpression(this.offset); |
| 349 | 349 |
| 350 @override | 350 @override |
| 351 void visitExpression(Expression expression) { | 351 void visitExpression(Expression expression) { |
| 352 Expression at = HtmlUnitUtils._getExpressionAt(expression, offset); | 352 Expression at = HtmlUnitUtils._getExpressionAt(expression, offset); |
| 353 if (at != null) { | 353 if (at != null) { |
| 354 result[0] = at; | 354 result = at; |
| 355 throw new HtmlUnitUtils_FoundExpressionError(); | 355 throw new HtmlUnitUtils_FoundExpressionError(); |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 } | 358 } |
| 359 | 359 |
| 360 /** | 360 /** |
| 361 * Instances of the class `HtmlParser` are used to parse tokens into a AST struc
ture comprised | 361 * Instances of the class `HtmlParser` are used to parse tokens into a AST struc
ture comprised |
| 362 * of [XmlNode]s. | 362 * of [XmlNode]s. |
| 363 */ | 363 */ |
| 364 class HtmlParser extends XmlParser { | 364 class HtmlParser extends XmlParser { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 376 | 376 |
| 377 static String _APPLICATION_DART_IN_SINGLE_QUOTES = "'application/dart'"; | 377 static String _APPLICATION_DART_IN_SINGLE_QUOTES = "'application/dart'"; |
| 378 | 378 |
| 379 static String _SCRIPT = "script"; | 379 static String _SCRIPT = "script"; |
| 380 | 380 |
| 381 static String _TYPE = "type"; | 381 static String _TYPE = "type"; |
| 382 | 382 |
| 383 /** | 383 /** |
| 384 * A set containing the names of tags that do not have a closing tag. | 384 * A set containing the names of tags that do not have a closing tag. |
| 385 */ | 385 */ |
| 386 static Set<String> SELF_CLOSING = new HashSet<String>.from(JavaArrays.asList(<
String> [ | 386 static Set<String> SELF_CLOSING = new HashSet<String>.from(<String>[ |
| 387 "area", | 387 "area", |
| 388 "base", | 388 "base", |
| 389 "basefont", | 389 "basefont", |
| 390 "br", | 390 "br", |
| 391 "col", | 391 "col", |
| 392 "frame", | 392 "frame", |
| 393 "hr", | 393 "hr", |
| 394 "img", | 394 "img", |
| 395 "input", | 395 "input", |
| 396 "link", | 396 "link", |
| 397 "meta", | 397 "meta", |
| 398 "param", | 398 "param", |
| 399 "!"])); | 399 "!"]); |
| 400 | 400 |
| 401 /** | 401 /** |
| 402 * Given the contents of an embedded expression that occurs at the given offse
t, parse it as a | 402 * Given the contents of an embedded expression that occurs at the given offse
t, parse it as a |
| 403 * Dart expression. The contents should not include the expression's delimiter
s. | 403 * Dart expression. The contents should not include the expression's delimiter
s. |
| 404 * | 404 * |
| 405 * @param source the source that contains that given token | 405 * @param source the source that contains that given token |
| 406 * @param token the token to start parsing from | 406 * @param token the token to start parsing from |
| 407 * @return the Dart expression that was parsed | 407 * @return the Dart expression that was parsed |
| 408 */ | 408 */ |
| 409 static Expression parseEmbeddedExpression(Source source, sc.Token token, Analy
sisErrorListener errorListener) { | 409 static Expression parseEmbeddedExpression(Source source, sc.Token token, Analy
sisErrorListener errorListener) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 */ | 621 */ |
| 622 class HtmlUnitUtils { | 622 class HtmlUnitUtils { |
| 623 /** | 623 /** |
| 624 * Returns the [XmlAttributeNode] that is part of the given [HtmlUnit] and enc
loses | 624 * Returns the [XmlAttributeNode] that is part of the given [HtmlUnit] and enc
loses |
| 625 * the given offset. | 625 * the given offset. |
| 626 */ | 626 */ |
| 627 static XmlAttributeNode getAttributeNode(HtmlUnit htmlUnit, int offset) { | 627 static XmlAttributeNode getAttributeNode(HtmlUnit htmlUnit, int offset) { |
| 628 if (htmlUnit == null) { | 628 if (htmlUnit == null) { |
| 629 return null; | 629 return null; |
| 630 } | 630 } |
| 631 List<XmlAttributeNode> result = [null]; | 631 RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode visitor |
| 632 = new RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode(offset); |
| 632 try { | 633 try { |
| 633 htmlUnit.accept(new RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode(off
set, result)); | 634 htmlUnit.accept(visitor); |
| 634 } on HtmlUnitUtils_FoundAttributeNodeError catch (e) { | 635 } on HtmlUnitUtils_FoundAttributeNodeError catch (e) { |
| 635 return result[0]; | 636 return visitor.result; |
| 636 } | 637 } |
| 637 return null; | 638 return null; |
| 638 } | 639 } |
| 639 | 640 |
| 640 /** | 641 /** |
| 641 * Returns the best [Element] of the given [Expression]. | 642 * Returns the best [Element] of the given [Expression]. |
| 642 */ | 643 */ |
| 643 static Element getElement(Expression expression) { | 644 static Element getElement(Expression expression) { |
| 644 if (expression == null) { | 645 if (expression == null) { |
| 645 return null; | 646 return null; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 671 } | 672 } |
| 672 | 673 |
| 673 /** | 674 /** |
| 674 * Returns the [XmlTagNode] that is part of the given [HtmlUnit] and encloses
the | 675 * Returns the [XmlTagNode] that is part of the given [HtmlUnit] and encloses
the |
| 675 * given offset. | 676 * given offset. |
| 676 */ | 677 */ |
| 677 static XmlTagNode getEnclosingTagNode(HtmlUnit htmlUnit, int offset) { | 678 static XmlTagNode getEnclosingTagNode(HtmlUnit htmlUnit, int offset) { |
| 678 if (htmlUnit == null) { | 679 if (htmlUnit == null) { |
| 679 return null; | 680 return null; |
| 680 } | 681 } |
| 681 List<XmlTagNode> result = [null]; | 682 RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode visitor |
| 683 = new RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode(offset); |
| 682 try { | 684 try { |
| 683 htmlUnit.accept(new RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode(
offset, result)); | 685 htmlUnit.accept(visitor); |
| 684 } on HtmlUnitUtils_FoundTagNodeError catch (e) { | 686 } on HtmlUnitUtils_FoundTagNodeError catch (e) { |
| 685 return result[0]; | 687 return visitor.result; |
| 686 } | 688 } |
| 687 return null; | 689 return null; |
| 688 } | 690 } |
| 689 | 691 |
| 690 /** | 692 /** |
| 691 * Returns the [Expression] that is part of the given [HtmlUnit] and encloses
the | 693 * Returns the [Expression] that is part of the given [HtmlUnit] and encloses
the |
| 692 * given offset. | 694 * given offset. |
| 693 */ | 695 */ |
| 694 static Expression getExpression(HtmlUnit htmlUnit, int offset) { | 696 static Expression getExpression(HtmlUnit htmlUnit, int offset) { |
| 695 if (htmlUnit == null) { | 697 if (htmlUnit == null) { |
| 696 return null; | 698 return null; |
| 697 } | 699 } |
| 698 List<Expression> result = [null]; | 700 ExpressionVisitor_HtmlUnitUtils_getExpression visitor |
| 701 = new ExpressionVisitor_HtmlUnitUtils_getExpression(offset); |
| 699 try { | 702 try { |
| 700 // TODO(scheglov) this code is very Angular specific | 703 // TODO(scheglov) this code is very Angular specific |
| 701 htmlUnit.accept(new ExpressionVisitor_HtmlUnitUtils_getExpression(offset,
result)); | 704 htmlUnit.accept(visitor); |
| 702 } on HtmlUnitUtils_FoundExpressionError catch (e) { | 705 } on HtmlUnitUtils_FoundExpressionError catch (e) { |
| 703 return result[0]; | 706 return visitor.result; |
| 704 } | 707 } |
| 705 return null; | 708 return null; |
| 706 } | 709 } |
| 707 | 710 |
| 708 /** | 711 /** |
| 709 * Returns the [XmlTagNode] that is part of the given [HtmlUnit] and its open
or | 712 * Returns the [XmlTagNode] that is part of the given [HtmlUnit] and its open
or |
| 710 * closing tag name encloses the given offset. | 713 * closing tag name encloses the given offset. |
| 711 */ | 714 */ |
| 712 static XmlTagNode getTagNode(HtmlUnit htmlUnit, int offset) { | 715 static XmlTagNode getTagNode(HtmlUnit htmlUnit, int offset) { |
| 713 XmlTagNode node = getEnclosingTagNode(htmlUnit, offset); | 716 XmlTagNode node = getEnclosingTagNode(htmlUnit, offset); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 } | 815 } |
| 813 | 816 |
| 814 @override | 817 @override |
| 815 R visitXmlTagNode(XmlTagNode node) { | 818 R visitXmlTagNode(XmlTagNode node) { |
| 816 node.visitChildren(this); | 819 node.visitChildren(this); |
| 817 return null; | 820 return null; |
| 818 } | 821 } |
| 819 } | 822 } |
| 820 | 823 |
| 821 class RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode extends RecursiveXmlVis
itor<Object> { | 824 class RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode extends RecursiveXmlVis
itor<Object> { |
| 822 int offset = 0; | 825 final int offset; |
| 823 | 826 |
| 824 List<XmlAttributeNode> result; | 827 XmlAttributeNode result; |
| 825 | 828 |
| 826 RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode(this.offset, this.result) :
super(); | 829 RecursiveXmlVisitor_HtmlUnitUtils_getAttributeNode(this.offset); |
| 827 | 830 |
| 828 @override | 831 @override |
| 829 Object visitXmlAttributeNode(XmlAttributeNode node) { | 832 Object visitXmlAttributeNode(XmlAttributeNode node) { |
| 830 Token nameToken = node.nameToken; | 833 Token nameToken = node.nameToken; |
| 831 if (nameToken.offset <= offset && offset <= nameToken.end) { | 834 if (nameToken.offset <= offset && offset <= nameToken.end) { |
| 832 result[0] = node; | 835 result = node; |
| 833 throw new HtmlUnitUtils_FoundAttributeNodeError(); | 836 throw new HtmlUnitUtils_FoundAttributeNodeError(); |
| 834 } | 837 } |
| 835 return super.visitXmlAttributeNode(node); | 838 return super.visitXmlAttributeNode(node); |
| 836 } | 839 } |
| 837 } | 840 } |
| 838 | 841 |
| 839 class RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode extends RecursiveXml
Visitor<Object> { | 842 class RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode extends RecursiveXml
Visitor<Object> { |
| 840 int offset = 0; | 843 final int offset; |
| 841 | 844 |
| 842 List<XmlTagNode> result; | 845 XmlTagNode result; |
| 843 | 846 |
| 844 RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode(this.offset, this.result
) : super(); | 847 RecursiveXmlVisitor_HtmlUnitUtils_getEnclosingTagNode(this.offset); |
| 845 | 848 |
| 846 @override | 849 @override |
| 847 Object visitXmlTagNode(XmlTagNode node) { | 850 Object visitXmlTagNode(XmlTagNode node) { |
| 848 if (node.offset <= offset && offset < node.end) { | 851 if (node.offset <= offset && offset < node.end) { |
| 849 result[0] = node; | 852 result = node; |
| 850 super.visitXmlTagNode(node); | 853 super.visitXmlTagNode(node); |
| 851 throw new HtmlUnitUtils_FoundTagNodeError(); | 854 throw new HtmlUnitUtils_FoundTagNodeError(); |
| 852 } | 855 } |
| 853 return null; | 856 return null; |
| 854 } | 857 } |
| 855 } | 858 } |
| 856 | 859 |
| 857 /** | 860 /** |
| 858 * Instances of the class `SimpleXmlVisitor` implement an AST visitor that will
do nothing | 861 * Instances of the class `SimpleXmlVisitor` implement an AST visitor that will
do nothing |
| 859 * when visiting an AST node. It is intended to be a superclass for classes that
use the visitor | 862 * when visiting an AST node. It is intended to be a superclass for classes that
use the visitor |
| (...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 */ | 2040 */ |
| 2038 abstract class XmlVisitor<R> { | 2041 abstract class XmlVisitor<R> { |
| 2039 R visitHtmlScriptTagNode(HtmlScriptTagNode node); | 2042 R visitHtmlScriptTagNode(HtmlScriptTagNode node); |
| 2040 | 2043 |
| 2041 R visitHtmlUnit(HtmlUnit htmlUnit); | 2044 R visitHtmlUnit(HtmlUnit htmlUnit); |
| 2042 | 2045 |
| 2043 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode); | 2046 R visitXmlAttributeNode(XmlAttributeNode xmlAttributeNode); |
| 2044 | 2047 |
| 2045 R visitXmlTagNode(XmlTagNode xmlTagNode); | 2048 R visitXmlTagNode(XmlTagNode xmlTagNode); |
| 2046 } | 2049 } |
| OLD | NEW |