daikon.tools.jtb
Class Ast

Object
  extended by Ast

public class Ast
extends Object


Constructor Summary
Ast()
           
 
Method Summary
static void addComment(Node n, NodeToken comment)
           
static void addComment(Node n, NodeToken comment, boolean first)
          Add the comment to the first regular token in the tree, as a "special token" (comment).
static NodeToken addComment(Node n, String comment)
           
static NodeToken addComment(Node n, String comment, boolean first)
           
static void addDeclaration(ClassOrInterfaceBody c, ClassOrInterfaceBodyDeclaration d)
           
static void addFirstSpecial(NodeToken n, NodeToken s)
          Adds the comment to the first regular token in the tree, *before* all other special tokens.
static void addImport(CompilationUnit u, ImportDeclaration i)
           
static void addNthSpecial(NodeToken n, NodeToken s, int i)
          Adds the comment to the first regular token in the tree, before the ith special token.
static void applyVisitorInsertComments(String javafilename, Node root, Writer output, AnnotateVisitor visitor)
           
static void applyVisitorReformat(Reader input, Writer output, Visitor visitor)
           
static PrimaryExpression assignment2primaryexpression(Expression n)
           
static String classnameForSourceOutput(Class c)
           
static boolean contains(Node n, String s)
           
static Node copy(String type, Node n)
           
static Node create(String type, Class[] argTypes, Object[] args, String stringRep)
           
static Node create(String type, String stringRep)
           
static String fieldName(Name n)
           
static String fieldName(PrimaryExpression pe)
           
static void findLineAndCol(Node n, NodeToken comment, boolean first)
          Add the comment to the first regular token in the tree.
static String format(Node n)
           
static String formatCurrentLine(Node n)
           
static String getBody(MethodDeclaration m)
           
static Class getClass(Node n)
           
static Class getClass(String s)
           
static String getClassName(Node d)
           
static String getClassNameForType(TypeDeclaration d)
           
static Constructor getConstructor(Class c, ConstructorDeclaration constructordecl)
           
static Constructor getConstructor(ConstructorDeclaration constructordecl)
           
static String getFullName(MethodDeclaration method)
           
static String getFullSignature(MethodDeclaration method)
           
static List<Invariant> getInvariants(PptTopLevel ppt, PptMap ppt_map)
          This code is taken from and modified from daikon.PrintInvariants.print_invariants.
static Method getMethod(Class c, MethodDeclaration methoddecl)
           
static Method getMethod(MethodDeclaration methoddecl)
           
static String getMethodDeclarator(MethodDeclaration m)
           
static Modifiers getModifiers(ClassOrInterfaceDeclaration n)
           
static Modifiers getModifiers(MethodDeclaration n)
           
static String getName(ConstructorDeclaration m)
           
static String getName(FormalParameter p)
           
static String getName(MethodDeclaration m)
           
static String getPackage(CompilationUnit u)
           
static List<FormalParameter> getParameters(ConstructorDeclaration cd)
           
static List<FormalParameter> getParameters(MethodDeclaration m)
           
static List<FormalParameter> getParametersNoImplicit(ConstructorDeclaration cd)
           
static Node getParent(Class type, Node child)
           
static Enumeration getPrimarySuffixes(PrimaryExpression p)
          Returns an Enumeration of PrimarySuffix objects (but the static type of the elements is only known to be Node).
static String getReturnType(MethodDeclaration m)
           
static String getType(FormalParameter fp)
           
static Set<String> getVariableNames(Node expr)
           
static boolean isAccessModifier(String s)
           
static boolean isArray(Type n)
           
static boolean isImplementation(Class c, MethodDeclaration methdecl)
           
static boolean isImplementation(MethodDeclaration methdecl)
           
static boolean isInner(ClassOrInterfaceDeclaration n)
           
static boolean isInterface(ClassOrInterfaceBody n)
           
static boolean isInterface(ClassOrInterfaceDeclaration n)
           
static boolean isMain(MethodDeclaration md)
          Return true if this is the main method for this class.
