|
From: Christopher W. <caw...@us...> - 2006-03-28 23:15:47
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18128/src/org/rubypeople/rdt/internal/core Modified Files: Openable.java RubyScript.java Log Message: start laying groundwork for the F3/Open action where users can easily navigate from text selections and menus with IRubyElements to the source. Index: RubyScript.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** RubyScript.java 25 Mar 2006 02:27:36 -0000 1.19 --- RubyScript.java 28 Mar 2006 23:15:43 -0000 1.20 *************** *** 41,44 **** --- 41,45 ---- import org.jruby.lexer.yacc.SyntaxException; import org.rubypeople.rdt.core.IBuffer; + import org.rubypeople.rdt.core.ICodeAssist; import org.rubypeople.rdt.core.IImportContainer; import org.rubypeople.rdt.core.IImportDeclaration; *************** *** 633,635 **** --- 634,649 ---- return null; } + + /** + * @see ICodeAssist#codeSelect(int, int) + */ + public IRubyElement[] codeSelect(int offset, int length) throws RubyModelException { + return codeSelect(offset, length, DefaultWorkingCopyOwner.PRIMARY); + } + /** + * @see ICodeAssist#codeSelect(int, int, WorkingCopyOwner) + */ + public IRubyElement[] codeSelect(int offset, int length, WorkingCopyOwner workingCopyOwner) throws RubyModelException { + return super.codeSelect(this, offset, length, workingCopyOwner); + } } \ No newline at end of file Index: Openable.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Openable.java 25 Mar 2006 02:27:36 -0000 1.7 --- Openable.java 28 Mar 2006 23:15:43 -0000 1.8 *************** *** 19,23 **** --- 19,26 ---- import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyModelStatusConstants; + import org.rubypeople.rdt.core.IRubyScript; import org.rubypeople.rdt.core.RubyModelException; + import org.rubypeople.rdt.core.WorkingCopyOwner; + import org.rubypeople.rdt.internal.codeassist.SelectionEngine; import org.rubypeople.rdt.internal.core.buffer.BufferManager; *************** *** 342,344 **** --- 345,361 ---- getElementInfo(pm); } + + protected IRubyElement[] codeSelect(IRubyScript cu, int offset, int length, WorkingCopyOwner owner) throws RubyModelException { + IBuffer buffer = getBuffer(); + if (buffer == null) { + return new IRubyElement[0]; + } + int end= buffer.getLength(); + if (offset < 0 || length < 0 || offset + length > end ) { + throw new RubyModelException(new RubyModelStatus(IRubyModelStatusConstants.INDEX_OUT_OF_BOUNDS)); + } + + SelectionEngine engine = new SelectionEngine(this); + return engine.select(cu, offset, offset + length - 1); + } } |