forked from phoedos/pmd
more CPD-aided refactoring
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@659 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -20,4 +20,8 @@ public class UnusedCodeRule extends AbstractRule {
|
||||
ctx.getReport().addRuleViolation(createRuleViolation(ctx, symbol.getLine(), MessageFormat.format(getMessage(), new Object[] {symbol.getImage()})));
|
||||
}
|
||||
}
|
||||
|
||||
protected String getEndName(String name) {
|
||||
return (name.indexOf('.') == -1) ? name : name.substring(0, name.indexOf('.'));
|
||||
}
|
||||
}
|
||||
|
@ -56,21 +56,11 @@ public class UnusedLocalVariableRule extends UnusedCodeRule {
|
||||
*/
|
||||
public Object visit(ASTName node, Object data) {
|
||||
if (node.jjtGetParent() instanceof ASTPrimaryPrefix) {
|
||||
String img = (node.getImage().indexOf('.') == -1) ? node.getImage() : node.getImage().substring(0, node.getImage().indexOf('.'));
|
||||
nameSpace.peek().recordPossibleUsageOf(new Symbol(img, node.getBeginLine()));
|
||||
nameSpace.peek().recordPossibleUsageOf(new Symbol(getEndName(node.getImage()), node.getBeginLine()));
|
||||
}
|
||||
return super.visit(node, data);
|
||||
}
|
||||
|
||||
/*
|
||||
private void reportUnusedLocals(RuleContext ctx, SymbolTable table) {
|
||||
for (Iterator i = table.getUnusedSymbols(); i.hasNext();) {
|
||||
Symbol symbol = (Symbol)i.next();
|
||||
ctx.getReport().addRuleViolation(createRuleViolation(ctx, symbol.getLine(), MessageFormat.format(getMessage(), new Object[] {symbol.getImage()})));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private Object addTable(SimpleNode node, Object data) {
|
||||
nameSpace.addTable();
|
||||
RuleContext ctx = (RuleContext)data;
|
||||
|
@ -99,10 +99,9 @@ public class UnusedPrivateInstanceVariableRule extends UnusedCodeRule {
|
||||
}
|
||||
|
||||
private void recordPossibleUsage(SimpleNode node) {
|
||||
String img = (node.getImage().indexOf('.') == -1) ? node.getImage() : node.getImage().substring(0, node.getImage().indexOf('.'));
|
||||
String otherImg = (node.getImage().indexOf('.') == -1) ? node.getImage() : node.getImage().substring(node.getImage().indexOf('.')+1);
|
||||
Namespace group = (Namespace)nameSpaces.peek();
|
||||
group.peek().recordPossibleUsageOf(new Symbol(img, node.getBeginLine()));
|
||||
group.peek().recordPossibleUsageOf(new Symbol(getEndName(node.getImage()), node.getBeginLine()));
|
||||
group.peek().recordPossibleUsageOf(new Symbol(otherImg, node.getBeginLine()));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user