static boolean isOverride(Class c, MethodDeclaration methdecl)
           
static boolean isOverride(MethodDeclaration methdecl)
           
static boolean isPrimitive(Type n)
           
static boolean isReference(Type n)
           
static boolean isStatic(ClassOrInterfaceDeclaration n)
           
static boolean isStatic(MethodDeclaration n)
           
static boolean modifierPresent(Modifiers modifiers, String modifierString)
           
static NodeToken nodeTokenAfter(Node n)
           
static boolean paramsMatch(Class[] params, List<FormalParameter> ast_params)
           
static String print(Node n)
          Deprecated. Use format(Node) instead
static String printCurrentLine(Node n)
          Deprecated. Use formatCurrentLine(Node) instead
static String quickFixForInternalComment(String s)
           
static void removeAnnotations(MethodDeclaration m)
           
static String removeWhitespace(String arg)
           
static void setAccess(MethodDeclaration m, String access)
           
static void setBody(MethodDeclaration m, String body)
           
static void setName(MethodDeclaration m, String name)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ast

public Ast()
Method Detail

applyVisitorInsertComments

public static void applyVisitorInsertComments(String javafilename,
                                              Node root,
                                              Writer output,
                                              AnnotateVisitor visitor)

applyVisitorReformat

public static void applyVisitorReformat(Reader input,
                                        Writer output,
                                        Visitor visitor)

format

public static String format(Node n)

quickFixForInternalComment

public static String quickFixForInternalComment(String s)

formatCurrentLine

public static String formatCurrentLine(Node n)

print

@Deprecated
public static String print(Node n)
Deprecated. Use format(Node) instead


printCurrentLine

@Deprecated
public static String printCurrentLine(Node n)
Deprecated. Use formatCurrentLine(Node) instead


create

public static Node create(String type,
                          String stringRep)

create

public static Node create(String type,
                          Class[] argTypes,
                          Object[] args,
                          String stringRep)

isAccessModifier

public static boolean isAccessModifier(String s)

getName

public static String getName(FormalParameter p)

getType

public static String getType(FormalParameter fp)

getName

public static String getName(MethodDeclaration m)

getName

public static String getName(ConstructorDeclaration m)

getPackage

public static String getPackage(CompilationUnit u)

getFullName

public static String getFullName(MethodDeclaration method)

getFullSignature

public static String getFullSignature(MethodDeclaration method)

getClassNameForType

public static String getClassNameForType(TypeDeclaration d)

getClassName

public static String getClassName(Node d)

setName

public static void setName(MethodDeclaration m,
                           String name)

assignment2primaryexpression

public static PrimaryExpression assignment2primaryexpression(Expression n)

fieldName

public static String fieldName(PrimaryExpression pe)

fieldName

public static String fieldName(Name n)

addComment

public static NodeToken addComment(Node n,
                                   String comment)

addComment

public static NodeToken addComment(Node n,
                                   String comment,
                                   boolean first)

addComment

public static void addComment(Node n,
                              NodeToken comment)

addComment

public static void addComment(Node n,
                              NodeToken comment,
                              boolean first)
Add the comment to the first regular token in the tree, as a "special token" (comment). If first is true, then it is inserted before all other special tokens; otherwise, it is inserted after them. Postcondition (make sure you preserve it if you modify this method): comment.beginLine and comment.beginColumn have been assigned the line and column number where this comment will go.


findLineAndCol

public static void findLineAndCol(Node n,
                                  NodeToken comment,
                                  boolean first)
Add the comment to the first regular token in the tree. If first is true, then it is inserted before all other special tokens; otherwise, it is inserted after them. Exception: If first is true, may heuristically place the comment it in the middle of the list of special tokens (comments), in order to place it at the same column as the real node. Postcondition (make sure you preserve it if you modify this method): comment.beginLine and comment.beginColumn have been assigned the line and column number where this comment will go.


addNthSpecial

public static void addNthSpecial(NodeToken n,
                                 NodeToken s,
                                 int i)
Adds the comment to the first regular token in the tree, before the ith special token.


