com.google.caja.parser.js
Class Declaration

java.lang.Object
  extended by com.google.caja.parser.AbstractParseTreeNode
      extended by com.google.caja.parser.js.AbstractStatement
          extended by com.google.caja.parser.js.Declaration
All Implemented Interfaces:
JsonMLCompatible, Statement, MutableParseTreeNode, ParseTreeNode, MessagePart, Renderable, java.lang.Cloneable
Direct Known Subclasses:
FormalParam, FunctionDeclaration

public class Declaration
extends AbstractStatement

Introduces a variable into the current scope.

Author:
mikesamuel@gmail.com

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.google.caja.parser.ParseTreeNode
ParseTreeNode.ReflectiveCtor
 
Nested classes/interfaces inherited from interface com.google.caja.reporting.MessagePart
MessagePart.Factory
 
Nested classes/interfaces inherited from interface com.google.caja.parser.js.JsonMLCompatible
JsonMLCompatible.JsonMLBuilder
 
Nested classes/interfaces inherited from interface com.google.caja.parser.MutableParseTreeNode
MutableParseTreeNode.Mutation
 
Field Summary
private  Identifier identifier
           
private  Expression initializer
           
 
Fields inherited from interface com.google.caja.parser.ParseTreeNode
TAINTED
 
Constructor Summary
Declaration(FilePosition pos, Identifier identifier, Expression initializer)
           
Declaration(FilePosition pos, java.lang.Void value, java.util.List<? extends ParseTreeNode> children)
           
 
Method Summary
protected  void childrenChanged()
          Called to perform consistency checks on the child list after changes have been made.
 Identifier getIdentifier()
           
 java.lang.String getIdentifierName()
           
 Expression getInitializer()
           
 java.lang.Object getValue()
           
 boolean hasHangingConditional()
          True if the rendered form of the statement would consume more tokens if parsed followed by the tokens "else" and ";".
 void render(RenderContext rc)
          Output the textual form to r.getOut().
(package private)  void renderShort(RenderContext rc)
          Renders the short form without the "var" keyword.
(package private)  com.google.javascript.jscomp.jsonml.JsonML toInitOrIdPatt()
           
 com.google.javascript.jscomp.jsonml.JsonML toJsonML()
          Creates a JsonML representation of this AST.
 
Methods inherited from class com.google.caja.parser.js.AbstractStatement
breaks, continues, isTerminal, makeRenderer, renderBlock
 
Methods inherited from class com.google.caja.parser.AbstractParseTreeNode
acceptPostOrder, acceptPreOrder, appendChild, children, childrenAs, childrenPart, clone, createMutation, equals, format, formatSelf, formatTree, formatTree, getAttributes, getComments, getFilePosition, hashCode, insertBefore, removeChild, replaceChild, setComments, setFilePosition, toString, toStringDeep, toStringDeep
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.caja.parser.ParseTreeNode
acceptPostOrder, acceptPreOrder, children, clone, formatTree, getAttributes, getComments, getFilePosition
 
Methods inherited from interface com.google.caja.reporting.MessagePart
format
 

Field Detail

identifier

private Identifier identifier

initializer

private Expression initializer
Constructor Detail

Declaration

@ParseTreeNode.ReflectiveCtor
public Declaration(FilePosition pos,
                                                java.lang.Void value,
                                                java.util.List<? extends ParseTreeNode> children)
Parameters:
value - unused. This ctor is provided for reflection.

Declaration

public Declaration(FilePosition pos,
                   Identifier identifier,
                   Expression initializer)
Method Detail

childrenChanged

protected void childrenChanged()
Description copied from class: AbstractParseTreeNode
Called to perform consistency checks on the child list after changes have been made. This can be overridden to do additional checks by subclasses, and to update derived state, but all subclasses must chain to super after performing their own checks.

This method may throw any RuntimeException on an invalid child. TODO(mikesamuel): maybe reliably throw an exception type, that includes information about the troublesome node.

Overrides:
childrenChanged in class AbstractParseTreeNode

getIdentifier

public Identifier getIdentifier()

getIdentifierName

public java.lang.String getIdentifierName()

getInitializer

public Expression getInitializer()

getValue

public java.lang.Object getValue()
Specified by:
getValue in interface ParseTreeNode
Specified by:
getValue in class AbstractParseTreeNode
Returns:
null or a value with subclass specific meaning which encapsulates all parsed state separate from the children.

render

public void render(RenderContext rc)
Description copied from interface: Renderable
Output the textual form to r.getOut().


renderShort

void renderShort(RenderContext rc)
Renders the short form without the "var" keyword. This is used in multi declarations, such as in for (var a = 0, b = 1, ...).


hasHangingConditional

public boolean hasHangingConditional()
Description copied from interface: Statement
True if the rendered form of the statement would consume more tokens if parsed followed by the tokens "else" and ";".


toJsonML

public com.google.javascript.jscomp.jsonml.JsonML toJsonML()
Description copied from interface: JsonMLCompatible
Creates a JsonML representation of this AST.


toInitOrIdPatt

com.google.javascript.jscomp.jsonml.JsonML toInitOrIdPatt()


Copyright (C) 2008 Google Inc.
Licensed under the Apache License, Version 2.0