OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
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. | |
7 | |
8 library engine.testing.html_factory; | |
9 | |
10 import 'package:analyzer/src/generated/html.dart'; | |
11 | |
12 /** | |
13 * Utility methods to create HTML nodes. | |
14 */ | |
15 @deprecated | |
16 class HtmlFactory { | |
17 static XmlAttributeNode attribute(String name, String value) { | |
18 Token nameToken = stringToken(name); | |
19 Token equalsToken = new Token.con1(TokenType.EQ, 0); | |
20 Token valueToken = stringToken(value); | |
21 return new XmlAttributeNode(nameToken, equalsToken, valueToken); | |
22 } | |
23 | |
24 static Token gtToken() { | |
25 return new Token.con1(TokenType.GT, 0); | |
26 } | |
27 | |
28 static Token ltsToken() { | |
29 return new Token.con1(TokenType.LT_SLASH, 0); | |
30 } | |
31 | |
32 static Token ltToken() { | |
33 return new Token.con1(TokenType.LT, 0); | |
34 } | |
35 | |
36 static HtmlScriptTagNode scriptTag( | |
37 [List<XmlAttributeNode> attributes = XmlAttributeNode.EMPTY_LIST]) { | |
38 return new HtmlScriptTagNode(ltToken(), stringToken("script"), attributes, | |
39 sgtToken(), null, null, null, null); | |
40 } | |
41 | |
42 static HtmlScriptTagNode scriptTagWithContent(String contents, | |
43 [List<XmlAttributeNode> attributes = XmlAttributeNode.EMPTY_LIST]) { | |
44 Token attributeEnd = gtToken(); | |
45 Token contentToken = stringToken(contents); | |
46 attributeEnd.setNext(contentToken); | |
47 Token contentEnd = ltsToken(); | |
48 contentToken.setNext(contentEnd); | |
49 return new HtmlScriptTagNode(ltToken(), stringToken("script"), attributes, | |
50 attributeEnd, null, contentEnd, stringToken("script"), gtToken()); | |
51 } | |
52 | |
53 static Token sgtToken() { | |
54 return new Token.con1(TokenType.SLASH_GT, 0); | |
55 } | |
56 | |
57 static Token stringToken(String value) { | |
58 return new Token.con2(TokenType.STRING, 0, value); | |
59 } | |
60 | |
61 static XmlTagNode tagNode(String name, | |
62 [List<XmlAttributeNode> attributes = XmlAttributeNode.EMPTY_LIST]) { | |
63 return new XmlTagNode(ltToken(), stringToken(name), attributes, sgtToken(), | |
64 null, null, null, null); | |
65 } | |
66 } | |
OLD | NEW |