|
From: <caw...@us...> - 2007-04-20 22:11:46
|
Revision: 2349
http://svn.sourceforge.net/rubyeclipse/?rev=2349&view=rev
Author: cawilliams
Date: 2007-04-20 15:11:45 -0700 (Fri, 20 Apr 2007)
Log Message:
-----------
if we can't parse the file and get and AST, try the last known good AST
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-04-20 22:11:11 UTC (rev 2348)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2007-04-20 22:11:45 UTC (rev 2349)
@@ -20,6 +20,7 @@
import org.jruby.ast.Node;
import org.jruby.ast.VCallNode;
import org.jruby.ast.types.INameNode;
+import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.IMethod;
import org.rubypeople.rdt.core.IParent;
import org.rubypeople.rdt.core.IRubyElement;
@@ -27,6 +28,7 @@
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.RubyScript;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.core.util.ASTUtil;
import org.rubypeople.rdt.internal.core.util.Util;
@@ -40,9 +42,14 @@
public IRubyElement[] select(IRubyScript script, int start, int end)
throws RubyModelException {
String source = script.getSource();
- RubyParser parser = new RubyParser();
- Node root = parser.parse((IFile) script.getResource(),
- new StringReader(source));
+ Node root;
+ try {
+ RubyParser parser = new RubyParser();
+ root = parser.parse((IFile) script.getResource(),
+ new StringReader(source));
+ } catch (SyntaxException e) {
+ root = ((RubyScript)script).lastGoodAST;
+ }
Node selected = OffsetNodeLocator.Instance().getNodeAtOffset(root,
start);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|