OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2013, the Dart project authors. |
| 3 * |
| 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
| 5 * in compliance with the License. You may obtain a copy of the License at |
| 6 * |
| 7 * http://www.eclipse.org/legal/epl-v10.html |
| 8 * |
| 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
| 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
| 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
| 12 * the License. |
| 13 */ |
| 14 package com.google.dart.engine.html.ast; |
| 15 |
| 16 import com.google.dart.engine.ast.CompilationUnit; |
| 17 import com.google.dart.engine.element.HtmlScriptElement; |
| 18 import com.google.dart.engine.html.ast.visitor.XmlVisitor; |
| 19 import com.google.dart.engine.html.scanner.Token; |
| 20 |
| 21 import java.util.List; |
| 22 |
| 23 /** |
| 24 * Instances of the class {@code HtmlScriptTagNode} represent a script tag withi
n an HTML file that |
| 25 * references a Dart script. |
| 26 */ |
| 27 public class HtmlScriptTagNode extends XmlTagNode { |
| 28 /** |
| 29 * The AST structure representing the Dart code within this tag. |
| 30 */ |
| 31 private CompilationUnit script; |
| 32 |
| 33 /** |
| 34 * The element representing this script. |
| 35 */ |
| 36 private HtmlScriptElement scriptElement; |
| 37 |
| 38 /** |
| 39 * Initialize a newly created node to represent a script tag within an HTML fi
le that references a |
| 40 * Dart script. |
| 41 * |
| 42 * @param nodeStart the token marking the beginning of the tag |
| 43 * @param tag the name of the tag |
| 44 * @param attributes the attributes in the tag |
| 45 * @param attributeEnd the token terminating the region where attributes can b
e |
| 46 * @param tagNodes the children of the tag |
| 47 * @param contentEnd the token that starts the closing tag |
| 48 * @param closingTag the name of the tag that occurs in the closing tag |
| 49 * @param nodeEnd the last token in the tag |
| 50 */ |
| 51 public HtmlScriptTagNode(Token nodeStart, Token tag, List<XmlAttributeNode> at
tributes, |
| 52 Token attributeEnd, List<XmlTagNode> tagNodes, Token contentEnd, Token clo
singTag, |
| 53 Token nodeEnd) { |
| 54 super(nodeStart, tag, attributes, attributeEnd, tagNodes, contentEnd, closin
gTag, nodeEnd); |
| 55 } |
| 56 |
| 57 @Override |
| 58 public <R> R accept(XmlVisitor<R> visitor) { |
| 59 return visitor.visitHtmlScriptTagNode(this); |
| 60 } |
| 61 |
| 62 /** |
| 63 * Return the AST structure representing the Dart code within this tag, or {@c
ode null} if this |
| 64 * tag references an external script. |
| 65 * |
| 66 * @return the AST structure representing the Dart code within this tag |
| 67 */ |
| 68 public CompilationUnit getScript() { |
| 69 return script; |
| 70 } |
| 71 |
| 72 /** |
| 73 * Return the element representing this script. |
| 74 * |
| 75 * @return the element representing this script |
| 76 */ |
| 77 public HtmlScriptElement getScriptElement() { |
| 78 return scriptElement; |
| 79 } |
| 80 |
| 81 /** |
| 82 * Set the AST structure representing the Dart code within this tag to the giv
en compilation unit. |
| 83 * |
| 84 * @param unit the AST structure representing the Dart code within this tag |
| 85 */ |
| 86 public void setScript(CompilationUnit unit) { |
| 87 script = unit; |
| 88 } |
| 89 |
| 90 /** |
| 91 * Set the element representing this script to the given element. |
| 92 * |
| 93 * @param scriptElement the element representing this script |
| 94 */ |
| 95 public void setScriptElement(HtmlScriptElement scriptElement) { |
| 96 this.scriptElement = scriptElement; |
| 97 } |
| 98 } |
OLD | NEW |