|
From: <caw...@us...> - 2006-08-19 23:28:28
|
Revision: 1570 Author: cawilliams Date: 2006-08-19 16:28:22 -0700 (Sat, 19 Aug 2006) ViewCVS: http://svn.sourceforge.net/rubyeclipse/?rev=1570&view=rev Log Message: ----------- Modified Paths: -------------- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java =================================================================== --- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java 2006-08-15 11:40:54 UTC (rev 1569) +++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyLintVisitor.java 2006-08-19 23:28:22 UTC (rev 1570) @@ -1,15 +1,11 @@ package org.rubypeople.rdt.internal.core.parser; - - import java.io.Reader; import java.util.HashSet; import java.util.Set; - - import org.jruby.ast.BlockNode; import org.jruby.ast.CallNode; @@ -48,12 +44,8 @@ import org.rubypeople.rdt.core.parser.IProblem; - - public class RubyLintVisitor extends InOrderVisitor { - - private IProblemRequestor problemRequestor; private Set assignedConstants; @@ -62,8 +54,6 @@ private String contents; - - public RubyLintVisitor(String contents, IProblemRequestor problemRequestor) { this.problemRequestor = problemRequestor; @@ -76,8 +66,6 @@ } - - public Instruction visitFCallNode(FCallNode iVisited) { methodsCalled.add(iVisited.getName()); @@ -86,69 +74,42 @@ } - - public Instruction visitCallNode(CallNode iVisited) { - methodsCalled.add(iVisited.getName()); - return super.visitCallNode(iVisited); - } - - public Instruction visitIfNode(IfNode iVisited) { - Node condition = iVisited.getCondition(); - if (condition instanceof TrueNode) { - - problemRequestor.acceptProblem(new Warning(iVisited.getPosition(), - - "Condition is always true")); - - } else if ((condition instanceof FalseNode) - - || (condition instanceof NilNode)) { - - problemRequestor.acceptProblem(new Warning(iVisited.getPosition(), - - "Condition is always false")); - + problemRequestor.acceptProblem(new Warning(iVisited.getPosition(), "Condition is always true")); + } else if ((condition instanceof FalseNode) || (condition instanceof NilNode)) { + problemRequestor.acceptProblem(new Warning(iVisited.getPosition(), "Condition is always false")); } String source = NodeUtil.getSource(contents, iVisited); - if (iVisited.getThenBody() == null && !source.contains("unless")) { - IProblem problem = createProblem( + RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited.getPosition(), "Empty Conditional Body"); - RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited - - .getPosition(), "Empty Conditional Body"); - - if (problem != null) problemRequestor.acceptProblem(problem); - + if (problem != null) + problemRequestor.acceptProblem(problem); } - return super.visitIfNode(iVisited); - } - - public Instruction visitWhenNode(WhenNode iVisited) { if (iVisited.getBodyNode() == null) { IProblem problem = createProblem( - RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited + RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited - .getPosition(), "Empty When Body"); + .getPosition(), "Empty When Body"); - if (problem != null) problemRequestor.acceptProblem(problem); + if (problem != null) + problemRequestor.acceptProblem(problem); } @@ -156,27 +117,24 @@ } - - public Instruction visitBlockNode(BlockNode iVisited) { return super.visitBlockNode(iVisited); } - - public Instruction visitIterNode(IterNode iVisited) { if (iVisited.getBodyNode() == null) { IProblem problem = createProblem( - RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited + RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited - .getPosition(), "Empty Block"); + .getPosition(), "Empty Block"); - if (problem != null) problemRequestor.acceptProblem(problem); + if (problem != null) + problemRequestor.acceptProblem(problem); } @@ -184,8 +142,6 @@ } - - public Instruction visitDefnNode(DefnNode iVisited) { // TODO Analyze method visibility. Create warning for uncalled private @@ -198,11 +154,12 @@ IProblem problem = createProblem( - RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited + RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited - .getPosition(), "Empty Method Definition"); + .getPosition(), "Empty Method Definition"); - if (problem != null) problemRequestor.acceptProblem(problem); + if (problem != null) + problemRequestor.acceptProblem(problem); } @@ -210,8 +167,6 @@ } - - public Instruction visitDefsNode(DefsNode iVisited) { ScopeNode scope = iVisited.getBodyNode(); @@ -220,11 +175,12 @@ IProblem problem = createProblem( - RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited + RubyCore.COMPILER_PB_EMPTY_STATEMENT, iVisited - .getPosition(), "Empty Method Definition"); + .getPosition(), "Empty Method Definition"); - if (problem != null) problemRequestor.acceptProblem(problem); + if (problem != null) + problemRequestor.acceptProblem(problem); } @@ -232,20 +188,16 @@ } - - protected Instruction handleNode(Node visited) { -// System.out.println(visited.toString() + ", position -> " + // System.out.println(visited.toString() + ", position -> " -// + visited.getPosition()); + // + visited.getPosition()); return super.handleNode(visited); } - - public Instruction visitConstDeclNode(ConstDeclNode iVisited) { String name = iVisited.getName(); @@ -254,7 +206,7 @@ problemRequestor.acceptProblem(new Warning(iVisited.getPosition(), - "Reassignment of a constant")); + "Reassignment of a constant")); } else @@ -264,11 +216,9 @@ } - - private IProblem createProblem(String compilerOption, - ISourcePosition position, String message) { + ISourcePosition position, String message) { String value = RubyCore.getOption(compilerOption); @@ -288,7 +238,4 @@ } - - } - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |