|
From: <caw...@us...> - 2007-02-22 20:47:02
|
Revision: 2006
http://svn.sourceforge.net/rubyeclipse/?rev=2006&view=rev
Author: cawilliams
Date: 2007-02-22 12:46:57 -0800 (Thu, 22 Feb 2007)
Log Message:
-----------
chnage the infrastructure for generating errors/warnings. Much easier to add a new type of AST code analyzer now...
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java 2007-02-22 20:46:57 UTC (rev 2006)
@@ -0,0 +1,51 @@
+package org.rubypeople.rdt.internal.core.parser.warnings;
+
+import org.jruby.ast.Node;
+import org.jruby.ast.visitor.AbstractVisitor;
+import org.jruby.evaluator.Instruction;
+import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.core.IProblemRequestor;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.internal.core.parser.Error;
+import org.rubypeople.rdt.internal.core.parser.NodeUtil;
+import org.rubypeople.rdt.internal.core.parser.Warning;
+
+public abstract class RubyLintVisitor extends AbstractVisitor {
+
+ private IProblemRequestor problemRequestor;
+ private String contents;
+
+ public RubyLintVisitor(String contents, IProblemRequestor problemRequestor) {
+ this.problemRequestor = problemRequestor;
+ this.contents = contents;
+ }
+
+ protected String getSource(Node node) {
+ return NodeUtil.getSource(contents, node);
+ }
+
+ protected void createProblem(ISourcePosition position, String message) {
+ String value = RubyCore.getOption(getOptionKey());
+ if (value != null && value.equals(RubyCore.IGNORE))
+ return;
+ IProblem problem;
+ if (value != null && value.equals(RubyCore.ERROR))
+ problem = new Error(position, message);
+ else
+ problem = new Warning(position, message);
+ problemRequestor.acceptProblem(problem);
+ }
+
+ @Override
+ protected Instruction visitNode(Node iVisited) {
+ return null;
+ }
+
+ /**
+ * The key used to store the error/warning severity option.
+ * @return a String key
+ */
+ abstract protected String getOptionKey();
+
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|