addFirstSpecial

public static void addFirstSpecial(NodeToken n,
                                   NodeToken s)
Adds the comment to the first regular token in the tree, *before* all other special tokens.


nodeTokenAfter

public static NodeToken nodeTokenAfter(Node n)

removeAnnotations

public static void removeAnnotations(MethodDeclaration m)

removeWhitespace

public static String removeWhitespace(String arg)

getClass

public static Class getClass(Node n)

getClass

public static Class getClass(String s)

getMethod

public static Method getMethod(MethodDeclaration methoddecl)

getMethod

public static Method getMethod(Class c,
                               MethodDeclaration methoddecl)

getConstructor

public static Constructor getConstructor(ConstructorDeclaration constructordecl)

getConstructor

public static Constructor getConstructor(Class c,
                                         ConstructorDeclaration constructordecl)

paramsMatch

public static boolean paramsMatch(Class[] params,
                                  List<FormalParameter> ast_params)

isOverride

public static boolean isOverride(MethodDeclaration methdecl)

isOverride

public static boolean isOverride(Class c,
                                 MethodDeclaration methdecl)

isImplementation

public static boolean isImplementation(MethodDeclaration methdecl)

isImplementation

public static boolean isImplementation(Class c,
                                       MethodDeclaration methdecl)

getParent

public static Node getParent(Class type,
                             Node child)

addDeclaration

public static void addDeclaration(ClassOrInterfaceBody c,
                                  ClassOrInterfaceBodyDeclaration d)

setAccess

public static void setAccess(MethodDeclaration m,
                             String access)

copy

public static Node copy(String type,
                        Node n)

contains

public static boolean contains(Node n,
                               String s)

setBody

public static void setBody(MethodDeclaration m,
                           String body)

getBody

public static String getBody(MethodDeclaration m)

getReturnType

public static String getReturnType(MethodDeclaration m)

getMethodDeclarator

public static String getMethodDeclarator(MethodDeclaration m)

getParameters

public static List<FormalParameter> getParameters(MethodDeclaration m)

getParametersNoImplicit

public static List<FormalParameter> getParametersNoImplicit(ConstructorDeclaration cd)

getParameters

public static List<FormalParameter> getParameters(ConstructorDeclaration cd)

addImport

public static void addImport(CompilationUnit u,
                             ImportDeclaration i)

getVariableNames

public static Set<String> getVariableNames(Node expr)

getPrimarySuffixes

public static Enumeration getPrimarySuffixes(PrimaryExpression p)
Returns an Enumeration of PrimarySuffix objects (but the static type of the elements is only known to be Node).


isMain

public static boolean isMain(MethodDeclaration md)
Return true if this is the main method for this class.


getInvariants

public static List<Invariant> getInvariants(PptTopLevel ppt,
                                            PptMap ppt_map)
This code is taken from and modified from daikon.PrintInvariants.print_invariants. The main modification is that instead of printing the invariants, we return a list of them. modifications involve removing code that I don't need here, like printing of debugging info. [[ TODO: instead of duplicating code, you should add this method to PrintInvariants (or wherever it belongs) and have PrintInvariants.print_invariants call it. ]]


isStatic

public static boolean isStatic(ClassOrInterfaceDeclaration n)

isStatic

public static boolean isStatic(MethodDeclaration n)

getModifiers

public static Modifiers getModifiers(ClassOrInterfaceDeclaration n)

getModifiers

public static Modifiers getModifiers(MethodDeclaration n)

modifierPresent

public static boolean modifierPresent(Modifiers modifiers,
                                      String modifierString)

isInner

public static boolean isInner(ClassOrInterfaceDeclaration n)

isInterface

public static boolean isInterface(ClassOrInterfaceBody n)

isInterface

public static boolean isInterface(ClassOrInterfaceDeclaration n)

isPrimitive

public static boolean isPrimitive(Type n)

isReference

public static boolean isReference(Type n)

isArray

public static boolean isArray(Type n)

classnameForSourceOutput

public static String classnameForSourceOutput(Class c)