Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.checks.usage.transmogrify
Class ASTManager  view ASTManager download ASTManager.java

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.checks.usage.transmogrify.ASTManager

public final class ASTManager
extends java.lang.Object

Manages AST trees and nodes. Capable of managing multiple parse trees, which is useful for inter-file checks.


Field Summary
private static ASTManager INSTANCE
          singleton
private  java.util.Map mCheckNodes
          Set of checks and their nodes to check
private  SymTabAST mCompleteTree
          root with subtrees for a set of files
private  java.util.Map mMap
          maps DetailASTs to SymTabASTs.
private  java.util.Map mTrees
          Map for parse trees, keyed on File name
 
Constructor Summary
private ASTManager()
          prevent client creation
 
Method Summary
private  void addToCompleteTree(java.io.File aFile, antlr.collections.AST aAST)
          Adds a file and a DetailAST to the root SymTabAST tree.
 void addTree(java.lang.String aFileName, antlr.collections.AST aRoot)
          Add the parse tree for a file to the set of parse trees.
private  void buildTree()
          Builds the complete tree for all added parse trees.
 void clearDetailsMap()
          Clears all associations from DetailsASTs to SymTabASTs.
 SymTabAST get(antlr.collections.AST aAST)
          Gets the SymTabAST associated with a AST.
 java.util.Set getCheckNodes(com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck aCheck)
          Gets the nodes to check with a usage check.
static ASTManager getInstance()
          Returns the singleon ASTManager.
 boolean isEmptyDetailsMap()
          Determines whether the map from DetailsASTs to SymTabASTs is empty.
 void put(antlr.collections.AST aAST, SymTabAST aSymTabAST)
          Maps a AST to its associated SymTabAST.
 void registerCheckNode(com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck aCheck, antlr.collections.AST aNode)
          Registers a node for checking.
 void removeCheck(com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck aCheck)
          Removes a check and its check nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

private static final ASTManager INSTANCE
singleton


mMap

private java.util.Map mMap
maps DetailASTs to SymTabASTs.


mCompleteTree

private SymTabAST mCompleteTree
root with subtrees for a set of files


mTrees

private java.util.Map mTrees
Map for parse trees, keyed on File name


mCheckNodes

private java.util.Map mCheckNodes
Set of checks and their nodes to check

Constructor Detail

ASTManager

private ASTManager()
prevent client creation

Method Detail

getInstance

public static ASTManager getInstance()
Returns the singleon ASTManager.


addTree

public void addTree(java.lang.String aFileName,
                    antlr.collections.AST aRoot)
Add the parse tree for a file to the set of parse trees.


buildTree

private void buildTree()
                throws SymbolTableException
Builds the complete tree for all added parse trees.


addToCompleteTree

private void addToCompleteTree(java.io.File aFile,
                               antlr.collections.AST aAST)
Adds a file and a DetailAST to the root SymTabAST tree. Normally, the DetailAST will be the parse tree for the file.


registerCheckNode

public void registerCheckNode(com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck aCheck,
                              antlr.collections.AST aNode)
Registers a node for checking.


getCheckNodes

public java.util.Set getCheckNodes(com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck aCheck)
                            throws SymbolTableException
Gets the nodes to check with a usage check.


put

public void put(antlr.collections.AST aAST,
                SymTabAST aSymTabAST)
Maps a AST to its associated SymTabAST.


get

public SymTabAST get(antlr.collections.AST aAST)
Gets the SymTabAST associated with a AST.


clearDetailsMap

public void clearDetailsMap()
Clears all associations from DetailsASTs to SymTabASTs.


isEmptyDetailsMap

public boolean isEmptyDetailsMap()
Determines whether the map from DetailsASTs to SymTabASTs is empty.


removeCheck

public void removeCheck(com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck aCheck)
Removes a check and its check nodes. Clears all managed elements if last check removed.