Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8784/src/org/rubypeople/rdt/internal/core/parser Modified Files: MarkerUtility.java RubyParser.java RdtWarnings.java Added Files: ImmediateWarnings.java IRdtWarnings.java Log Message: Refactored RubyBuilder into several smaller classes. Wrote UTs for a few of them. Began work on a SymbolIndex. Index: MarkerUtility.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MarkerUtility.java 6 Aug 2005 12:55:10 -0000 1.8 --- MarkerUtility.java 1 Oct 2005 23:01:01 -0000 1.9 *************** *** 68,76 **** } ! /** ! * @param underlyingResource ! * @param problem ! */ ! private static void createProblemMarker(IResource underlyingResource, IProblem problem) { try { IMarker marker = underlyingResource.createMarker(IRubyModelMarker.RUBY_MODEL_PROBLEM_MARKER); --- 68,72 ---- } ! public static void createProblemMarker(IResource underlyingResource, IProblem problem) { try { IMarker marker = underlyingResource.createMarker(IRubyModelMarker.RUBY_MODEL_PROBLEM_MARKER); Index: RdtWarnings.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RdtWarnings.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RdtWarnings.java 30 Mar 2005 00:12:29 -0000 1.3 --- RdtWarnings.java 1 Oct 2005 23:01:01 -0000 1.4 *************** *** 8,12 **** import java.util.List; ! import org.jruby.common.IRubyWarnings; import org.jruby.lexer.yacc.ISourcePosition; --- 8,12 ---- import java.util.List; ! import org.eclipse.core.resources.IFile; import org.jruby.lexer.yacc.ISourcePosition; *************** *** 14,18 **** * @author Chris */ ! public class RdtWarnings implements IRubyWarnings { private List warnings; --- 14,18 ---- * @author Chris */ ! public class RdtWarnings implements IRdtWarnings { private List warnings; *************** *** 77,79 **** --- 77,82 ---- } + public void setFile(IFile file) { + } + } Index: RubyParser.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/RubyParser.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** RubyParser.java 4 Mar 2005 23:31:09 -0000 1.35 --- RubyParser.java 1 Oct 2005 23:01:01 -0000 1.36 *************** *** 5,12 **** import java.io.Reader; - import java.io.StringReader; import org.jruby.ast.Node; - import org.jruby.common.IRubyWarnings; import org.jruby.common.NullWarnings; import org.jruby.lexer.yacc.LexerSource; --- 5,11 ---- import java.io.Reader; + import org.eclipse.core.resources.IFile; import org.jruby.ast.Node; import org.jruby.common.NullWarnings; import org.jruby.lexer.yacc.LexerSource; *************** *** 22,66 **** public class RubyParser { ! private final RubyParserPool pool; ! private IRubyWarnings warnings; private static boolean isDebug; public RubyParser() { ! this(new NullWarnings()); } ! public RubyParser(IRubyWarnings warnings) { this.warnings = warnings; this.pool = RubyParserPool.getInstance(); } ! public Node parse(String file, String content) { ! return parse(file, new StringReader(content)); ! } ! ! public Node parse(String file, Reader content) { ! return parse(file, content, new RubyParserConfiguration()); ! } ! ! private Node parse(String file, Reader content, RubyParserConfiguration config) { DefaultRubyParser parser = null; ! RubyParserResult result = null; ! try { ! parser = pool.borrowParser(); ! parser.setWarnings(warnings); ! parser.init(config); ! LexerSource lexerSource = new LexerSource(file, content, new RdtPositionFactory()); ! result = parser.parse(lexerSource); ! } catch (SyntaxException e) { ! throw e; ! } finally { ! pool.returnParser(parser); ! } ! return result.getAST(); } - /** - * @param b - */ public static void setDebugging(boolean b) { isDebug = b; --- 21,55 ---- public class RubyParser { ! private final RubyParserPool pool; ! private IRdtWarnings warnings; private static boolean isDebug; public RubyParser() { ! this(new NullRdtWarnings()); } ! public RubyParser(IRdtWarnings warnings) { this.warnings = warnings; this.pool = RubyParserPool.getInstance(); } ! public Node parse(IFile file, Reader content) { DefaultRubyParser parser = null; ! RubyParserResult result = null; ! try { ! warnings.setFile(file); ! parser = pool.borrowParser(); ! parser.setWarnings(warnings); ! parser.init(new RubyParserConfiguration()); ! LexerSource lexerSource = new LexerSource(file.getName(), content, new RdtPositionFactory()); ! result = parser.parse(lexerSource); ! } catch (SyntaxException e) { ! throw e; ! } finally { ! pool.returnParser(parser); ! } ! return result.getAST(); } public static void setDebugging(boolean b) { isDebug = b; *************** *** 68,74 **** public static boolean isDebugging() { - // TODO Auto-generated method stub return isDebug; } } \ No newline at end of file --- 57,68 ---- public static boolean isDebugging() { return isDebug; } + private static class NullRdtWarnings extends NullWarnings implements IRdtWarnings { + public void setFile(IFile file) { + } + } + + } \ No newline at end of file --- NEW FILE: ImmediateWarnings.java --- package org.rubypeople.rdt.internal.core.parser; import org.eclipse.core.resources.IFile; import org.jruby.lexer.yacc.ISourcePosition; import org.rubypeople.rdt.internal.core.builder.IMarkerManager; public class ImmediateWarnings implements IRdtWarnings { private IFile file; private IMarkerManager markerManager; public ImmediateWarnings(IMarkerManager markerManager) { this.markerManager = markerManager; } public void warning(String message) { warn(new RdtPosition(1, 0, 0), message); } public void warning(ISourcePosition position, String message) { warn(position, message); } public void warn(ISourcePosition position, String message) { markerManager.addWarning(file, message, position.getStartLine(), position.getStartOffset(), position.getEndOffset()); } public void warn(String message) { markerManager.addWarning(file, message); } public boolean isVerbose() { return true; } public void setFile(IFile file) { this.file = file; } } --- NEW FILE: IRdtWarnings.java --- package org.rubypeople.rdt.internal.core.parser; import org.eclipse.core.resources.IFile; import org.jruby.common.IRubyWarnings; public interface IRdtWarnings extends IRubyWarnings { public void setFile(IFile file); } |