From 3d734ac4162e457e4d3679487a6726e94c17db5b Mon Sep 17 00:00:00 2001 From: Rick Giles Date: Thu, 10 Jul 2003 23:01:56 +0000 Subject: [PATCH] fixed most checkstyle errors --- .../checkstyle/checks/usage/ASTManager.java | 46 ++++++++++--------- .../checks/usage/AbstractUsageCheck.java | 20 ++++---- .../usage/UnusedLocalVariableCheck.java | 3 +- .../checks/usage/UnusedParameterCheck.java | 17 ++++--- .../checks/usage/UnusedPrivateFieldCheck.java | 1 - .../usage/UnusedPrivateMethodCheck.java | 2 +- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/ASTManager.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/ASTManager.java index 13d4e1568..43ef265b7 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/ASTManager.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/ASTManager.java @@ -1,20 +1,20 @@ //////////////////////////////////////////////////////////////////////////////// -//checkstyle: Checks Java source code for adherence to a set of rules. -//Copyright (C) 2001-2003 Oliver Burn +// checkstyle: Checks Java source code for adherence to a set of rules. +// Copyright (C) 2001-2003 Oliver Burn // -//This library is free software; you can redistribute it and/or -//modify it under the terms of the GNU Lesser General Public -//License as published by the Free Software Foundation; either -//version 2.1 of the License, or (at your option) any later version. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -//This library is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -//Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -//You should have received a copy of the GNU Lesser General Public -//License along with this library; if not, write to the Free Software -//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //////////////////////////////////////////////////////////////////////////////// package com.puppycrawl.tools.checkstyle.checks.usage; @@ -43,11 +43,11 @@ import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.TableMaker; public final class ASTManager { /** singleton */ - private static final ASTManager sInstance = new ASTManager(); + private static final ASTManager INSTANCE = new ASTManager(); /** maps DetailASTs to SymTabASTs. */ private Map mMap = new IdentityHashMap(); - + /** root with subtrees for a set of files */ private SymTabAST mCompleteTree = null; @@ -61,14 +61,14 @@ public final class ASTManager private ASTManager() { } - + /** * Returns the singleon ASTManager. * @return the singleon ASTManager. */ public static ASTManager getInstance() { - return sInstance; + return INSTANCE; } /** @@ -83,6 +83,7 @@ public final class ASTManager /** * Builds the complete tree for all added parse trees. + * @throws SymbolTableException if there is an error. */ private void buildTree() throws SymbolTableException @@ -108,14 +109,15 @@ public final class ASTManager * @param aFile the file to add. * @param aAST the DetailAST to add. */ - private void addToCompleteTree(File aFile, AST aAST) { + private void addToCompleteTree(File aFile, AST aAST) + { // add aFile to the root final SymTabAST fileNode = SymTabASTFactory.create(0, aFile.getAbsolutePath()); fileNode.setFile(aFile); mCompleteTree.addChild(fileNode); fileNode.setParent(mCompleteTree); - + // add aAST to aFile final SymTabAST child = SymTabASTFactory.create(aAST); child.setFile(aFile); @@ -153,7 +155,7 @@ public final class ASTManager { // lazy initialization if (mCompleteTree == null) { - buildTree(); + buildTree(); } Set result = (Set) mCheckNodes.get(aCheck); if (result == null) { @@ -181,7 +183,7 @@ public final class ASTManager { return (SymTabAST) mMap.get(aAST); } - + /** * Clears all associations from DetailsASTs to SymTabASTs. */ @@ -206,7 +208,7 @@ public final class ASTManager { mCheckNodes.clear(); mCompleteTree = null; - mMap .clear(); + mMap.clear(); mTrees.clear(); } } diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/AbstractUsageCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/AbstractUsageCheck.java index 7618b3cec..a76782339 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/AbstractUsageCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/AbstractUsageCheck.java @@ -45,7 +45,7 @@ public abstract class AbstractUsageCheck { /** determines whether all checks are single, intra-file checks */ private static boolean sIsSingleFileCheckSet = true; - + /** the regexp to match against */ private RE mRegexp = null; /** the format string of the regexp */ @@ -85,7 +85,7 @@ public abstract class AbstractUsageCheck { // use my class loader ClassManager.setClassLoader(getClassLoader()); - + final String fileName = getFileContents().getFilename(); ASTManager.getInstance().addTree(fileName, aRootAST); } @@ -124,7 +124,7 @@ public abstract class AbstractUsageCheck */ public void logError(Exception aException) { - log(0, "general.exception", new String[] { aException.getMessage()}); + log(0, "general.exception", new String[] {aException.getMessage()}); } /** @@ -134,14 +134,15 @@ public abstract class AbstractUsageCheck * @param aFile the file to add. * @param aAST the DetailAST to add. */ - private void addToTree(SymTabAST aRoot, File aFile, DetailAST aAST) { + private void addToTree(SymTabAST aRoot, File aFile, DetailAST aAST) + { // add aFile to aRoot final SymTabAST fileNode = SymTabASTFactory.create(0, aFile.getAbsolutePath()); fileNode.setFile(aFile); aRoot.addChild(fileNode); fileNode.setParent(aRoot); - + // add aAST to aFile final SymTabAST child = SymTabASTFactory.create(aAST); child.setFile(aFile); @@ -153,13 +154,13 @@ public abstract class AbstractUsageCheck /** * Determines the reference count for a DetailAST. * @param aAST the DetailAST to count. - * @return the number of references to aAST. + * @return the number of references to aAST. */ private int getReferenceCount(DetailAST aAST) { final SymTabAST ident = ASTManager.getInstance().get(aAST); final Definition definition = - (Definition)ident.getDefinition(); + (Definition) ident.getDefinition(); if (definition != null) { return definition.getNumReferences(); } @@ -183,9 +184,10 @@ public abstract class AbstractUsageCheck /** * Applies this check to a set of nodes. - * @param nodes the nodes to check. + * @param aNodes the nodes to check. */ - public void applyTo(Set aNodes) { + public void applyTo(Set aNodes) + { final Iterator it = aNodes.iterator(); while (it.hasNext()) { final DetailAST nameAST = (DetailAST) it.next(); diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheck.java index e7849d63b..9bfcb110e 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedLocalVariableCheck.java @@ -44,7 +44,6 @@ public class UnusedLocalVariableCheck extends AbstractUsageCheck TokenTypes.VARIABLE_DEF, }; } - /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */ public String getErrorKey() @@ -55,6 +54,6 @@ public class UnusedLocalVariableCheck extends AbstractUsageCheck /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */ public boolean mustCheckReferenceCount(DetailAST aAST) { - return ScopeUtils.isLocalVariableDef(aAST); + return ScopeUtils.isLocalVariableDef(aAST); } } \ No newline at end of file diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheck.java index 79055afe5..da44788e3 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedParameterCheck.java @@ -39,7 +39,7 @@ public class UnusedParameterCheck extends AbstractUsageCheck { /** controls checking of catch clause parameter */ private boolean mIgnoreCatch = true; - + /** @see com.puppycrawl.tools.checkstyle.api.Check */ public int[] getDefaultTokens() { @@ -47,7 +47,7 @@ public class UnusedParameterCheck extends AbstractUsageCheck TokenTypes.PARAMETER_DEF, }; } - + /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */ public String getErrorKey() { @@ -63,29 +63,28 @@ public class UnusedParameterCheck extends AbstractUsageCheck if (parent.getType() == TokenTypes.PARAMETERS) { final DetailAST grandparent = parent.getParent(); if (grandparent != null) { - if (grandparent.getType() == TokenTypes.METHOD_DEF) - { + if (grandparent.getType() == TokenTypes.METHOD_DEF) { final DetailAST modifiersAST = - grandparent.findFirstToken(TokenTypes.MODIFIERS); + grandparent.findFirstToken(TokenTypes.MODIFIERS); if ((modifiersAST != null) && !modifiersAST.branchContains(TokenTypes.ABSTRACT) && !ScopeUtils.inInterfaceBlock(aAST)) { result = true; - } + } } else if (grandparent.getType() == TokenTypes.CTOR_DEF) { result = true; - } + } } } else if (parent.getType() == TokenTypes.LITERAL_CATCH) { result = !mIgnoreCatch; } } - return result; + return result; } - + /** * Control whether unused catch clause parameters are flagged. * @param aIgnoreCatch whether unused catch clause parameters diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheck.java index dffaf88f3..6558789d4 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateFieldCheck.java @@ -46,7 +46,6 @@ public class UnusedPrivateFieldCheck TokenTypes.VARIABLE_DEF, }; } - /** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */ public String getErrorKey() diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheck.java index 9016447c0..7bfd9e075 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/usage/UnusedPrivateMethodCheck.java @@ -37,7 +37,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; */ public class UnusedPrivateMethodCheck extends AbstractUsageCheck - + { /** @see com.puppycrawl.tools.checkstyle.api.Check */ public int[] getDefaultTokens()