com.google.caja.ancillary.jsdoc
Class JsdocRewriter

java.lang.Object
  extended by com.google.caja.ancillary.jsdoc.JsdocRewriter

 class JsdocRewriter
extends java.lang.Object

A rewriter that rewrites javascript to store documentation strings with javascript values so that we can evaluate the javascript and inspect the resulting environment to get at the public API, a la pydoc.

Author:
mikesamuel@gmail.com

Field Summary
private  java.util.Set<Token<?>> consumed
           
private  AnnotationHandlers handlers
           
private  MessageContext mc
           
private  MessageQueue mq
           
private static java.util.regex.Pattern TAG
           
 
Constructor Summary
JsdocRewriter(AnnotationHandlers handlers, MessageContext mc, MessageQueue mq)
           
 
Method Summary
private  Expression commentToJson(Comment cmt)
           
private  Statement delayDocingOfUninitializedVariables(Statement s)
           
private  Conditional documentConditional(Conditional js)
           
private  ParseTreeNode documentDeclaration(Declaration js)
           
private  Expression documentExpression(Expression js)
           
private  Expression documentExpression(Expression js, Expression doc)
           
private  ExpressionStmt documentExpressionStmt(ExpressionStmt js)
           
private  ParseTreeNode documentFunction(ParseTreeNode fn)
           
private  Loop documentLoop(Loop js)
           
private  ParseTreeNode documentObjectConstructor(ObjectConstructor o)
           
private  ParseTreeNode documentReturnStmt(ReturnStmt js)
           
private  Expression extractFileOverview(ParseTreeNode js)
           
(package private) static java.lang.String format(FilePosition p, MessageContext mc)
           
(package private) static java.lang.String format(InputSource s, MessageContext mc)
          Simplify a URI by removing the common path elements from the front.
private  Comment getDocComment(ParseTreeNode js, Criterion<Comment> filter)
           
private  Expression getDocCommentJson(ParseTreeNode js)
           
private static boolean isScopeBlock(ParseTreeNode js)
           
private  BlockAnnotation normalizeHtml(BlockAnnotation a)
           
private  Comment normalizeHtml(Comment c)
           
private  java.util.List<Annotation> normalizeHtml(java.util.List<? extends Annotation> annotations)
          Normalize HTML so that unclosed tags don't interfere with the formatting of the embedding page.
private  ParseTreeNode rewrite(ParseTreeNode js)
           
private  java.util.List<ParseTreeNode> rewriteAll(java.util.List<? extends ParseTreeNode> nodes)
           
(package private)  ParseTreeNode rewriteFile(ParseTreeNode js)
           
(package private)  ParseTreeNode rewritePackageDocs(InputSource is, Comment cmt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mq

private final MessageQueue mq

mc

private final MessageContext mc

consumed

private final java.util.Set<Token<?>> consumed

handlers

private final AnnotationHandlers handlers

TAG

private static final java.util.regex.Pattern TAG
Constructor Detail

JsdocRewriter

JsdocRewriter(AnnotationHandlers handlers,
              MessageContext mc,
              MessageQueue mq)
Method Detail

rewriteFile

ParseTreeNode rewriteFile(ParseTreeNode js)

rewritePackageDocs

ParseTreeNode rewritePackageDocs(InputSource is,
                                 Comment cmt)

extractFileOverview

private Expression extractFileOverview(ParseTreeNode js)

rewrite

private ParseTreeNode rewrite(ParseTreeNode js)

isScopeBlock

private static boolean isScopeBlock(ParseTreeNode js)

documentExpression

private Expression documentExpression(Expression js)

documentExpression

private Expression documentExpression(Expression js,
                                      Expression doc)

documentExpressionStmt

private ExpressionStmt documentExpressionStmt(ExpressionStmt js)

documentDeclaration

private ParseTreeNode documentDeclaration(Declaration js)

documentFunction

private ParseTreeNode documentFunction(ParseTreeNode fn)

documentObjectConstructor

private ParseTreeNode documentObjectConstructor(ObjectConstructor o)

documentReturnStmt

private ParseTreeNode documentReturnStmt(ReturnStmt js)

documentLoop

private Loop documentLoop(Loop js)

documentConditional

private Conditional documentConditional(Conditional js)

delayDocingOfUninitializedVariables

private Statement delayDocingOfUninitializedVariables(Statement s)

rewriteAll

private java.util.List<ParseTreeNode> rewriteAll(java.util.List<? extends ParseTreeNode> nodes)

getDocComment

private Comment getDocComment(ParseTreeNode js,
                              Criterion<Comment> filter)

getDocCommentJson

private Expression getDocCommentJson(ParseTreeNode js)

commentToJson

private Expression commentToJson(Comment cmt)

format

static java.lang.String format(FilePosition p,
                               MessageContext mc)

format

static java.lang.String format(InputSource s,
                               MessageContext mc)
Simplify a URI by removing the common path elements from the front. If all the input sources start with "file:///src/" then that prefix will be skipped.


normalizeHtml

private java.util.List<Annotation> normalizeHtml(java.util.List<? extends Annotation> annotations)
Normalize HTML so that unclosed tags don't interfere with the formatting of the embedding page. This is not meant to enforce any security properties.


normalizeHtml

private Comment normalizeHtml(Comment c)

normalizeHtml

private BlockAnnotation normalizeHtml(BlockAnnotation a)


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