com.google.caja.parser.js
Class TranslatedCode

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.TranslatedCode
All Implemented Interfaces:
JsonMLCompatible, Statement, MutableParseTreeNode, ParseTreeNode, MessagePart, Renderable, java.lang.Cloneable

public final class TranslatedCode
extends AbstractStatement

The result of a code translation step, such as an HTML to JS compiler. This is not a real javascript parse tree node since it will never be created by the JS parser.

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
 
Fields inherited from interface com.google.caja.parser.ParseTreeNode
TAINTED
 
Constructor Summary
TranslatedCode(Block body)
           
TranslatedCode(FilePosition pos, java.lang.Void value, java.util.List<? extends Statement> children)
           
 
Method Summary
 java.util.List<? extends Block> children()
          An immutable list of children.
protected  void childrenChanged()
          Called to perform consistency checks on the child list after changes have been made.
 Block getTranslation()
           
 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 ";".
 boolean isTerminal()
          Does the rendered form end with a close curly bracket?
 void render(RenderContext rc)
          Output the textual form to r.getOut().
 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, makeRenderer, renderBlock
 
Methods inherited from class com.google.caja.parser.AbstractParseTreeNode
acceptPostOrder, acceptPreOrder, appendChild, 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, clone, formatTree, getAttributes, getComments, getFilePosition
 
Methods inherited from interface com.google.caja.reporting.MessagePart
format
 

Constructor Detail

TranslatedCode

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

TranslatedCode

public TranslatedCode(Block body)
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

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.

children

public java.util.List<? extends Block> children()
Description copied from interface: ParseTreeNode
An immutable list of children.

Specified by:
children in interface ParseTreeNode
Overrides:
children in class AbstractParseTreeNode

getTranslation

public Block getTranslation()

render

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


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 ";".


isTerminal

public boolean isTerminal()
Description copied from class: AbstractStatement
Does the rendered form end with a close curly bracket?

Specified by:
isTerminal in interface Statement
Overrides:
isTerminal in class AbstractStatement

toJsonML

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



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