removed context hashmaps

This commit is contained in:
Lars Kühne 2003-01-07 08:15:27 +00:00
parent 59af65d194
commit 9074e6953f
3 changed files with 9 additions and 97 deletions

View File

@ -100,7 +100,6 @@ public final class TreeWalker
{
}
}
// TODO: really need to optimise the performance of this class.
/** maps from token name to checks */
private final Map mTokenToChecks = new HashMap();
@ -119,12 +118,6 @@ public final class TreeWalker
/** context of child components */
private Context mChildContext;
/** context of visited node */
private final Map mTokenContext = new HashMap();
/** context of tree */
private final Map mTreeContext = new HashMap();
/**
* HACK - a reference to a private "mParent" field in DetailAST.
* Don't do this at home!
@ -385,12 +378,9 @@ public final class TreeWalker
*/
private void notifyBegin(FileContents aContents)
{
// TODO: do not track Context properly for token
final Iterator it = mAllChecks.iterator();
while (it.hasNext()) {
final Check check = (Check) it.next();
mTreeContext.clear();
check.setTreeContext(mTreeContext);
check.setFileContents(aContents);
check.beginTree();
}
@ -446,10 +436,8 @@ public final class TreeWalker
(ArrayList) mTokenToChecks.get(
TokenTypes.getTokenName(aAST.getType()));
if (visitors != null) {
mTokenContext.clear();
for (int i = 0; i < visitors.size(); i++) {
final Check check = (Check) visitors.get(i);
check.setTokenContext(mTokenContext);
check.visitToken(aAST);
}
}
@ -467,7 +455,6 @@ public final class TreeWalker
if (visitors != null) {
for (int i = 0; i < visitors.size(); i++) {
final Check check = (Check) visitors.get(i);
// TODO: need to setup the token context
check.leaveToken(aAST);
}
}

View File

@ -19,7 +19,6 @@
package com.puppycrawl.tools.checkstyle.api;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
@ -33,24 +32,18 @@ public abstract class Check extends AutomaticBean
/** resuable constant for message formating */
private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
/** name to store file contents under */
private static final String FILE_CONTENTS_ATTRIBUTE = "fILEcONTENTS";
/** the current file contents */
private FileContents mFileContents = null;
/** the global context for the check */
private Map mGlobalContext;
/** the tokens the check is interested in */
private final Set mTokens = new HashSet();
/**
* the object for collecting messages. decided to not put in the global
* context for performance and ease of use.
*/
/** the object for collecting messages. */
private LocalizedMessages mMessages;
/** the context for the check across an AST */
private Map mTreeContext;
/** the context for a check across a token. */
private Map mTokenContext;
/** the tab with for column reporting */
private int mTabWidth = 8; // meaningful default
/** current class loader */
private ClassLoader mLoader =
Thread.currentThread().getContextClassLoader();
@ -107,26 +100,6 @@ public abstract class Check extends AutomaticBean
return mTokens;
}
/**
* Return the global context object for check. This context is valid for
* the lifetime of the check.
* @return the context object
*/
public final Map getGlobalContext()
{
return mGlobalContext;
}
/**
* Set the global context for the check.
* @param aContext the context
*/
public final void setGlobalContext(Map aContext)
{
mGlobalContext = aContext;
}
/**
* Set the global object used to collect messages.
* @param aMessages the messages to log with
@ -136,44 +109,6 @@ public abstract class Check extends AutomaticBean
mMessages = aMessages;
}
/**
* Return the tree context object for check. This context is valid for
* the lifetime of a abstract syntax tree.
* @return the context object
*/
public final Map getTreeContext()
{
return mTreeContext;
}
/**
* Set the tree context for the check.
* @param aContext the context
*/
public final void setTreeContext(Map aContext)
{
mTreeContext = aContext;
}
/**
* Return the tree context object for check. This context is valid for
* the lifetime of a abstract syntax tree.
* @return the context object
*/
public final Map getTokenContext()
{
return mTokenContext;
}
/**
* Set the token context for the check.
* @param aContext the global context
*/
public final void setTokenContext(Map aContext)
{
mTokenContext = aContext;
}
/**
* Initialse the check. This is the time to verify that the check has
* everything required to perform it job.
@ -236,7 +171,7 @@ public abstract class Check extends AutomaticBean
*/
public final void setFileContents(FileContents aContents)
{
getTreeContext().put(FILE_CONTENTS_ATTRIBUTE, aContents);
mFileContents = aContents;
}
/**
@ -245,7 +180,7 @@ public abstract class Check extends AutomaticBean
*/
public final FileContents getFileContents()
{
return (FileContents) getTreeContext().get(FILE_CONTENTS_ATTRIBUTE);
return mFileContents;
}
/**

View File

@ -33,9 +33,6 @@ import com.puppycrawl.tools.checkstyle.api.FullIdent;
public abstract class AbstractImportCheck
extends Check
{
/** key to store name of import as */
private static final String TEXT_KEY = "name";
/**
* Return the name of the import associated with a specifed DetailAST.
*
@ -44,13 +41,6 @@ public abstract class AbstractImportCheck
*/
protected FullIdent getImportText(DetailAST aAST)
{
FullIdent text = (FullIdent) getTokenContext().get(TEXT_KEY);
if (text != null) {
return text;
}
text = FullIdent.createFullIdent((DetailAST) aAST.getFirstChild());
getTokenContext().put(TEXT_KEY, text);
return text;
return FullIdent.createFullIdent((DetailAST) aAST.getFirstChild());
}
}