|
From: <caw...@us...> - 2007-02-22 20:45:44
|
Revision: 2004
http://svn.sourceforge.net/rubyeclipse/?rev=2004&view=rev
Author: cawilliams
Date: 2007-02-22 12:45:36 -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...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java
Modified: trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-02-22 20:44:36 UTC (rev 2003)
+++ trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-02-22 20:45:36 UTC (rev 2004)
@@ -15,6 +15,7 @@
org.rubypeople.rdt.internal.core.buffer,
org.rubypeople.rdt.internal.core.builder,
org.rubypeople.rdt.internal.core.parser,
+ org.rubypeople.rdt.internal.core.parser.warnings,
org.rubypeople.rdt.internal.core.symbols,
org.rubypeople.rdt.internal.core.util,
org.rubypeople.rdt.internal.formatter,
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java 2007-02-22 20:44:36 UTC (rev 2003)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java 2007-02-22 20:45:36 UTC (rev 2004)
@@ -11,15 +11,18 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.jruby.ast.Node;
+import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.IProblemRequestor;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.internal.core.builder.ProblemRequestorMarkerManager;
import org.rubypeople.rdt.internal.core.parser.Error;
import org.rubypeople.rdt.internal.core.parser.RdtWarnings;
-import org.rubypeople.rdt.internal.core.parser.RubyLintVisitor;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.core.parser.TaskParser;
+import org.rubypeople.rdt.internal.core.parser.warnings.DelegatingVisitor;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
/**
* @author Chris
@@ -52,7 +55,8 @@
try {
Node node = parser.parse((IFile) script.getUnderlyingResource(), new StringReader(contents));
if (node == null) return;
- RubyLintVisitor visitor = new RubyLintVisitor(contents, problemRequestor);
+ List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents, problemRequestor);
+ NodeVisitor visitor = new DelegatingVisitor(visitors);
node.accept(visitor);
} catch (SyntaxException e) {
// Eat the exception
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-02-22 20:44:36 UTC (rev 2003)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-02-22 20:45:36 UTC (rev 2004)
@@ -17,15 +17,18 @@
import java.io.Reader;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
+import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.jruby.ast.Node;
+import org.jruby.ast.visitor.NodeVisitor;
import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.internal.core.parser.ImmediateWarnings;
-import org.rubypeople.rdt.internal.core.parser.RubyLintVisitor;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.core.parser.warnings.DelegatingVisitor;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
public final class RubyCodeAnalyzer implements SingleFileCompiler {
private final IMarkerManager markerManager;
@@ -54,8 +57,9 @@
markerManager.removeProblemsAndTasksFor(file);
try {
Node rootNode = parser.parse(file, new StringReader(contents));
- if (rootNode == null) return;
- RubyLintVisitor visitor = new RubyLintVisitor(contents, new ProblemRequestorMarkerManager(file, markerManager));
+ if (rootNode == null) return;
+ List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents, new ProblemRequestorMarkerManager(file, markerManager));
+ NodeVisitor visitor = new DelegatingVisitor(visitors);
rootNode.accept(visitor);
indexUpdater.update(file, rootNode, true);
} catch (SyntaxException e) {
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java 2007-02-22 20:44:36 UTC (rev 2003)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java 2007-02-22 20:45:36 UTC (rev 2004)
@@ -7,11 +7,13 @@
import junit.framework.TestCase;
import org.jruby.ast.Node;
+import org.jruby.ast.visitor.NodeVisitor;
import org.rubypeople.eclipse.shams.resources.ShamFile;
import org.rubypeople.rdt.core.IProblemRequestor;
import org.rubypeople.rdt.core.parser.IProblem;
-import org.rubypeople.rdt.internal.core.parser.RubyLintVisitor;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.core.parser.warnings.DelegatingVisitor;
+import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
public class TC_RubyLintVisitor extends TestCase {
@@ -47,7 +49,6 @@
public void testUnlessConditionalDoesntCreateEmptyConditionalWarning() throws Exception {
runLint("unless @blah\n @var = 3\nend");
- System.out.println(problemRequestor.problems.get(0));
assertEquals(0, problemRequestor.problems.size());
}
@@ -55,8 +56,8 @@
RubyParser parser = new RubyParser();
Node rootNode = parser.parse(new ShamFile("fake/path.rb"), new StringReader(contents));
problemRequestor = new MockProblemRequestor();
- RubyLintVisitor visitor = new RubyLintVisitor(contents,
- problemRequestor);
+ List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents, problemRequestor);
+ NodeVisitor visitor = new DelegatingVisitor(visitors);
rootNode.accept(visitor);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|