You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(41) |
Apr
(9) |
May
|
Jun
|
Jul
(39) |
Aug
(38) |
Sep
(135) |
Oct
(220) |
Nov
(75) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(44) |
Feb
(160) |
Mar
(49) |
Apr
(69) |
May
(40) |
Jun
(52) |
Jul
(47) |
Aug
(51) |
Sep
(19) |
Oct
(22) |
Nov
(36) |
Dec
(76) |
| 2007 |
Jan
(154) |
Feb
(165) |
Mar
(186) |
Apr
(143) |
May
(175) |
Jun
(133) |
Jul
(203) |
Aug
(177) |
Sep
(136) |
Oct
|
Nov
|
Dec
|
|
From: <caw...@us...> - 2006-10-18 00:54:17
|
Revision: 1622
http://svn.sourceforge.net/rubyeclipse/?rev=1622&view=rev
Author: cawilliams
Date: 2006-10-17 17:54:14 -0700 (Tue, 17 Oct 2006)
Log Message:
-----------
don't suggest types or variables when we're sure it's a method we're trying to complete, don't suggest methods that don't begin with the prefix user has typed.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2006-10-13 07:16:27 UTC (rev 1621)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2006-10-18 00:54:14 UTC (rev 1622)
@@ -48,12 +48,14 @@
public class CompletionEngine {
private CompletionRequestor requestor;
+ private String prefix;
public CompletionEngine(CompletionRequestor requestor) {
this.requestor = requestor;
}
public void complete(IRubyScript script, int offset) throws RubyModelException {
+ this.prefix = null;
this.requestor.beginReporting();
if (offset < 0)
offset = 0;
@@ -66,9 +68,12 @@
// inferrer
// if we hit a space, use character after space?
// TODO We need to handle other bad syntax like invoking compeltion right after an @
+ StringBuffer prefix = new StringBuffer();
+ boolean isMethod = false;
for (int i = offset; i >= 0; i--) {
char curChar = (char) source.charAt(i);
if (curChar == '.') {
+ isMethod = true;
if (offset == i) { // if it's the first character we looked at,
// fix syntax
source.deleteCharAt(i);
@@ -76,7 +81,7 @@
break;
}
// TODO Grab the prefix we just ate up and use it to filter
- // responses?
+ // responses?
offset = i - 1;
break;
}
@@ -84,8 +89,10 @@
offset = i + 1;
break;
}
- }
-
+ prefix.insert(0, curChar);
+ }
+ this.prefix = prefix.toString();
+
List<ITypeGuess> guesses = inferrer.infer(source.toString(), offset);
// TODO Grab the project and all referred projects!
IRubyProject[] projects = new IRubyProject[1];
@@ -97,7 +104,7 @@
suggestMethods(replaceStart, completer, guess, type);
}
// FIXME Do we need to call this at all if we know it's a method call we're trying to complete?
- getDocumentsRubyElementsInScope(script, source.toString(), offset, replaceStart);
+ if (!isMethod) getDocumentsRubyElementsInScope(script, source.toString(), offset, replaceStart);
this.requestor.endReporting();
}
@@ -131,6 +138,11 @@
for (int k = 0; k < methods.length; k++) {
IMethod method = methods[k];
String name = method.getElementName();
+
+ if (prefix != null && prefix.length() != 0) {
+ // If we have a prefix, then don't suggest non-matches
+ if (!name.startsWith(prefix)) continue;
+ }
CompletionProposal proposal = new CompletionProposal(
CompletionProposal.METHOD_REF, name, confidence);
// TODO Handle replacement start index correctly
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-10-13 07:16:40
|
Revision: 1621
http://svn.sourceforge.net/rubyeclipse/?rev=1621&view=rev
Author: mbarchfe
Date: 2006-10-13 00:16:27 -0700 (Fri, 13 Oct 2006)
Log Message:
-----------
splittet the communication test suite into a test suite for classic debugger and a test suite for ruby-debug
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTS_Debug.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_ClassicDebuggerCommunicationTest.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_RubyDebugCommunicationTest.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerCommunicationTest.java
Copied: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java (from rev 1611, trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerCommunicationTest.java)
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java 2006-10-13 07:16:27 UTC (rev 1621)
@@ -0,0 +1,971 @@
+package org.rubypeople.rdt.debug.core.tests;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.ConnectException;
+import java.net.Socket;
+
+import junit.framework.TestCase;
+
+import org.rubypeople.rdt.internal.debug.core.ExceptionSuspensionPoint;
+import org.rubypeople.rdt.internal.debug.core.StepSuspensionPoint;
+import org.rubypeople.rdt.internal.debug.core.SuspensionPoint;
+import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
+import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
+import org.rubypeople.rdt.internal.debug.core.model.RubyThread;
+import org.rubypeople.rdt.internal.debug.core.model.RubyVariable;
+import org.rubypeople.rdt.internal.debug.core.model.ThreadInfo;
+import org.rubypeople.rdt.internal.debug.core.parsing.FramesReader;
+import org.rubypeople.rdt.internal.debug.core.parsing.LoadResultReader;
+import org.rubypeople.rdt.internal.debug.core.parsing.MultiReaderStrategy;
+import org.rubypeople.rdt.internal.debug.core.parsing.SuspensionReader;
+import org.rubypeople.rdt.internal.debug.core.parsing.ThreadInfoReader;
+import org.rubypeople.rdt.internal.debug.core.parsing.VariableReader;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+public abstract class FTC_AbstractDebuggerCommunicationTest extends TestCase {
+
+ private static String tmpDir;
+ protected static String getTmpDir() {
+ if (tmpDir == null) {
+ tmpDir = System.getProperty("java.io.tmpdir");
+ if (tmpDir.charAt(tmpDir.length() - 1) != File.separatorChar) {
+ tmpDir = tmpDir + File.separator;
+ }
+ }
+ return tmpDir;
+ }
+ public static String RUBY_INTERPRETER;
+ static {
+ RUBY_INTERPRETER = System.getProperty("rdt.rubyInterpreter");
+ if (RUBY_INTERPRETER == null) {
+ RUBY_INTERPRETER = "ruby";
+ }
+ }
+ private static long TIMEOUT_MS = 20000 ;
+ protected Process process;
+ protected OutputRedirectorThread rubyStdoutRedirectorThread;
+ protected OutputRedirectorThread rubyStderrRedirectorThread;
+ private Socket socket;
+ private PrintWriter out;
+ private MultiReaderStrategy multiReaderStrategy;
+
+ // for timeout handling
+ private Thread mainThread ;
+ private Thread timeoutThread ;
+
+ public FTC_AbstractDebuggerCommunicationTest(String arg0) {
+ super(arg0);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(FTC_ClassicDebuggerCommunicationTest.class);
+ }
+
+ protected String getTestFilename() {
+ return getTmpDir() + "test.rb";
+ }
+
+ protected String getRubyTestFilename() {
+ return getTestFilename().replace('\\', '/');
+ }
+
+ protected XmlPullParser getXpp(Socket socket) throws Exception {
+
+ XmlPullParserFactory factory = XmlPullParserFactory.newInstance("org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer", null);
+ XmlPullParser xpp = factory.newPullParser();
+ xpp.setInput(new BufferedReader(new InputStreamReader(socket.getInputStream())));
+ return xpp;
+ }
+
+ protected SuspensionReader getSuspensionReader() throws Exception {
+ return new SuspensionReader(multiReaderStrategy);
+ }
+
+ protected VariableReader getVariableReader() throws Exception {
+ return new VariableReader(multiReaderStrategy);
+ }
+
+ protected FramesReader getFramesReader() throws Exception {
+ return new FramesReader(multiReaderStrategy);
+ }
+
+ protected ThreadInfoReader getThreadInfoReader() throws Exception {
+ return new ThreadInfoReader(multiReaderStrategy);
+ }
+
+ protected LoadResultReader getLoadResultReader() throws Exception {
+ return new LoadResultReader(multiReaderStrategy) ;
+ }
+
+ protected String getOSIndependent(String path) {
+ return path.replace('\\', '/');
+ }
+
+ public void setUp() throws Exception {
+ if (!new File(getTmpDir()).exists() || !new File(getTmpDir()).isDirectory()) {
+ throw new RuntimeException("Temp directory does not exist: " + getTmpDir());
+ }
+ // if a reader hangs, because the expected data from the ruby process
+ // does not arrive, it gets interrupted from the timeout watchdog.
+ mainThread = Thread.currentThread() ;
+ timeoutThread = new Thread() {
+ public void run() {
+ try {
+ while (true) {
+ System.out.println("Starting timeout watchdog.");
+ Thread.sleep(TIMEOUT_MS);
+ System.out.println("Timeout reached.");
+ mainThread.interrupt();
+ }
+ } catch (InterruptedException e) {
+ System.out.println("Watchdog deactivated.");
+ }
+ }
+ } ;
+ timeoutThread.start() ;
+ }
+
+ public void tearDown() throws Exception {
+ timeoutThread.interrupt() ;
+ if (process == null || socket == null) {
+ // here we go it there was an error in the creation of the process (process == null)
+ // or there was an error creating the socket, e.g. ruby process has died early
+ return ;
+ }
+ Thread.sleep(1000);
+ socket.close();
+ try {
+ if (process.exitValue() != 0) {
+ System.out.println("Ruby finished with exit value: " + process.exitValue());
+ }
+ } catch (IllegalThreadStateException ex) {
+ process.destroy();
+ System.out.println("Ruby process had to be destroyed.");
+ // wait so that the debugger port will be availabel for the next test
+ // There seems to be a delay after the destroying of a process and
+ // freeing the server port
+ Thread.sleep(5000) ;
+ }
+
+ System.out.println("Waiting for stdout redirector thread..");
+ rubyStdoutRedirectorThread.join();
+ System.out.println("..done");
+ System.out.println("Waiting for stderr redirector thread..");
+ rubyStderrRedirectorThread.join();
+ System.out.println("..done");
+ }
+
+ private void writeFile(String name, String[] content) throws Exception {
+ PrintWriter writer = new PrintWriter(new FileOutputStream(getTmpDir() + name));
+ for (int i = 0; i < content.length; i++) {
+ writer.println(content[i]);
+ }
+ writer.close();
+ }
+
+ private void createSocket(String[] lines) throws Exception {
+ writeFile("test.rb", lines);
+ startRubyProcess();
+ Thread.sleep(500) ;
+ try {
+ socket = new Socket("localhost", 1098);
+ } catch (ConnectException cex) {
+ throw new RuntimeException("Ruby process finished prematurely. Last line in stderr: " + rubyStderrRedirectorThread.getLastLine(), cex) ;
+ }
+ multiReaderStrategy = new MultiReaderStrategy(getXpp(socket));
+ out = new PrintWriter(socket.getOutputStream(), true);
+ }
+
+ protected abstract void startRubyProcess() throws Exception;
+
+ private void sendRuby(String debuggerCommand) {
+ try {
+ process.exitValue() ;
+ throw new RuntimeException("Ruby debugger has finished prematurely.") ;
+ } catch (IllegalThreadStateException ex) {
+ // not yet finished, normal behaviour
+ // why does process does not have a function like isRunning() ?
+ System.out.println("Sending: " + debuggerCommand) ;
+ out.println(debuggerCommand);
+ }
+ }
+
+ public void testNameError() throws Exception {
+ createSocket(new String[] { "puts 'x'" });
+ sendRuby("cont");
+ SuspensionPoint hit = getSuspensionReader().readSuspension();
+ // TODO: assertion is wrong, I want the debugger to suspend here
+ // but there must be several catchpoints available
+ assertNull(hit);
+ }
+
+ public void testBreakpointOnFirstLine() throws Exception {
+ // Breakpoint in line 1 does not work yet.
+ createSocket(new String[] { "puts 'a'" });
+ sendRuby("b test.rb:1");
+ sendRuby("cont");
+ System.out.println("Waiting for breakpoint..");
+ SuspensionPoint hit = getSuspensionReader().readSuspension();
+ assertNotNull(hit);
+ assertTrue(hit.isBreakpoint());
+ assertEquals(1, hit.getLine());
+ }
+
+ public void testBreakpointAddAndRemove() throws Exception {
+ // Breakpoint in line 1 does not work yet.
+ createSocket(new String[] { "puts 'a'", "puts 'a'", "puts 'a'" });
+ sendRuby("b test.rb:2");
+ sendRuby("b test.rb:3");
+ sendRuby("cont");
+ System.out.println("Waiting for breakpoint..");
+ SuspensionPoint hit = getSuspensionReader().readSuspension();
+ assertNotNull(hit);
+ assertTrue(hit.isBreakpoint());
+ assertEquals(2, hit.getLine());
+ assertEquals("test.rb", hit.getFile());
+ sendRuby("b remove test.rb:3");
+ sendRuby("cont");
+ hit = getSuspensionReader().readSuspension();
+ assertNull(hit);
+ }
+
+ public void testException() throws Exception {
+ // per default catch is set to StandardError, i.e. every raise of a subclass of StandardError
+ // will suspend
+ createSocket(new String[] { "puts 'a'", "raise 'message \\dir\\file: <xml/>\n<8>'", "puts 'c'" });
+ sendRuby("catch StandardError");
+ sendRuby("cont");
+ System.out.println("Waiting for exception");
+ SuspensionPoint hit = getSuspensionReader().readSuspension();
+ assertNotNull(hit);
+ assertEquals(3, hit.getLine());
+ assertEquals(getOSIndependent(getTmpDir() + "test.rb"), hit.getFile());
+ assertTrue(hit.isException());
+ assertEquals("message \\dir\\file: <xml/> <8>", ((ExceptionSuspensionPoint) hit).getExceptionMessage());
+ assertEquals("RuntimeError", ((ExceptionSuspensionPoint) hit).getExceptionType());
+ sendRuby("catch off");
+ sendRuby("cont");
+ }
+
+ public void testIgnoreException() throws Exception {
+ createSocket(new String[] { "puts 'a'", "raise 'dont stop'" });
+ sendRuby("catch off");
+ sendRuby("cont");
+ System.out.println("Waiting for the program to finish without suspending at the raise command");
+ SuspensionPoint hit = getSuspensionReader().readSuspension();
+ assertNull(hit);
+ }
+
+ public void testExceptionsIgnoredByDefault() throws Exception {
+ createSocket(new String[] { "puts 'a'", "raise 'dont stop'" });
+ sendRuby("cont");
+ System.out.println("Waiting for the program to finish without suspending at the raise command");
+ SuspensionPoint hit = getSuspensionReader().readSuspension();
+ assertNull(hit);
+ }
+
+ public void testExceptionHierarchy() throws Exception {
+ createSocket(new String[] { "class MyError < StandardError", "end", "begin", "raise StandardError.new", "rescue", "end", "raise MyError.new"});
+ sendRuby("catch MyError");
+ sendRuby("cont");
+ System.out.println("Waiting for the program to finish without suspending at the raise command");
+ SuspensionPoint hit = getSuspensionReader().readSuspension();
+ assertNotNull(hit);
+ assertEquals(7, hit.getLine());
+ assertEquals("MyError", ((ExceptionSuspensionPoint) hit).getExceptionType());
+ sendRuby("cont");
+ hit = getSuspensionReader().readSuspension();
+ assertNull(hit);
+ }
+
+ public void testBreakpointNeverReached() throws Exception {
+ createSocket(new String[] { "puts 'a'", "puts 'b'", "puts 'c'" });
+ sendRuby("b test.rb:10");
+ sendRuby("cont");
+ System.out.println("Waiting for breakpoint..");
+ SuspensionPoint hit = getSuspensionReader().readSuspension();
+ assertNull(hit);
+ }
+
+ public void testStepOver() throws Exception {
+ createSocket(new String[] { "puts 'a'", "puts 'b'", "puts 'c'" });
+ sendRuby("b test.rb:2");
+ sendRuby("cont");
+ getSuspensionReader().readSuspension();
+ sendRuby("next");
+ SuspensionPoint info = getSuspensionReader().readSuspension();
+ assertEquals(3, info.getLine());
+ assertEquals(getOSIndependent(getTmpDir() + "test.rb"), info.getFile());
+ assertTrue(info.isStep());
+ assertEquals(1, ((StepSuspensionPoint) info).getFramesNumber());
+ sendRuby("next");
+ info = getSuspensionReader().readSuspension();
+ assertNull(info);
+ }
+
+ public void testStepOverFrames() throws Exception {
+ createSocket(new String[] { "require 'test2.rb'", "puts 'a'", "Test2.new.print()" });
+ writeFile("test2.rb", new String[] { "class Test2", "def print", "puts 'XX'", "end", "end" });
+ sendRuby("b test.rb:3");
+ sendRuby("cont");
+ getSuspensionReader().readSuspension();
+ sendRuby("next");
+ SuspensionPoint info = getSuspensionReader().readSuspension();
+ assertNull(info);
+ }
+
+ public void testStepOverFramesValue2() throws Exception {
+ createSocket(new String[] { "require 'test2.rb'", "puts 'a'", "Test2.new.print()" });
+ writeFile("test2.rb", new String[] { "class Test2", "def print", "puts 'XX'", "puts 'XX'", "end", "end" });
+ runTo("test2.rb", 3);
+ sendRuby("next");
+ SuspensionPoint info = getSuspensionReader().readSuspension();
+ assertEquals(4, info.getLine());
+ assertEquals(getOSIndependent(getTmpDir() + "test2.rb"), info.getFile());
+ assertTrue(info.isStep());
+ assertEquals(2, ((StepSuspensionPoint) info).getFramesNumber());
+ sendRuby("next");
+ info = getSuspensionReader().readSuspension();
+ assertNull(info);
+ }
+
+ public void testStepOverInDifferentFrame() throws Exception {
+ createSocket(new String[] { "require 'test2.rb'", "Test2.new.print()", "puts 'a'" });
+ writeFile("test2.rb", new String[] { "class Test2", "def print", "puts 'XX'", "puts 'XX'", "end", "end" });
+ runTo("test2.rb", 4);
+ sendRuby("next");
+ SuspensionPoint info = getSuspensionReader().readSuspension();
+ assertEquals(3, info.getLine());
+ assertEquals(getOSIndependent(getTmpDir() + "test.rb"), info.getFile());
+ assertTrue(info.isStep());
+ assertEquals(1, ((StepSuspensionPoint) info).getFramesNumber());
+ sendRuby("cont");
+ }
+
+ public void testStepReturn() throws Exception {
+ createSocket(new String[] { "require 'test2.rb'", "Test2.new.print()", "puts 'a'" });
+ writeFile("test2.rb", new String[] { "class Test2", "def print", "puts 'XX'", "puts 'XX'", "end", "end" });
+ runTo("test2.rb", 4);
+ sendRuby("next");
+ SuspensionPoint info = getSuspensionReader().readSuspension();
+ assertEquals(3, info.getLine());
+ assertEquals(getOSIndependent(getTmpDir() + "test.rb"), info.getFile());
+ assertTrue(info.isStep());
+ assertEquals(1, ((StepSuspensionPoint) info).getFramesNumber());
+ sendRuby("cont");
+ }
+
+ public void testHitBreakpointWhileSteppingOver() throws Exception {
+ createSocket(new String[] { "require 'test2.rb'", "Test2.new.print()", "puts 'a'" });
+ writeFile("test2.rb", new String[] { "class Test2", "def print", "puts 'XX'", "puts 'XX'", "end", "end" });
+ sendRuby("b test2.rb:4");
+ runTo("test.rb", 2);
+ sendRuby("next");
+ SuspensionPoint info = getSuspensionReader().readSuspension();
+ assertEquals(4, info.getLine());
+ assertEquals("test2.rb", info.getFile());
+ assertTrue(info.isBreakpoint());
+ sendRuby("cont");
+ }
+
+ public void testStepInto() throws Exception {
+ createSocket(new String[] { "require 'test2.rb'", "puts 'a'", "Test2.new.print()" });
+ writeFile("test2.rb", new String[] { "class Test2", "def print", "puts 'XX'", "puts 'XX'", "end", "end" });
+ runTo("test.rb", 3);
+ sendRuby("step");
+ SuspensionPoint info = getSuspensionReader().readSuspension();
+ assertEquals(3, info.getLine());
+ assertEquals(getOSIndependent(getTmpDir() + "test2.rb"), info.getFile());
+ assertTrue(info.isStep());
+ assertEquals(2, ((StepSuspensionPoint) info).getFramesNumber());
+ sendRuby("cont");
+ }
+
+ private void runToLine(int lineNumber) throws Exception {
+ runTo("test.rb", lineNumber);
+ }
+
+ private void runTo(String filename, int lineNumber) throws Exception {
+ sendRuby("b " + filename + ":" + lineNumber);
+ sendRuby("cont");
+ SuspensionPoint suspension = getSuspensionReader().readSuspension();
+ if (suspension == null) {
+ throw new RuntimeException("Expected suspension, but program exited.");
+ }
+ }
+
+ protected RubyStackFrame createStackFrame() throws Exception {
+ RubyStackFrame stackFrame = new RubyStackFrame(null, "", 5, 1); //RubyThread thread = new RubyThread(null) ;
+ //thread.addStackFrame(stackFrame) ;
+ return stackFrame;
+ }
+
+ public void testVariableNil() throws Exception {
+ createSocket(new String[] { "puts 'a'", "puts 'b'", "stringA='XX'" });
+ runToLine(2);
+ sendRuby("v l");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("stringA", variables[0].getName());
+ assertEquals("nil", variables[0].getValue().getValueString());
+ assertEquals(null, variables[0].getValue().getReferenceTypeName());
+ assertTrue(!variables[0].getValue().hasVariables());
+ }
+
+ public void testVariableWithXmlContent() throws Exception {
+ createSocket(new String[] { "stringA='<start test=\"&\"/>'", "testHashValue=Hash[ '$&' => nil]", "puts 'b'" });
+ runToLine(3);
+ sendRuby("v l");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(2, variables.length);
+ assertEquals("stringA", variables[0].getName());
+ assertEquals("<start test=\"&\"/>", variables[0].getValue().getValueString());
+ assertTrue(variables[0].isLocal()) ;
+ // the testHashValue contains an example, where the name consists of special characters
+ sendRuby("v i testHashValue");
+ variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("'$&'", variables[0].getName());
+
+
+ }
+
+ public void testVariablesInObject() throws Exception {
+ createSocket(new String[] { "class Test", "def initialize", "@y=5", "puts @y", "end", "def to_s", "'test'", "end", "end", "Test.new()" });
+ runTo("test.rb", 4);
+ // Read numerical variable
+ sendRuby("v l");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("self", variables[0].getName());
+ assertEquals("test", variables[0].getValue().getValueString());
+ assertEquals("Test", variables[0].getValue().getReferenceTypeName());
+ assertTrue(variables[0].getValue().hasVariables());
+ sendRuby("v i self");
+ variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("@y", variables[0].getName());
+ assertEquals("5", variables[0].getValue().getValueString());
+ assertEquals("Fixnum", variables[0].getValue().getReferenceTypeName());
+ assertTrue(!variables[0].isStatic()) ;
+ assertTrue(!variables[0].isLocal()) ;
+ assertTrue(variables[0].isInstance()) ;
+ assertTrue(!variables[0].getValue().hasVariables());
+ sendRuby("cont");
+ }
+
+ public void testStaticVariables() throws Exception {
+ createSocket(new String[] { "class Test", "@@staticVar=55", "def method", "puts 'a'", "end", "end", "test=Test.new()", "test.method()" });
+ runTo("test.rb", 4);
+ sendRuby("v l") ;
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("self", variables[0].getName());
+ assertTrue(variables[0].getValue().hasVariables());
+ sendRuby("v i self");
+ variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("@@staticVar", variables[0].getName());
+ assertEquals("55", variables[0].getValue().getValueString());
+ assertEquals("Fixnum", variables[0].getValue().getReferenceTypeName());
+ assertTrue(variables[0].isStatic()) ;
+ assertTrue(!variables[0].isLocal()) ;
+ assertTrue(!variables[0].isInstance()) ;
+ assertTrue(!variables[0].getValue().hasVariables());
+ sendRuby("cont");
+ }
+
+ public void testSingletonStaticVariables() throws Exception {
+ createSocket(new String[] { "class Test", "def method", "puts 'a'", "end", "class << Test", "@@staticVar=55", "end", "end", "Test.new().method()" });
+ runTo("test.rb", 3);
+ sendRuby("v i self");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("@@staticVar", variables[0].getName());
+ assertEquals("55", variables[0].getValue().getValueString());
+ assertEquals("Fixnum", variables[0].getValue().getReferenceTypeName());
+ assertTrue(variables[0].isStatic()) ;
+ assertTrue(!variables[0].isLocal()) ;
+ assertTrue(!variables[0].isInstance()) ;
+ assertTrue(!variables[0].getValue().hasVariables());
+ sendRuby("cont");
+ }
+
+
+ public void testConstants() throws Exception {
+ createSocket(new String[] { "class Test", "TestConstant=5", "end", "test=Test.new()", "puts 'a'" });
+ runTo("test.rb", 5);
+ sendRuby("v i test");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("TestConstant", variables[0].getName());
+ assertEquals("5", variables[0].getValue().getValueString());
+ assertEquals("Fixnum", variables[0].getValue().getReferenceTypeName());
+ assertTrue(variables[0].isConstant()) ;
+ assertTrue(!variables[0].isStatic()) ;
+ assertTrue(!variables[0].isLocal()) ;
+ assertTrue(!variables[0].isInstance()) ;
+ assertTrue(!variables[0].getValue().hasVariables());
+ sendRuby("cont");
+ }
+
+
+ public void testConstantDefinedInBothClassAndSuperclass() throws Exception {
+ createSocket(new String[] { "class A", "TestConstant=5", "TestConstant2=2", "end", "class B < A", "TestConstant=6", "end", "b=B.new()", "puts 'a'" });
+ runTo("test.rb", 9);
+ sendRuby("v i b");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("TestConstant", variables[0].getName());
+ assertEquals("6", variables[0].getValue().getValueString());
+ assertEquals("Fixnum", variables[0].getValue().getReferenceTypeName());
+ assertTrue(variables[0].isConstant()) ;
+ assertTrue(!variables[0].isStatic()) ;
+ assertTrue(!variables[0].isLocal()) ;
+ assertTrue(!variables[0].isInstance()) ;
+ assertTrue(!variables[0].getValue().hasVariables());
+ sendRuby("cont");
+ }
+
+
+ public void testVariableString() throws Exception {
+ createSocket(new String[] { "stringA='XX'", "puts stringA" });
+ runToLine(2);
+ // Read numerical variable
+ sendRuby("v l");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("stringA", variables[0].getName());
+ assertEquals("XX", variables[0].getValue().getValueString());
+ assertEquals("String", variables[0].getValue().getReferenceTypeName());
+ assertTrue(!variables[0].getValue().hasVariables());
+ sendRuby("cont");
+ }
+
+ public void testVariableLocal() throws Exception {
+ createSocket(new String[] { "class User", "def initialize(id)", "@id=id", "end", "end",
+ "class CallClass", "def method(user)", "puts user", "end", "end",
+ "CallClass.new.method(User.new(22))" }) ;
+ runTo("test.rb", 8);
+ sendRuby("v local") ;
+ RubyVariable[] localVariables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(2, localVariables.length);
+ RubyVariable userVariable = localVariables[1] ;
+ //sendRuby("v i 1 " + userVariable.getObjectId());
+ sendRuby("v i " + userVariable.getObjectId());
+ RubyVariable[] userVariables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, userVariables.length);
+ assertEquals("@id", userVariables[0].getName());
+ assertEquals("22", userVariables[0].getValue().getValueString());
+ assertEquals("Fixnum", userVariables[0].getValue().getReferenceTypeName());
+ assertTrue(!userVariables[0].getValue().hasVariables());
+ }
+
+ public void testVariableInstance() throws Exception {
+ createSocket(new String[] { "require 'test2.rb'", "customObject=Test2.new", "puts customObject" });
+ writeFile("test2.rb", new String[] { "class Test2", "def initialize", "@y=5", "end", "def to_s", "'test'", "end", "end" });
+ runTo("test2.rb", 6);
+ sendRuby("v i 2 customObject");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("@y", variables[0].getName());
+ assertEquals("5", variables[0].getValue().getValueString());
+ assertEquals("Fixnum", variables[0].getValue().getReferenceTypeName());
+ assertTrue(!variables[0].getValue().hasVariables());
+ }
+
+ public void testVariableArray() throws Exception {
+ createSocket(new String[] { "array = []", "array << 1", "array << 2", "puts 'a'" });
+ runTo("test.rb", 4);
+ sendRuby("v local") ;
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("array", variables[0].getName());
+ assertTrue("array has children", variables[0].getValue().hasVariables());
+ sendRuby("v i array");
+ RubyVariable[] elements = getVariableReader().readVariables(variables[0]);
+ assertEquals(2, elements.length);
+ assertEquals("[0]", elements[0].getName());
+ assertEquals("1", elements[0].getValue().getValueString());
+ assertEquals("Fixnum", elements[0].getValue().getReferenceTypeName());
+ assertEquals("array[0]", elements[0].getQualifiedName()) ;
+ }
+
+ public void testVariableHashWithStringKeys() throws Exception {
+ createSocket(new String[] { "hash = Hash['a' => 'z', 'b' => 'y']", "puts 'a'" });
+ runTo("test.rb", 2);
+ sendRuby("v local") ;
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("hash", variables[0].getName());
+ assertTrue("hash has children", variables[0].getValue().hasVariables());
+ sendRuby("v i hash");
+ RubyVariable[] elements = getVariableReader().readVariables(variables[0]);
+ assertEquals(2, elements.length);
+ assertEquals("'a'", elements[0].getName());
+ assertEquals("z", elements[0].getValue().getValueString());
+ assertEquals("String", elements[0].getValue().getReferenceTypeName());
+ assertEquals("hash['a']", elements[0].getQualifiedName()) ;
+ }
+
+ public void testVariableHashWithObjectKeys() throws Exception {
+ createSocket(new String[] { "class KeyAndValue", "def initialize(v)", "@a=v", "end", "def to_s", "return @a.to_s", "end", "end", "hash = Hash[KeyAndValue.new(55) => KeyAndValue.new(66)]", "puts 'a'" });
+ runTo("test.rb", 10);
+ sendRuby("v local") ;
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("hash", variables[0].getName());
+ assertTrue("hash has children", variables[0].getValue().hasVariables());
+ sendRuby("v i 1 " + variables[0].getObjectId());
+ RubyVariable[] elements = getVariableReader().readVariables(variables[0]);
+ assertEquals(1, elements.length);
+ assertEquals("55", elements[0].getName());
+ //assertEquals("z", elements[0].getValue().getValueString());
+ assertEquals("KeyAndValue", elements[0].getValue().getReferenceTypeName());
+ // get the value
+ sendRuby("v i 1 " + elements[0].getObjectId()) ;
+ RubyVariable[] values = getVariableReader().readVariables(variables[0]);
+ assertEquals(1, values.length);
+ assertEquals("@a", values[0].getName());
+ assertEquals("Fixnum", values[0].getValue().getReferenceTypeName());
+ assertEquals("66", values[0].getValue().getValueString());
+
+ }
+
+
+ public void testVariableArrayEmpty() throws Exception {
+ createSocket(new String[] { "emptyArray = []", "puts 'a'" });
+ runTo("test.rb", 2);
+ sendRuby("v local") ;
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("emptyArray", variables[0].getName());
+ assertTrue("array does not have children", !variables[0].getValue().hasVariables());
+ }
+
+
+ public void testVariableInstanceNested() throws Exception {
+ createSocket(new String[] { "class Test", "def initialize(test)", "@privateTest = test", "end", "end", "test2 = Test.new(Test.new(nil))", "puts test2" });
+ runToLine(7);
+ sendRuby("v l");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ RubyVariable test2Variable = variables[0];
+ assertEquals("test2", test2Variable.getName());
+ assertEquals("test2", test2Variable.getQualifiedName());
+ sendRuby("v i " + test2Variable.getQualifiedName());
+ variables = getVariableReader().readVariables(test2Variable);
+ assertEquals(1, variables.length);
+ RubyVariable privateTestVariable = variables[0];
+ assertEquals("@privateTest", privateTestVariable.getName());
+ assertEquals("test2.@privateTest", privateTestVariable.getQualifiedName());
+ assertTrue(privateTestVariable.getValue().hasVariables());
+ sendRuby("v i " + privateTestVariable.getQualifiedName());
+ variables = getVariableReader().readVariables(privateTestVariable);
+ assertEquals(1, variables.length);
+ RubyVariable privateTestprivateTestVariable = variables[0];
+ assertEquals("@privateTest", privateTestprivateTestVariable.getName());
+ assertEquals("test2.@privateTest.@privateTest", privateTestprivateTestVariable.getQualifiedName());
+ assertEquals("nil", privateTestprivateTestVariable.getValue().getValueString());
+ assertTrue(!privateTestprivateTestVariable.getValue().hasVariables());
+ sendRuby("cont");
+ }
+
+ public void testInspect() throws Exception {
+ createSocket(new String[] { "class Test", "def calc(a)", "a = a*2", "return a", "end", "end", "test=Test.new()", "a=3", "test.calc(a)" });
+ runToLine(4);
+ // test variable value in stack 1 (top stack frame)
+ sendRuby("v inspect 1 a*2");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals("There is one variable returned.", 1, variables.length) ;
+ assertEquals("Result is 12", "12", variables[0].getValue().getValueString()) ;
+ // test variable value in stack 2 (caller stack)
+ sendRuby("v inspect 2 a*4");
+ variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals("There is one variable returned.", 1, variables.length) ;
+ assertEquals("Result is 12", "12", variables[0].getValue().getValueString()) ;
+ // test more complex expression
+ sendRuby("v inspect 1 Test.new().calc(5)");
+ variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals("There is one variable returned.", 1, variables.length) ;
+ assertEquals("Result is 10", "10", variables[0].getValue().getValueString()) ;
+ }
+
+ public void testInspectError() throws Exception {
+ createSocket(new String[] { "puts 'test'" });
+ runToLine(1);
+ sendRuby("v inspect a*2");
+ try {
+ getVariableReader().readVariables(createStackFrame());
+ } catch (RubyProcessingException e) {
+ assertNotNull(e.getMessage()) ;
+ return ;
+ }
+ fail("RubyProcessingException not thrown.") ;
+ }
+
+ public void testStaticVariableInstanceNested() throws Exception {
+ createSocket(new String[] { "class TestStatic", "def initialize(no)", "@no = no", "end", "@@staticVar=TestStatic.new(2)", "end", "test = TestStatic.new(1)", "puts test" });
+ runToLine(8);
+ sendRuby("v i test.@@staticVar");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(2, variables.length) ;
+ assertEquals("@no", variables[0].getName()) ;
+ assertEquals("2", variables[0].getValue().getValueString()) ;
+ assertEquals("@@staticVar", variables[1].getName()) ;
+ assertTrue("2", variables[1].getValue().hasVariables()) ;
+
+ sendRuby("cont");
+ }
+
+
+ public void testVariablesInFrames() throws Exception {
+ createSocket(new String[] { "require 'test2.rb'", "y=5", "Test2.new().test()" });
+ writeFile("test2.rb", new String[] { "class Test2", "def test", "y=6", "puts y", "end", "end" });
+ runTo("test2.rb", 4);
+ sendRuby("v l");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ // there are 2 variables self and y
+ assertEquals(2, variables.length);
+ // the variables are sorted: self = variables[0], y = variables[1]
+ assertEquals("y", variables[1].getName());
+ assertEquals("6", variables[1].getValue().getValueString());
+ sendRuby("v l 1");
+ variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(2, variables.length);
+ assertEquals("y", variables[1].getName());
+ assertEquals("6", variables[1].getValue().getValueString());
+ sendRuby("v l 2");
+ variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(1, variables.length);
+ assertEquals("y", variables[0].getName());
+ assertEquals("5", variables[0].getValue().getValueString());
+ // 20 is out of range, then the default frame is used, which is 1
+ sendRuby("v l 20");
+ variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals(2, variables.length);
+ assertEquals("y", variables[1].getName());
+ assertEquals("6", variables[1].getValue().getValueString());
+ sendRuby("cont");
+ }
+
+ public void testFrames() throws Exception {
+ createSocket(new String[] { "require 'test2.rb'", "test = Test2.new()", "test.print()", "test.print()" });
+ writeFile("test2.rb", new String[] { "class Test2", "def print", "puts 'Test2.print'", "end", "end" });
+ runTo("test2.rb", 3);
+ sendRuby("b test.rb:4");
+ sendRuby("th 1 ; w");
+ RubyThread thread = new RubyThread(null, 0);
+ getFramesReader().readFrames(thread);
+ assertEquals(2, thread.getStackFrames().length);
+ RubyStackFrame frame1 = (RubyStackFrame) thread.getStackFrames()[0];
+ assertEquals(getOSIndependent(getTmpDir() + "test2.rb"), frame1.getFileName());
+ assertEquals(1, frame1.getIndex());
+ assertEquals(3, frame1.getLineNumber());
+ RubyStackFrame frame2 = (RubyStackFrame) thread.getStackFrames()[1];
+ assertEquals(getOSIndependent(getTmpDir() + "test.rb"), frame2.getFileName());
+ assertEquals(2, frame2.getIndex());
+ assertEquals(3, frame2.getLineNumber());
+ sendRuby("cont");
+ getSuspensionReader().readSuspension();
+ sendRuby("w");
+ getFramesReader().readFrames(thread);
+ assertEquals(1, thread.getStackFramesSize());
+
+ }
+
+ public void testFramesWhenThreadSpawned() throws Exception {
+ createSocket(new String[] { "def startThread", "Thread.new() { a = 5 }", "end", "def calc", "5 + 5", "end", "startThread()", "calc()" });
+ runTo("test.rb", 5);
+ RubyThread thread = new RubyThread(null, 0);
+ sendRuby("f");
+ getFramesReader().readFrames(thread);
+ assertEquals(2, thread.getStackFramesSize());
+ }
+
+ public void testThreads() throws Exception {
+ createSocket(new String[] { "Thread.new {", "puts 'a'", "}", "Thread.pass", "puts 'b'" });
+ sendRuby("b test.rb:2");
+ sendRuby("b test.rb:5");
+ sendRuby("cont");
+ SuspensionPoint point1 = getSuspensionReader().readSuspension();
+ sendRuby("th l") ;
+ ThreadInfo[] threadInfos = getThreadInfoReader().readThreads() ;
+ assertEquals(2, threadInfos.length) ;
+ sendRuby("cont");
+ SuspensionPoint point2 = getSuspensionReader().readSuspension();
+ sendRuby("th l") ;
+ threadInfos = getThreadInfoReader().readThreads() ;
+ assertEquals(1, threadInfos.length) ;
+ assertNotSame(point1.getThreadId(), point2.getThreadId()) ;
+ sendRuby("cont");
+ }
+
+ public void testThreadIdsAndResume() throws Exception {
+ createSocket(new String[] { "threads=[]", "threads << Thread.new {", "puts 'a'", "}", "threads << Thread.new{", "puts 'b'", "}", "puts 'c'", "threads.each{|t| t.join()}" });
+ sendRuby("b test.rb:3");
+ sendRuby("b test.rb:6");
+ sendRuby("b test.rb:8");
+ sendRuby("cont");
+ getSuspensionReader().readSuspension();
+ getSuspensionReader().readSuspension();
+ getSuspensionReader().readSuspension();
+
+ sendRuby("th l");
+ ThreadInfo[] threads = getThreadInfoReader().readThreads();
+ assertEquals(3, threads.length);
+ int threadId1 = threads[0].getId();
+ int threadId2 = threads[1].getId();
+ int threadId3 = threads[2].getId();
+ sendRuby("th " + threadId2 + " ; cont");
+
+ sendRuby("th l");
+ threads = getThreadInfoReader().readThreads();
+ assertEquals(2, threads.length);
+ assertEquals(threadId1, threads[0].getId());
+ assertEquals(threadId3, threads[1].getId());
+ sendRuby("th " + threadId3 + " ; cont");
+
+ sendRuby("th l");
+ threads = getThreadInfoReader().readThreads();
+ assertEquals(1, threads.length);
+ assertEquals(threadId1, threads[0].getId());
+ sendRuby("cont");
+ }
+
+ public void testThreadFramesAndVariables() throws Exception {
+ createSocket(new String[] { "Thread.new {", "a=5", "x=6", "puts 'x'", "}", "b=10", "b=11" });
+ sendRuby("b test.rb:3");
+ sendRuby("b test.rb:7");
+ sendRuby("cont");
+ getSuspensionReader().readSuspension();
+ getSuspensionReader().readSuspension();
+ // the main thread and the "puts 'a'" - thread are active
+ sendRuby("th l");
+ ThreadInfo[] threads = getThreadInfoReader().readThreads();
+ assertEquals(2, threads.length);
+ assertEquals(1, threads[0].getId());
+ assertEquals(2, threads[1].getId());
+ sendRuby("th 1 ; f ");
+ RubyStackFrame[] stackFrames = getFramesReader().readFrames(new RubyThread(null, 1));
+ assertEquals(1, stackFrames.length);
+ assertEquals(7, stackFrames[0].getLineNumber());
+ sendRuby("th 1 ; v l");
+ RubyVariable[] variables = getVariableReader().readVariables(stackFrames[0]);
+ assertEquals(1, variables.length);
+ assertEquals("b", variables[0].getName());
+ sendRuby("th 2 ; f");
+ stackFrames = getFramesReader().readFrames(new RubyThread(null, 1));
+ assertEquals(1, stackFrames.length);
+ assertEquals(3, stackFrames[0].getLineNumber());
+ sendRuby("th 2 ; v l");
+ variables = getVariableReader().readVariables(stackFrames[0]);
+ assertEquals("a", variables[0].getName()) ;
+ assertEquals("b", variables[1].getName()) ;
+ // there is a third variable 'x' for ruby 1.8.0
+ sendRuby("th 2 ; next");
+ getSuspensionReader().readSuspension();
+ sendRuby("th 2 ; v l");
+ variables = getVariableReader().readVariables(stackFrames[0]);
+ assertEquals(3, variables.length) ;
+ assertEquals("a", variables[0].getName()) ;
+ assertEquals("b", variables[1].getName()) ;
+ assertEquals("x", variables[2].getName()) ;
+
+ }
+
+ public void testReloadAndInspect() throws Exception {
+ String[] lines = new String[] { "class Test", "def calc(a)", "a = a*2", "return a", "end", "end", "test=Test.new()" } ;
+ createSocket( lines );
+ runToLine(7);
+ // test variable value in stack 1 (top stack frame)
+ lines[2] = "a=a*4" ;
+ writeFile( "test.rb", lines);
+ sendRuby("load " + getTmpDir() + "test.rb") ;
+ LoadResultReader.LoadResult loadResult = this.getLoadResultReader().readLoadResult() ;
+ assertTrue("No Exception from load", loadResult.isOk()) ;
+ sendRuby("v inspect Test.new.calc(2)");
+ RubyVariable[] variables = getVariableReader().readVariables(createStackFrame());
+ assertEquals("There is one variable returned.", 1, variables.length) ;
+ assertEquals("Result is 8", "8", variables[0].getValue().getValueString()) ;
+ }
+
+ public void testReloadAndStep() throws Exception {
+ String[] lines = new String[] { "puts 'a'", "puts 'b'", "puts 'c'" } ;
+ createSocket( lines );
+ runToLine(2) ;
+ lines = new String[] { "puts 'd'", "puts 'e'", "puts 'f'" } ;
+ writeFile("test.rb", lines) ;
+ sendRuby("load " + getTmpDir() + "test.rb") ;
+ this.getLoadResultReader().readLoadResult() ;
+ sendRuby("next");
+ SuspensionPoint info = getSuspensionReader().readSuspension();
+ assertEquals(3, info.getLine());
+ }
+
+ public void testReloadWithException() throws Exception {
+ createSocket(new String[] { "puts 'a'" }) ;
+ runToLine(1);
+ // test variable value in stack 1 (top stack frame)
+ String[] lines = new String[] { "classs A;end" } ;
+ writeFile( "test.rb", lines);
+
+ sendRuby("load " + getTmpDir() + "test.rb") ;
+ LoadResultReader.LoadResult loadResult = this.getLoadResultReader().readLoadResult() ;
+ assertFalse("Exception from load", loadResult.isOk()) ;
+ assertEquals(loadResult.getExceptionType(), "SyntaxError") ;
+ }
+
+ public void testReloadInRequire() throws Exception {
+ // Deadlock
+ String[] lines = new String[] { "def endless", "sleep 0.1", "end" } ;
+ writeFile( "content file.rb", lines);
+ createSocket(new String[] { "require 'content file'", "while true", "endless()", "end"} );
+ sendRuby("cont") ;
+ // test variable value in stack 1 (top stack frame)
+ lines[1] = "exit 0" ;
+ writeFile( "content file.rb", lines);
+ sendRuby("load " + getTmpDir() + "content file.rb") ;
+ LoadResultReader.LoadResult loadResult = this.getLoadResultReader().readLoadResult() ;
+ assertTrue("No Exception from load", loadResult.isOk()) ;
+ }
+
+
+ public void testReloadInStackFrame() throws Exception {
+ String[] lines = new String[] { "class Test", "def calc(a)", "a = a*2", "return a", "end", "end", "result = Test.new.calc(2)", "result = Test.new.calc(2)", "puts result" } ;
+ createSocket( lines );
+ runToLine(3);
+ // a has not yet been calculated ...
+ sendRuby("v local") ;
+ RubyVariable[] localVariables = getVariableReader().readVariables(createStackFrame());
+ assertEquals("2", localVariables[0].getValue().getValueString());
+ // now change the code ...
+ lines[2] = "a=a*4" ;
+ writeFile( "test.rb", lines);
+ sendRuby("load " + getTmpDir() + "test.rb") ;
+ LoadResultReader.LoadResult loadResult = this.getLoadResultReader().readLoadResult() ;
+ assertTrue("No Exception from load", loadResult.isOk()) ;
+ runToLine(4);
+ // now a is calculated and the result is 4. That means that ruby does not change the code which
+ // currently being executed in a stack frame, Java would have reset the instruction pointer and the
+ // result would be 8
+ sendRuby("v local") ;
+ localVariables = getVariableReader().readVariables(createStackFrame());
+ assertEquals("4", localVariables[0].getValue().getValueString());
+
+ // Now check that the new code is executed with the next call to calc
+ runToLine(3) ;
+ runToLine(4) ;
+ sendRuby("v local") ;
+ localVariables = getVariableReader().readVariables(createStackFrame());
+ assertEquals("8", localVariables[0].getValue().getValueString());
+ }
+
+
+
+}
+
Property changes on: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_ClassicDebuggerCommunicationTest.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_ClassicDebuggerCommunicationTest.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_ClassicDebuggerCommunicationTest.java 2006-10-13 07:16:27 UTC (rev 1621)
@@ -0,0 +1,101 @@
+package org.rubypeople.rdt.debug.core.tests;
+
+import java.io.File;
+
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.launching.RdtLaunchingPlugin;
+
+public class FTC_ClassicDebuggerCommunicationTest extends
+ FTC_AbstractDebuggerCommunicationTest {
+ public static junit.framework.TestSuite suite() {
+
+ junit.framework.TestSuite suite = new junit.framework.TestSuite();
+ //suite.addTest(new FTC_DebuggerCommunicationTest("testBreakpointOnFirstLine"));
+ //suite.addTest(new FTC_DebuggerCommunicationTest("testBreakpointAddAndRemove"));
+// suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testVariableLocal"));
+// suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testVariableArray"));
+// suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testVariableArrayEmpty"));
+// suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testVariableHash"));
+// suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testVariableHashWithObjectKeys"));
+// suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testVariableHashWithStringKeys"));
+// suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testVariableWithXmlContent"));
+// suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testThreadIdsAndResume"));
+// suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testThreadFramesAndVariables"));
+ suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testFrames"));
+ suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testThreads"));
+
+
+
+
+ //suite.addTest(new TC_DebuggerCommunicationTest("testConstants"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testConstantDefinedInBothClassAndSuperclass"));
+
+ //suite.addTest(new TC_DebuggerCommunicationTest("testVariablesInFrames"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testFramesWhenThreadSpawned"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testThreadIdsAndResume"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testThreadsAndFrames"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testStepOver"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testVariableNil"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testVariableInstanceNested"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testStaticVariableInstanceNested"));
+
+ //suite.addTest(new TC_DebuggerCommunicationTest("testNameError"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testVariablesInObject"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testStaticVariables"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testSingletonStaticVariables"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testVariableString"));
+ // suite.addTest(new TC_DebuggerCommunicationTest("testInspect"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testInspectError"));
+ //suite.addTest(new TC_DebuggerCommunicationTest("testReloadAndInspect")) ;
+ //suite.addTest(new TC_DebuggerCommunicationTest("testReloadWithException")) ;
+ //suite.addTest(new TC_DebuggerCommunicationTest("testReloadAndStep")) ;
+ //suite.addTest(new TC_DebuggerCommunicationTest("testReloadInRequire")) ;
+ //suite.addTest(new TC_DebuggerCommunicationTest("testReloadInStackFrame")) ;
+// suite.addTest(new TC_DebuggerCommunicationTest("testIgnoreException"));
+// suite.addTest(new TC_DebuggerCommunicationTest("testExceptionHierarchy"));
+// suite.addTest(new TC_DebuggerCommunicationTest("testException"));
+
+ return suite;
+ }
+
+ public FTC_ClassicDebuggerCommunicationTest(String arg0) {
+ super(arg0);
+ }
+
+ public void startRubyProcess() throws Exception {
+ String cmd = FTC_ClassicDebuggerCommunicationTest.RUBY_INTERPRETER + " -I" + createIncludeDir() + " -I" + getTmpDir().replace('\\', '/') + " -reclipseDebugVerbose.rb " + getRubyTestFilename();
+ System.out.println("Starting: " + cmd);
+ process = Runtime.getRuntime().exec(cmd);
+ rubyStderrRedirectorThread = new OutputRedirectorThread(process.getErrorStream());
+ rubyStderrRedirectorThread.start();
+ rubyStdoutRedirectorThread = new OutputRedirectorThread(process.getInputStream());
+ rubyStdoutRedirectorThread.start();
+
+ }
+
+ private String createIncludeDir() {
+ String includeDir;
+ if (RdtLaunchingPlugin.getDefault() != null) {
+ // being run as JUnit Plug-in Test, Eclipse is running
+ includeDir = RubyCore.getOSDirectory(RdtLaunchingPlugin.getDefault()) + "ruby" ;
+ }
+ else {
+ // being run as "pure" JUnit Test without Eclipse running
+ // getResource delivers a URL, so we get slashes as Fileseparator
+ includeDir = getClass().getResource("/").getFile();
+ includeDir += "../../org.rubypeople.rdt.launching/ruby" ;
+ // if on windows, remove a leading slash
+ if (includeDir.startsWith("/") && File.separatorChar == '\\') {
+ includeDir = includeDir.substring(1);
+ }
+ }
+ // the ruby interpreter on linux does not like quotes, so we use them only if really necessary
+ if (includeDir.indexOf(" ") == -1) {
+ return includeDir ;
+ }
+ else {
+ return '"' + includeDir + '"';
+ }
+ }
+
+}
Deleted: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerCommunicationTest.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerCommunicationTest.java 2006-10-08 13:33:12 UTC (rev 1620)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerCommunicationTest.java 2006-10-13 07:16:27 UTC (rev 1621)
@@ -1,1050 +0,0 @@
-package org.rubypeople.rdt.debug.core.tests;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.net.ConnectException;
-import java.net.Socket;
-
-import junit.framework.TestCase;
-
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.internal.debug.core.ExceptionSuspensionPoint;
-import org.rubypeople.rdt.internal.debug.core.StepSuspensionPoint;
-import org.rubypeople.rdt.internal.debug.core.SuspensionPoint;
-import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
-import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
-import org.rubypeople.rdt.internal.debug.core.model.RubyThread;
-import org.rubypeople.rdt.internal.debug.core.model.RubyVariable;
-import org.rubypeople.rdt.internal.debug.core.model.ThreadInfo;
-import org.rubypeople.rdt.internal.debug.core.parsing.FramesReader;
-import org.rubypeople.rdt.internal.debug.core.parsing.LoadResultReader;
-import org.rubypeople.rdt.internal.debug.core.parsing.MultiReaderStrategy;
-import org.rubypeople.rdt.internal.debug.core.parsing.SuspensionReader;
-import org.rubypeople.rdt.internal.debug.core.parsing.ThreadInfoReader;
-import org.rubypeople.rdt.internal.debug.core.parsing.VariableReader;
-import org.rubypeople.rdt.internal.launching.RdtLaunchingPlugin;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-public class FTC_DebuggerCommunicationTest extends TestCase {
-
-/*
- public static junit.framework.TestSuite suite() {
-
- junit.framework.TestSuite suite = new junit.framework.TestSuite();
- //suite.addTest(new TC_DebuggerCommunicationTest("testConstants"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testConstantDefinedInBothClassAndSuperclass"));
-
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariablesInFrames"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testBreakpoint"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testFramesWhenThreadSpawned"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testThreadIdsAndResume"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testThreadsAndFrames"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testStepOver"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testThreadFramesAndVariables"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableNil"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableInstanceNested"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testStaticVariableInstanceNested"));
-
- //suite.addTest(new TC_DebuggerCommunicationTest("testNameError"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariablesInObject"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testStaticVariables"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testSingletonStaticVariables"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableString"));
- // suite.addTest(new TC_DebuggerCommunicationTest("testInspect"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testInspectError"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableArray"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableArrayEmpty"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableHash"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableHashWithObjectKeys"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableHashWithStringKeys"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableWithXmlContent"));
- // suite.addTest(new TC_DebuggerCommunicationTest("testVariableLocal"));
- //suite.addTest(new TC_DebuggerCommunicationTest("testReloadAndInspect")) ;
- //suite.addTest(new TC_DebuggerCommunicationTest("testReloadWithException")) ;
- //suite.addTest(new TC_DebuggerCommunicationTest("testReloadAndStep")) ;
- //suite.addTest(new TC_DebuggerCommunicationTest("testReloadInRequire")) ;
- //suite.addTest(new TC_DebuggerCommunicationTest("testReloadInStackFrame")) ;
- suite.addTest(new TC_DebuggerCommunicationTest("testIgnoreException"));
- suite.addTest(new TC_DebuggerCommunicationTest("testExceptionHierarchy"));
- suite.addTest(new TC_DebuggerCommunicationTest("testException"));
-
- return suite;
- }
- */
-
-
-
- private static String tmpDir;
- private static String getTmpDir() {
- if (tmpDir == null) {
- tmpDir = System.getProperty("java.io.tmpdir");
- if (tmpDir.charAt(tmpDir.length() - 1) != File.separatorChar) {
- tmpDir = tmpDir + File.separator;
- }
- }
- return tmpDir;
- }
- public static String RUBY_INTERPRETER;
- static {
- RUBY_INTERPRETER = System.getProperty("rdt.rubyInterpreter");
- if (RUBY_INTERPRETER == null) {
- RUBY_INTERPRETER = "ruby";
- }
- }
- private static long TIMEOUT_MS = 60000 ;
- private Process process;
- private OutputRedirectorThread rubyStdoutRedirectorThread;
- private OutputRedirectorThread rubyStderrRedirectorThread;
- private Socket socket;
- private PrintWriter out;
- private MultiReaderStrategy multiReaderStrategy;
-
- // for timeout handling
- private Thread mainThread ;
- private Thread timeoutThread ;
-
- public FTC_DebuggerCommunicationTest(String arg0) {
- super(arg0);
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(FTC_DebuggerCommunicationTest.class);
- }
-
- private String getTestFilename() {
- return getTmpDir() + "test.rb";
- }
-
- private String getRubyTestFilename() {
- return getTestFilename().replace('\\', '/');
- }
-
- protected XmlPullParser getXpp(Socket socket) throws Exception {
-
- XmlPullParserFactory factory = XmlPullParserFactory.newInstance("org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer", null);
- XmlPullParser xpp = factory.newPullParser();
- xpp.setInput(new BufferedReader(new InputStreamReader(socket.getInputStream())));
- return xpp;
- }
-
- protected SuspensionReader getSuspensionReader() throws Exception {
- return new SuspensionReader(multiReaderStrategy);
- }
-
- protected VariableReader getVariableReader() throws Exception {
- return new VariableReader(multiReaderStrategy);
- }
-
- protected FramesReader getFramesReader() throws Exception {
- return new FramesReader(multiReaderStrategy);
- }
-
- protected ThreadInfoReader getThreadInfoReader() throws Exception {
- return new ThreadInfoReader(multiReaderStrategy);
- }
-
- protected LoadResultReader getLoadResultReader() throws Exception {
- return new LoadResultReader(multiReaderStrategy) ;
- }
-
- public void startRubyProcess() throws Exception {
- String cmd = FTC_DebuggerCommunicationTest.RUBY_INTERPRETER + " -I" + createIncludeDir() + " -I" + getTmpDir().replace('\\', '/') + " -reclipseDebugVerbose.rb " + getRubyTestFilename();
- System.out.println("Starting: " + cmd);
- process = Runtime.getRuntime().exec(cmd);
- rubyStderrRedirectorThread = new OutputRedirectorThread(process.getErrorStream());
- rubyStderrRedirectorThread.start();
- rubyStdoutRedirectorThread = new OutputRedirectorThread(process.getInputStream());
- rubyStdoutRedirectorThread.start();
-
- }
-
- private String createIncludeDir() {
- String includeDir;
- if (RdtLaunchingPlugin.getDefault() != null) {
- // being run as JUnit Plug-in Test, Eclipse is running
- includeDir = RubyCore.getOSDirectory(RdtLaunchingPlugin.getDefault()) + "ruby" ;
- }
- else {
- // being run as "pure" JUnit Test without Eclipse running
- // getResource delivers a URL, so we get slashes as Fileseparator
- includeDir = getClass().getResource("/").getFile();
- includeDir += "../../org.rubypeople.rdt.launching/ruby" ;
- // if on windows, remove a leading slash
- if (includeDir.startsWith("/") && File.separatorChar == '\\') {
- includeDir = includeDir.substring(1);
- }
- }
- // the ruby interpreter on linux does not like quotes, so we use them only if really necessary
- if (includeDir.indexOf(" ") == -1) {
- return includeDir ;
- }
- else {
- return '"' + includeDir + '"';
- }
- }
-
- protected String getOSIndependent(String path) {
- return path.replace('\\', '/');
- }
-
- public void setUp() throws Exception {
- if (!new File(getTmpDir()).exists() || !new File(getTmpDir()).isDirectory()) {
- throw new RuntimeException("Temp directory does not exist: " + getTmpDir());
- }
- // if a reader hangs, because the expected data from the ruby process
- // does not arrive, it gets interrupted from the timeout watchdog.
- mainThread = Thread.currentThread() ;
- timeoutThread = new Thread() {
- public void run() {
- try {
- while (true) {
- System.out.println("Starting timeout watchdog.");
- Thread.sleep(TIMEOUT_MS);
- System.out.println("Timeout reached.");
- mainThread.interrupt();
- }
- } catch (InterruptedException e) {
- System.out.println("Watchdog deactivated.");
- }
- }
- } ;
- timeoutThread.start() ;
- }
-
- public void tearDown() throws Exception {
- timeoutThread.interrupt() ;
- if (process == null || socket == null) {
- // here we go it there was an error in the creation of the process (process == null)
- // or there was an error creating the socket, e.g. ruby process has died early
- return ;
- }
- Thread.sleep(1000);
- socket.close();
- try {
- if (process.exitValue() != 0) {
- System.out.println("Ruby finished with exit value: " + process.exitValue());
- }
- } catch (IllegalThreadStateException ex) {
- process.destroy();
- System.out.println("Ruby process had to be destroyed.");
- // wait so that the debugger port will be availabel for the next test
- // There seems to be a delay after the destroying of a process and
- // freeing the server port
- Thread.sleep(5000) ;
- }
-
- System.out.println("Waiting for stdout redirector thread..");
- rubyStdoutRedirectorThread.join();
- System.out.println("..done");
- System.out.println("Waiting for stderr redirector thread..");
- rubyStderrRedirectorThread.join();
- System.out.println("..done");
- }
-
- private void writeFile(String name, String[] content) throws Exception {
- PrintWriter writer = new PrintWriter(new FileOutputStream(getTmpDir() + name));
- for (int i = 0; i < content.length; i++) {
- writer.println(content[i]);
- }
- writer.close();
- }
-
- private void createSocket(String[] lines) throws Exception {
- writeFile("test.rb", lines);
- startRubyProcess();
- Thread.sleep(500) ;
- try {
- ...
[truncated message content] |
|
From: <mba...@us...> - 2006-10-08 13:33:17
|
Revision: 1620
http://svn.sourceforge.net/rubyeclipse/?rev=1620&view=rev
Author: mbarchfe
Date: 2006-10-08 06:33:12 -0700 (Sun, 08 Oct 2006)
Log Message:
-----------
undo accidental check-in
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/RubyFileSelector.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/RubyFileSelector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/RubyFileSelector.java 2006-10-08 13:30:57 UTC (rev 1619)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/RubyFileSelector.java 2006-10-08 13:33:12 UTC (rev 1620)
@@ -62,8 +62,7 @@
}
protected String validateResourceSelection() {
- return getSelectionText() ;
-// IFile selection = getSelection();
-// return selection == null ? EMPTY_STRING : selection.getProjectRelativePath().toString();
+ IFile selection = getSelection();
+ return selection == null ? EMPTY_STRING : selection.getProjectRelativePath().toString();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-10-08 13:31:22
|
Revision: 1619
http://svn.sourceforge.net/rubyeclipse/?rev=1619&view=rev
Author: mbarchfe
Date: 2006-10-08 06:30:57 -0700 (Sun, 08 Oct 2006)
Log Message:
-----------
changes for ruby-debug and adapting to Eclipse 3.2 debug framework
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyStackFrame.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/ruby-debug-0.4.2-mswin32.zip
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -144,7 +144,7 @@
if (breakpoint instanceof RubyExceptionBreakpoint) {
this.println("catch " + ((RubyExceptionBreakpoint) breakpoint).getException());
} else {
- this.printBreakpoint("add", breakpoint.getMarker().getResource().getName(), breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1));
+ this.printBreakpoint("", breakpoint.getMarker().getResource().getName(), breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1));
}
}
} catch (IOException e) {
@@ -292,7 +292,7 @@
public RubyStackFrame[] readFrames(RubyThread thread) {
try {
- this.println("th " + thread.getId() + " ; f ");
+ this.println("th " + thread.getId() + " ; w");
return new FramesReader(getMultiReaderStrategy()).readFrames(thread);
} catch (IOException e) {
RdtDebugCorePlugin.log(e);
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -67,13 +67,13 @@
}
if (threadIndex == threads.length) {
updatedThreads[i] = new RubyThread(this, threadInfos[i].getId());
+ DebugEvent ev = new DebugEvent(updatedThreads[i], DebugEvent.CREATE);
+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
} else {
updatedThreads[i] = threads[threadIndex];
}
}
threads = updatedThreads;
- DebugEvent ev = new DebugEvent(this, DebugEvent.CHANGE);
- DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
}
@@ -101,6 +101,7 @@
}
public boolean hasThreads() throws DebugException {
+ System.out.println("THREADS: " + threads.length) ;
return threads.length > 0;
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyStackFrame.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyStackFrame.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyStackFrame.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -43,10 +43,7 @@
}
public boolean hasVariables() throws DebugException {
- if (variables == null) {
- return false;
- }
- return variables.length > 0;
+ return getVariables().length > 0;
}
public int getLineNumber() {
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -15,37 +15,56 @@
// see RubyDebugTarget for the reason why PlatformObject is being extended
public class RubyThread extends PlatformObject implements IThread {
private RubyStackFrame[] frames;
+
private IDebugTarget target;
+
private boolean isSuspended = false;
+
private boolean isTerminated = false;
+
private boolean isStepping = false;
- private String name ;
- private int id ;
-
+
+ private String name;
+
+ private int id;
+
public RubyThread(IDebugTarget target, int id) {
this.target = target;
- this.setId(id) ;
- this.createName() ;
+ this.setId(id);
+ this.createName();
}
- public IStackFrame[] getStackFrames() throws DebugException {
- // Not all clients ask hasStackFrames before calling this method (DeferredThread)
+ public IStackFrame[] getStackFrames() {
+ // Not all clients ask hasStackFrames before calling this method
+ // (DeferredThread)
// Therefore we must not return null
+ // Since 3.2: It seems as if the first method called on a thread is
+ // hasStackFrames
+ // this is done frome AsynchronousContentAdapter and therefore we have
+ // the time to
+ // send this call to the debuggger ;
if (frames == null) {
- return new RubyStackFrame[0];
+ createStackFrames();
}
- return frames ;
+ return frames;
}
+ private void createStackFrames() {
+ getRubyDebuggerProxy().readFrames(this);
+ for (int i = 0; i < frames.length; i++) {
+ RubyStackFrame frame = frames[i];
+ DebugEvent ev = new DebugEvent(frame, DebugEvent.CREATE);
+ DebugPlugin.getDefault().fireDebugEventSet(
+ new DebugEvent[] { ev });
+ }
+ }
+
public int getStackFramesSize() {
return frames.length;
}
public boolean hasStackFrames() {
- if (frames == null) {
- return false;
- }
- return frames.length > 0;
+ return getStackFrames().length > 0;
}
public int getPriority() throws DebugException {
@@ -59,10 +78,11 @@
return frames[0];
}
-
public IBreakpoint[] getBreakpoints() {
// TODO: Experimental Code
- return new IBreakpoint[] { DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IRubyDebugTarget.MODEL_IDENTIFIER)[0] } ;
+ return new IBreakpoint[] { DebugPlugin.getDefault()
+ .getBreakpointManager().getBreakpoints(
+ IRubyDebugTarget.MODEL_IDENTIFIER)[0] };
}
public String getModelIdentifier() {
@@ -95,27 +115,30 @@
protected void prepareForResume() {
isSuspended = false;
- this.createName() ;
- this.frames = null ;
- DebugEvent ev = new DebugEvent(this, DebugEvent.RESUME, DebugEvent.CLIENT_REQUEST);
- DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
+ this.createName();
+ this.frames = null;
+ DebugEvent ev = new DebugEvent(this, DebugEvent.RESUME,
+ DebugEvent.CLIENT_REQUEST);
+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
}
public void resume() throws DebugException {
- this.prepareForResume() ;
- ((RubyDebugTarget) this.getDebugTarget()).getRubyDebuggerProxy().resume(this);
+ this.prepareForResume();
+ ((RubyDebugTarget) this.getDebugTarget()).getRubyDebuggerProxy()
+ .resume(this);
}
public void doSuspend(SuspensionPoint suspensionPoint) {
- this.getRubyDebuggerProxy().readFrames(this);
- this.createName(suspensionPoint) ;
- this.suspend() ;
+ this.createStackFrames() ;
+ this.createName(suspensionPoint);
+ this.suspend();
}
- public void suspend() {
- isStepping = false ;
+ public void suspend() {
+ isStepping = false;
isSuspended = true;
- DebugEvent ev = new DebugEvent(this, DebugEvent.SUSPEND, DebugEvent.BREAKPOINT);
+ DebugEvent ev = new DebugEvent(this, DebugEvent.SUSPEND,
+ DebugEvent.BREAKPOINT);
DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
}
@@ -136,17 +159,17 @@
}
public void stepInto() throws DebugException {
- isStepping = true ;
- this.createName() ;
- this.frames = null ;
+ isStepping = true;
+ this.createName();
+ this.frames = null;
frames[0].stepInto();
}
public void stepOver() throws DebugException {
- isStepping = true ;
- this.createName() ;
- this.frames = null ;
- frames[0].stepOver() ;
+ isStepping = true;
+ this.createName();
+ this.frames = null;
+ frames[0].stepOver();
}
public void stepReturn() throws DebugException {
@@ -161,7 +184,7 @@
}
public void terminate() throws DebugException {
- this.getDebugTarget().terminate() ;
+ this.getDebugTarget().terminate();
isTerminated = true;
this.frames = null;
}
@@ -183,13 +206,13 @@
}
protected void createName() {
- this.createName(null) ;
+ this.createName(null);
}
-
+
protected void createName(SuspensionPoint suspensionPoint) {
- this.name = "Ruby Thread - " + this.getId() ;
- if (suspensionPoint != null) {
- this.name += " (" + suspensionPoint + ")" ;
+ this.name = "Ruby Thread - " + this.getId();
+ if (suspensionPoint != null) {
+ this.name += " (" + suspensionPoint + ")";
}
}
Added: trunk/org.rubypeople.rdt.launching/ruby-debug-0.4.2-mswin32.zip
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.launching/ruby-debug-0.4.2-mswin32.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -4,50 +4,91 @@
import java.util.List;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IProcess;
import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.core.parser.RdtPosition;
import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin;
import org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy;
import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
public class DebuggerRunner extends InterpreterRunner {
- private RubyDebugTarget debugTarget ;
- public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) throws CoreException {
- debugTarget = new RubyDebugTarget(launch);
+ private RubyDebugTarget debugTarget;
+
+ public IProcess run(InterpreterRunnerConfiguration configuration,
+ ILaunch launch) throws CoreException {
+ debugTarget = new RubyDebugTarget(launch);
IProcess process = super.run(configuration, launch);
- debugTarget.setProcess(process) ;
- RubyDebuggerProxy proxy = new RubyDebuggerProxy(debugTarget) ;
+ debugTarget.setProcess(process);
+ RubyDebuggerProxy proxy = new RubyDebuggerProxy(debugTarget);
if (proxy.checkConnection()) {
proxy.start();
- launch.addDebugTarget(debugTarget);
- }
- else {
- RdtLaunchingPlugin.log(new Status(IStatus.ERROR, RdtLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, RdtLaunchingMessages.getString("RdtLaunchingPlugin.processTerminatedBecauseNoDebuggerConnection"),null)) ;
+ launch.addDebugTarget(debugTarget);
+ } else {
+ RdtLaunchingPlugin
+ .log(new Status(
+ IStatus.ERROR,
+ RdtLaunchingPlugin.PLUGIN_ID,
+ IStatus.ERROR,
+ RdtLaunchingMessages
+ .getString("RdtLaunchingPlugin.processTerminatedBecauseNoDebuggerConnection"),
+ null));
debugTarget.terminate();
}
return process;
}
protected void addDebugCommandLineArgument(List commandLine) {
- if (!debugTarget.isUsingDefaultPort()) {
- commandLine.add("-r" + debugTarget.getDebugParameterFile().getAbsolutePath());
- }
-
- if (RdtDebugCorePlugin.isRubyDebuggerVerbose()) {
- commandLine.add("-reclipseDebugVerbose");
+ if (isUseRubyDebug()) {
+ commandLine.add("--server");
+ commandLine.add("--port");
+ commandLine.add(Integer.toString(debugTarget.getPort()));
+ commandLine.add("--wait");
+ commandLine.add("--eclipse");
} else {
- commandLine.add("-reclipseDebug");
+ if (!debugTarget.isUsingDefaultPort()) {
+ commandLine
+ .add("-r"
+ + debugTarget.getDebugParameterFile()
+ .getAbsolutePath());
+ }
+
+ if (RdtDebugCorePlugin.isRubyDebuggerVerbose()) {
+ commandLine.add("-reclipseDebugVerbose");
+ } else {
+ commandLine.add("-reclipseDebug");
+ }
+ commandLine.add("-I");
+ commandLine.add(RdtLaunchingPlugin.osDependentPath(DebuggerRunner
+ .getDirectoryOfRubyDebuggerFile().replace('/',
+ File.separatorChar)));
}
-
- commandLine.add("-I");
- commandLine.add(RdtLaunchingPlugin.osDependentPath(DebuggerRunner.getDirectoryOfRubyDebuggerFile().replace('/', File.separatorChar)));
}
public static String getDirectoryOfRubyDebuggerFile() {
- return RubyCore.getOSDirectory(RdtLaunchingPlugin.getDefault()) + "ruby" ;
+ return RubyCore.getOSDirectory(RdtLaunchingPlugin.getDefault())
+ + "ruby";
}
+
+ public boolean isUseRubyDebug() {
+ // TODO: use PrefernceConstants ?
+ return RdtLaunchingPlugin.getDefault().getPluginPreferences().getBoolean(
+ "useRubyDebug");
+ }
+
+ protected RubyInterpreter convertInterpreter(RubyInterpreter rubyInterpreter) {
+ if (isUseRubyDebug()) {
+ IPath rdebugLocation = rubyInterpreter.getInstallLocation()
+ .removeLastSegments(1);
+ rdebugLocation = rdebugLocation.append("rdebug.cmd");
+ return new RubyInterpreter("rdebug", rdebugLocation);
+ } else {
+ return rubyInterpreter;
+ }
+ }
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -19,7 +19,7 @@
List commandLine = renderCommandLine(configuration);
File workingDirectory = configuration.getAbsoluteWorkingDirectory();
- RubyInterpreter interpreter = configuration.getInterpreter() ;
+ RubyInterpreter interpreter = convertInterpreter(configuration.getInterpreter()) ;
Process nativeRubyProcess = interpreter.exec(commandLine, workingDirectory);
Map defaultAttributes = new HashMap();
defaultAttributes.put(IProcess.ATTR_PROCESS_TYPE, "ruby");
@@ -27,9 +27,11 @@
process.setAttribute(RdtLaunchingPlugin.PLUGIN_ID + ".launcher.cmdline", commandLine.toString());
return process ;
}
+
+ protected RubyInterpreter convertInterpreter(RubyInterpreter rubyInterpreter) {
+ return rubyInterpreter ;
+ }
-
-
protected String renderLabel(InterpreterRunnerConfiguration configuration) {
StringBuffer buffer = new StringBuffer();
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -61,7 +61,7 @@
List rubyCmd = new ArrayList();
rubyCmd.add(this.getCommand());
rubyCmd.addAll(args);
- return commandExecutor.exec((String[]) rubyCmd.toArray(new String[0]), workingDirectory);
+ return commandExecutor.exec((String[]) rubyCmd.toArray(new String[] {}), workingDirectory);
} catch (IOException e) {
IStatus errorStatus = new Status(IStatus.ERROR, RdtLaunchingPlugin.PLUGIN_ID, IStatus.OK,
"Unable to execute interpreter: " + args + workingDirectory, e);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-10-08 13:29:47
|
Revision: 1618
http://svn.sourceforge.net/rubyeclipse/?rev=1618&view=rev
Author: mbarchfe
Date: 2006-10-08 06:29:41 -0700 (Sun, 08 Oct 2006)
Log Message:
-----------
added debugger preference page
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2006-10-08 13:29:10 UTC (rev 1617)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2006-10-08 13:29:41 UTC (rev 1618)
@@ -16,6 +16,7 @@
public static final String RI_PATH = "riDirectoryPath";
public static final String RDOC_PATH = "rdocDirectoryPath";
+ public static final String DEBUGGER_USE_RUBY_DEBUG = "useRubyDebug";
public static final String TEMPLATES_USE_CODEFORMATTER = "templatesUseCodeFormatter"; //$NON-NLS-1$
@@ -611,6 +612,8 @@
.getDefaultPath(PreferenceConstants.DEFAULT_RDOC_CMD));
store.setDefault(PreferenceConstants.RI_PATH, PreferenceConstants
.getDefaultPath(PreferenceConstants.DEFAULT_RI_CMD));
+
+ store.setDefault(PreferenceConstants.DEBUGGER_USE_RUBY_DEBUG, false) ;
store.setDefault(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE, true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-10-08 13:29:25
|
Revision: 1617
http://svn.sourceforge.net/rubyeclipse/?rev=1617&view=rev
Author: mbarchfe
Date: 2006-10-08 06:29:10 -0700 (Sun, 08 Oct 2006)
Log Message:
-----------
added debugger preference page
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/RubyFileSelector.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/DebuggerPreferencePage.java
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2006-09-22 00:00:16 UTC (rev 1616)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2006-10-08 13:29:10 UTC (rev 1617)
@@ -26,6 +26,7 @@
PreferencePage.rdtTemplatePreferences=Templates
PreferencePage.rdtTaskPreferences=Task Tags
PreferencePage.rdtRiPreferences=Ri/rdoc
+PreferencePage.rdtDebuggerPreferences=Debugger
viewCategoryName=Ruby
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2006-09-22 00:00:16 UTC (rev 1616)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2006-10-08 13:29:10 UTC (rev 1617)
@@ -90,10 +90,15 @@
<page
name="%problemSeveritiesPrefName"
category="org.rubypeople.rdt.ui.preferences.PreferencePageRubyBase"
- class="org.rubypeople.rdt.internal.ui.preferences.ProblemSeveritiesPreferencePage"
+ class="org.rubypeople.rdt.internal.ui.preferences.DebuggerPreferencePage"
id="org.rubypeople.rdt.ui.preferences.ProblemSeveritiesPreferencePage">
<keywordReference id="org.rubypeople.rdt.ui.severities"/>
</page>
+ <page
+ category="org.rubypeople.rdt.ui.preferences.PreferencePageRubyBase"
+ class="org.rubypeople.rdt.internal.ui.preferences.DebuggerPreferencePage"
+ id="org.rubypeople.rdt.ui.preferences.debugger"
+ name="%PreferencePage.rdtDebuggerPreferences"/>
</extension>
<!-- =========================================================================== -->
<!-- Ruby Perspective -->
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/DebuggerPreferencePage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/DebuggerPreferencePage.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/DebuggerPreferencePage.java 2006-10-08 13:29:10 UTC (rev 1617)
@@ -0,0 +1,37 @@
+package org.rubypeople.rdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.launching.RdtLaunchingPlugin;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.PreferencesAdapter;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+
+
+public class DebuggerPreferencePage
+ extends FieldEditorPreferencePage
+ implements IWorkbenchPreferencePage {
+
+ public DebuggerPreferencePage() {
+ super(GRID);
+ Preferences launchingPreferences = RdtLaunchingPlugin.getDefault().getPluginPreferences() ;
+ setPreferenceStore(new PreferencesAdapter(launchingPreferences)) ;
+ setDescription(PreferencesMessages.DebuggerPreferencePage_description_label);
+ }
+
+ public void createFieldEditors() {
+ addField( new BooleanFieldEditor( PreferenceConstants.DEBUGGER_USE_RUBY_DEBUG,
+ PreferencesMessages.DebuggerPreferencePage_useRubyDebug_label, getFieldEditorParent() ) );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {}
+
+}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2006-09-22 00:00:16 UTC (rev 1616)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2006-10-08 13:29:10 UTC (rev 1617)
@@ -20,6 +20,7 @@
}
public static String RiPreferencePage_description_label;
+ public static String DebuggerPreferencePage_description_label;
public static String CodeFormatterPreferencePage_title;
public static String CodeFormatterPreferencePage_description;
public static String MembersOrderPreferencePage_category_button_up;
@@ -54,6 +55,7 @@
public static String RubyEditorPreferencePage_link;
public static String RiPreferencePage_ripath_label;
public static String RiPreferencePage_rdocpath_label;
+ public static String DebuggerPreferencePage_useRubyDebug_label;
public static String TodoTaskConfigurationBlock_tasks_default;
public static String TodoTaskConfigurationBlock_markers_tasks_high_priority;
public static String TodoTaskConfigurationBlock_markers_tasks_normal_priority;
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2006-09-22 00:00:16 UTC (rev 1616)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2006-10-08 13:29:10 UTC (rev 1617)
@@ -168,3 +168,5 @@
MarkOccurrencesConfigurationBlock_markMethodExitPoints= Method &exits
MarkOccurrencesConfigurationBlock_stickyOccurrences= &Keep marks when the selection changes
+DebuggerPreferencePage_description_label=Debugger preferences
+DebuggerPreferencePage_useRubyDebug_label=Use ruby-debug library (ruby >= 1.8.4, gem install ruby-debug)
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/RubyFileSelector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/RubyFileSelector.java 2006-09-22 00:00:16 UTC (rev 1616)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/RubyFileSelector.java 2006-10-08 13:29:10 UTC (rev 1617)
@@ -62,7 +62,8 @@
}
protected String validateResourceSelection() {
- IFile selection = getSelection();
- return selection == null ? EMPTY_STRING : selection.getProjectRelativePath().toString();
+ return getSelectionText() ;
+// IFile selection = getSelection();
+// return selection == null ? EMPTY_STRING : selection.getProjectRelativePath().toString();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-09-22 00:00:26
|
Revision: 1616
http://svn.sourceforge.net/rubyeclipse/?rev=1616&view=rev
Author: cawilliams
Date: 2006-09-21 17:00:16 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
move all the completion code into the CompletionEngine as a single spot for the code. Properly create images for all proposal types (not just methods)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCompletionProcessor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2006-09-21 22:30:10 UTC (rev 1615)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2006-09-22 00:00:16 UTC (rev 1616)
@@ -1,19 +1,50 @@
package org.rubypeople.rdt.internal.codeassist;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
+import org.jruby.ast.ClassNode;
+import org.jruby.ast.ClassVarAsgnNode;
+import org.jruby.ast.ClassVarDeclNode;
+import org.jruby.ast.ClassVarNode;
+import org.jruby.ast.Colon2Node;
+import org.jruby.ast.ConstNode;
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.DefsNode;
+import org.jruby.ast.InstAsgnNode;
+import org.jruby.ast.InstVarNode;
+import org.jruby.ast.ModuleNode;
+import org.jruby.ast.Node;
+import org.jruby.ast.ScopeNode;
+import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.CompletionProposal;
import org.rubypeople.rdt.core.CompletionRequestor;
import org.rubypeople.rdt.core.Flags;
import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IParent;
+import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.RubyElement;
+import org.rubypeople.rdt.internal.core.RubyScript;
+import org.rubypeople.rdt.internal.core.RubyType;
+import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.ti.DefaultTypeInferrer;
import org.rubypeople.rdt.internal.ti.ITypeGuess;
import org.rubypeople.rdt.internal.ti.ITypeInferrer;
+import org.rubypeople.rdt.internal.ti.util.AttributeLocator;
+import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
+import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
+import org.rubypeople.rdt.internal.ti.util.ScopedNodeLocator;
public class CompletionEngine {
private CompletionRequestor requestor;
@@ -34,6 +65,7 @@
// if we hit a period, use character before period as offset for
// inferrer
// if we hit a space, use character after space?
+ // TODO We need to handle other bad syntax like invoking compeltion right after an @
for (int i = offset; i >= 0; i--) {
char curChar = (char) source.charAt(i);
if (curChar == '.') {
@@ -53,7 +85,6 @@
break;
}
}
- System.out.println((char) source.charAt(offset));
List<ITypeGuess> guesses = inferrer.infer(source.toString(), offset);
// TODO Grab the project and all referred projects!
@@ -63,22 +94,24 @@
for (Iterator iter = guesses.iterator(); iter.hasNext();) {
ITypeGuess guess = (ITypeGuess) iter.next();
IType type = completer.findType(guess.getType());
- suggestMethods(requestor, replaceStart, completer, guess, type);
+ suggestMethods(replaceStart, completer, guess, type);
}
+ // FIXME Do we need to call this at all if we know it's a method call we're trying to complete?
+ getDocumentsRubyElementsInScope(script, source.toString(), offset, replaceStart);
+ this.requestor.endReporting();
}
- private void suggestMethods(CompletionRequestor requestor,
- int replaceStart, RubyElementRequestor completer, ITypeGuess guess,
+ private void suggestMethods(int replaceStart, RubyElementRequestor completer, ITypeGuess guess,
IType type) throws RubyModelException {
if (type == null)
return;
- suggestMethods(requestor, replaceStart, guess.getConfidence(), type);
+ suggestMethods(replaceStart, guess.getConfidence(), type);
// Now grab methods from all the included modules
String[] modules = type.getIncludedModuleNames();
for (int x = 0; x < modules.length; x++) {
IType tmpType = completer.findType(modules[x]);
- suggestMethods(requestor, replaceStart, guess.getConfidence(),
+ suggestMethods(replaceStart, guess.getConfidence(),
tmpType);
}
String superClass = type.getSuperclassName();
@@ -87,11 +120,10 @@
&& superClass.equals("Object"))
return;
IType parentClass = completer.findType(superClass);
- suggestMethods(requestor, replaceStart, completer, guess, parentClass);
+ suggestMethods(replaceStart, completer, guess, parentClass);
}
- private void suggestMethods(CompletionRequestor requestor,
- int replaceStart, int confidence, IType type)
+ private void suggestMethods(int replaceStart, int confidence, IType type)
throws RubyModelException {
if (type == null)
return;
@@ -125,5 +157,338 @@
requestor.accept(proposal);
}
}
+
+ /**
+ * Gets all the distinct elements in the current RubyScript
+ * @param offset
+ * @param replaceStart
+ *
+ * @return a List of the names of all the elements in the current RubyScript
+ */
+ private void getDocumentsRubyElementsInScope(IRubyScript script, String source, int offset, int replaceStart) {
+ try {
+ // Get all references projects
+ List<IRubyProject> projects = new ArrayList<IRubyProject>();
+ projects.add(script.getRubyProject());
+ projects.addAll(script.getRubyProject().getReferencedProjects());
+
+ // FIXME Try to stop all the multiple re-parsing of the source! Can we parse once and pass the root node around?
+ // Parse
+ Node rootNode = (new RubyParser()).parse(source);
+ if ( rootNode == null ) { return; }
+ // Find the enclosing method to get locals and args
+ Node enclosingMethodNode = ClosestSpanningNodeLocator.Instance().findClosestSpanner(rootNode, offset, new INodeAcceptor() {
+ public boolean doesAccept(Node node) {
+ return ( node instanceof DefnNode || node instanceof DefsNode );
+ }
+ });
+
+ // Add local vars and arguments
+ if ( enclosingMethodNode != null ) {
+ ScopeNode scopeNode = null;
+ if ( enclosingMethodNode instanceof DefnNode ) { scopeNode = (ScopeNode)((DefnNode)enclosingMethodNode).getBodyNode(); }
+ if ( enclosingMethodNode instanceof DefsNode ) { scopeNode = (ScopeNode)((DefsNode)enclosingMethodNode).getBodyNode(); }
+ if ( scopeNode != null && scopeNode.getLocalNames().length > 0 ) {
+ List locals = Arrays.asList (scopeNode.getLocalNames());
+ for (Iterator iter = locals.iterator(); iter.hasNext();) {
+ String local = (String) iter.next();
+ CompletionProposal proposal = new CompletionProposal(
+ CompletionProposal.LOCAL_VARIABLE_REF, local, 100);
+ // TODO Handle replacement start index correctly
+ proposal.setReplaceRange(replaceStart, replaceStart + local.length());
+ requestor.accept(proposal);
+ }
+ }
+ }
+
+ // Find the enclosing type (class or module) to get instance and classvars from
+ Node enclosingTypeNode = ClosestSpanningNodeLocator.Instance().findClosestSpanner(rootNode, offset, new INodeAcceptor() {
+ public boolean doesAccept(Node node) {
+ return ( node instanceof ClassNode || node instanceof ModuleNode );
+ }
+ });
+
+ // Add members from enclosing type
+ if ( enclosingTypeNode != null ) {
+ getMembersAvailableInsideType( enclosingTypeNode, script, replaceStart );
+ }
+
+ // Add all globals, classes, and modules
+ for (Iterator iter = projects.iterator(); iter.hasNext();) {
+ IRubyProject nextProject = (IRubyProject)(iter.next());
+ getElementsOfType( nextProject, new int[] { IRubyElement.GLOBAL }, replaceStart);
+ addClassesAndModulesInProject( nextProject, replaceStart );
+ }
+ } catch ( RubyModelException rme ) {
+ System.out.println("RubyModelException in CompletionEngine::getElementsInScope()");
+ rme.printStackTrace();
+ } catch ( SyntaxException se ) {
+ System.out.println("SyntaxError in CompletionEngine::getElementsInScope()");
+ se.printStackTrace();
+ }
+ }
+
+ private void addClassesAndModulesInProject(IRubyProject project, int replaceStart) {
+ getElementsOfType(project, new int[] { IRubyElement.TYPE }, replaceStart);
+ }
+
+ private void getElementsOfType(IParent element, int[] types, int replaceStart) {
+ try {
+ IRubyElement[] elements = element.getChildren();
+ if (elements == null) return;
+ for (int x = 0; x < elements.length; x++) {
+ IRubyElement child = elements[x];
+ for (int i = 0; i < types.length; i++) {
+ if (child.getElementType() == types[i]) {
+ String name = child.getElementName();
+ CompletionProposal proposal = new CompletionProposal(
+ getCompletionProposalType(child), name, 100);
+ // TODO Handle replacement start index correctly
+ proposal.setReplaceRange(replaceStart, replaceStart + name.length());
+ requestor.accept(proposal);
+ break;
+ }
+ }
+ if (child instanceof IParent)
+ getElementsOfType((IParent) child, types, replaceStart);
+ }
+ } catch (RubyModelException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private int getCompletionProposalType(IRubyElement child) {
+ switch (child.getElementType()) {
+ case IRubyElement.DYNAMIC_VAR:
+ case IRubyElement.LOCAL_VARIABLE:
+ return CompletionProposal.LOCAL_VARIABLE_REF;
+ case IRubyElement.METHOD:
+ return CompletionProposal.METHOD_REF;
+ case IRubyElement.TYPE:
+ return CompletionProposal.TYPE_REF;
+ case IRubyElement.INSTANCE_VAR:
+ case IRubyElement.CLASS_VAR:
+ return CompletionProposal.FIELD_REF;
+ default:
+ return CompletionProposal.KEYWORD;
+ }
+ }
+
+ /**
+ * Gets the members available inside a type node (ModuleNode, ClassNode):
+ * - Instance variables
+ * - Class variables
+ * - Methods
+ *
+ * @param typeNode
+ * @return
+ */
+ private void getMembersAvailableInsideType(Node typeNode, IRubyScript script, int replaceStart) throws RubyModelException {
+ if ( typeNode == null ) { return; }
+
+ // Get type name
+ String typeName = null;
+ if ( typeNode instanceof ClassNode ) { typeName = ((Colon2Node)((ClassNode)typeNode).getCPath()).getName(); }
+ if ( typeNode instanceof ModuleNode ) { typeName = ((Colon2Node)((ModuleNode)typeNode).getCPath()).getName(); }
+ if ( typeName == null ) { return; }
+
+ // XXX rubyType may not be in script, but rather be defined in another script
+// IType rubyType = new RubyType( (RubyElement)script, typeName );
+ //Better method:
+ // Find the named type
+// IType rubyType = findTypeFromAllProjects(typeName, script);
+
+// System.out.println(" -- Located RubyType info.");
+// System.out.println(" -- Superclass: " + rubyType.getSuperclassName() );
+
+// if ( rubyType != null ) {
+// String[] includedModuleNames = rubyType.getIncludedModuleNames();
+// if ( includedModuleNames != null ) {
+// for ( String moduleName : rubyType.getIncludedModuleNames() ) {
+// System.out.println(" -- Includes module: " + moduleName);
+// }
+// }
+// }
+
+
+
+ // Get superclass and add its public members
+ List<Node> superclassNodes = getSuperclassNodes( typeNode, script );
+ for ( Node superclassNode : superclassNodes ) {
+ getMembersAvailableInsideType( superclassNode, script, replaceStart );
+ }
+
+ // Get public members of mixins
+ List<String> mixinNames = getIncludedMixinNames( typeName, script );
+ for ( String mixinName : mixinNames ) {
+ List<Node> mixinDeclarations = getTypeDeclarationNodes( mixinName, script );
+ for ( Node mixinDeclaration : mixinDeclarations ) {
+ getMembersAvailableInsideType( mixinDeclaration, script, replaceStart );
+ }
+ }
+
+ // Get instance and class variables available in the enclosing type
+ List<Node> instanceAndClassVars = ScopedNodeLocator.Instance().findNodesInScope(typeNode, new INodeAcceptor() {
+ public boolean doesAccept(Node node) {
+ return ( node instanceof InstVarNode ||
+ node instanceof InstAsgnNode ||
+ node instanceof ClassVarNode ||
+ node instanceof ClassVarDeclNode ||
+ node instanceof ClassVarAsgnNode );
+ }
+ });
+
+ if ( instanceAndClassVars != null ) {
+ // Get the unique names of instance and class variables
+ for ( Node varNode : instanceAndClassVars ) {
+ String name = getNameReflectively(varNode);
+ if ( name != null ) {
+ CompletionProposal proposal = new CompletionProposal(CompletionProposal.FIELD_REF, name, 100);
+ // TODO Handle replacement start index correctly
+ proposal.setReplaceRange(replaceStart, replaceStart + name.length());
+ requestor.accept(proposal);
+ }
+ }
+ }
+
+ // Get method names defined by DefnNodes and DefsNodes
+ List<Node> methodDefinitions = ScopedNodeLocator.Instance().findNodesInScope(typeNode, new INodeAcceptor() {
+ public boolean doesAccept(Node node) {
+ return ( node instanceof DefnNode ) || ( node instanceof DefsNode );
+ }
+ });
+ for ( Node methodDefinition : methodDefinitions ) {
+ String name = null;
+ if ( methodDefinition instanceof DefnNode ) { name = ((DefnNode)methodDefinition).getName(); }
+ if ( methodDefinition instanceof DefsNode ) { name = ((DefsNode)methodDefinition).getName(); }
+ if (name == null) continue;
+ CompletionProposal proposal = new CompletionProposal(CompletionProposal.METHOD_REF, name, 100);
+ // TODO Handle replacement start index correctly
+ proposal.setReplaceRange(replaceStart, replaceStart + name.length());
+ requestor.accept(proposal);
+ }
+
+ // Get instance and class vars defined by [c]attr_* calls
+ List<String> attrs = AttributeLocator.Instance().findInstanceAttributesInScope(typeNode);
+ for (Iterator iter = attrs.iterator(); iter.hasNext(); ) {
+ String attr = (String) iter.next();
+ CompletionProposal proposal = new CompletionProposal(CompletionProposal.FIELD_REF, attr, 100);
+ // TODO Handle replacement start index correctly
+ proposal.setReplaceRange(replaceStart, replaceStart + attr.length());
+ requestor.accept(proposal);
+ }
+
+ }
+
+ /**
+ * Finds all nodes that declare a type that is a superclass of the specified node. Example:
+ *
+ * """
+ * class Klass;def meth_1;1;end;end
+ * class Klass;def meth_2;2;end;end
+ *
+ * class SubKlass < Klass;end
+ * """
+ *
+ * Issuing getSuperClassNodes() on the ClassNode declaring SubKlass would return two ClassNodes;
+ * one for each definition of Klass.
+ *
+ * @param typeNode Node to find superclass nodes of
+ * @return List of ClassNode or ModuleNode
+ */
+ private List<Node> getSuperclassNodes( Node typeNode, IRubyScript script ) {
+ if ( typeNode instanceof ClassNode ) {
+ Node superNode = ((ClassNode)typeNode).getSuperNode();
+ if ( superNode instanceof ConstNode ) {
+ String superclassName = ((ConstNode)superNode).getName();
+ return getTypeDeclarationNodes( superclassName, script );
+ }
+ }
+ return new ArrayList<Node>();
+ }
+
+ /** Lookup type declaration nodes */
+ private List<Node> getTypeDeclarationNodes( String typeName, IRubyScript script ) {
+ System.out.println("Being asked for the type decl node for " + typeName );
+
+ // Find the named type
+ IType type = findTypeFromAllProjects(typeName, script);
+
+ try {
+ if ( type instanceof RubyType ) {
+
+ // FIXME This feels a little hacky and backwards - RubyType.getSource() and then parse... consider reworking the clients to this method to accept RubyTypes or something similar?
+ // Find source and parse
+ RubyType rubyType = (RubyType)type;
+ String source = rubyType.getSource();
+
+ // FIXME Why does the parser balk on \r chars?
+ source = source.replace('\r', ' ');
+ Node rootNode = (new RubyParser()).parse( source );
+
+ // Bail if the parse fails
+ if ( rootNode == null ) { return new ArrayList(); }
+
+ // Return any type declaration nodes in included source
+ return ScopedNodeLocator.Instance().findNodesInScope(rootNode, new INodeAcceptor() {
+ public boolean doesAccept(Node node) {
+ return ( node instanceof ClassNode ) ||
+ ( node instanceof ModuleNode );
+ }
+ });
+ }
+
+ } catch ( RubyModelException rme ) {
+ rme.printStackTrace();
+ }
+
+ return new ArrayList<Node>(0);
+ }
+
+ private IType findTypeFromAllProjects(String typeName, IRubyScript rootScript) {
+ // Grab the project and all referred projects
+ List<IRubyProject> projects = new LinkedList<IRubyProject>();
+ projects.add(rootScript.getRubyProject());
+ projects.addAll(rootScript.getRubyProject().getReferencedProjects());
+
+ List<IRubyProject> refProjects = rootScript.getRubyProject().getReferencedProjects();
+
+ // Find the named type
+ RubyElementRequestor completer = new RubyElementRequestor(projects.toArray(new IRubyProject[]{}));
+ return completer.findType(typeName);
+ }
+
+ private List<String> getIncludedMixinNames( String typeName, IRubyScript script ) {
+ IType rubyType = new RubyType( (RubyElement)script, typeName );
+
+ try {
+ String[] includedModuleNames = rubyType.getIncludedModuleNames();
+ if ( includedModuleNames != null ) {
+ return Arrays.asList(rubyType.getIncludedModuleNames());
+ } else {
+ return new ArrayList<String>(0);
+ }
+ } catch (RubyModelException e) {
+ return new ArrayList<String>(0);
+ }
+ }
+
+ /**
+ * Gets the name of a node by reflectively invoking "getName()" on it;
+ * helper method just to cut many "instanceof/cast" pairs.
+ * @param node
+ * @return name or null
+ */
+ // TODO Copy/pasted from DefaultOccurrencesFinder, refactor these two methods to a common location.
+ private String getNameReflectively( Node node ) {
+ try {
+ Method getNameMethod = node.getClass().getMethod("getName", new Class[]{});
+ Object name = getNameMethod.invoke( node, new Object[0] );
+ return (String)name;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCompletionProcessor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCompletionProcessor.java 2006-09-21 22:30:10 UTC (rev 1615)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCompletionProcessor.java 2006-09-22 00:00:16 UTC (rev 1616)
@@ -1,16 +1,11 @@
package org.rubypeople.rdt.internal.ui.text.ruby;
-import java.lang.reflect.Method;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextSelection;
@@ -28,36 +23,8 @@
import org.eclipse.jface.text.templates.TemplateContextType;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorPart;
-import org.jruby.ast.ClassNode;
-import org.jruby.ast.ClassVarAsgnNode;
-import org.jruby.ast.ClassVarDeclNode;
-import org.jruby.ast.ClassVarNode;
-import org.jruby.ast.Colon2Node;
-import org.jruby.ast.ConstNode;
-import org.jruby.ast.DefnNode;
-import org.jruby.ast.DefsNode;
-import org.jruby.ast.InstAsgnNode;
-import org.jruby.ast.InstVarNode;
-import org.jruby.ast.ModuleNode;
-import org.jruby.ast.Node;
-import org.jruby.ast.ScopeNode;
-import org.jruby.lexer.yacc.SyntaxException;
-import org.rubypeople.rdt.core.IParent;
-import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.IType;
-import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.codeassist.RubyElementRequestor;
-import org.rubypeople.rdt.internal.core.RubyElement;
-import org.rubypeople.rdt.internal.core.RubyScript;
-import org.rubypeople.rdt.internal.core.RubyType;
-import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.corext.template.ruby.RubyContextType;
-import org.rubypeople.rdt.internal.ti.util.AttributeLocator;
-import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
-import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
-import org.rubypeople.rdt.internal.ti.util.ScopedNodeLocator;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.RubyPluginImages;
import org.rubypeople.rdt.internal.ui.text.template.contentassist.RubyTemplateAccess;
@@ -141,8 +108,6 @@
.getSelectionProvider().getSelection();
cursorPosition = selection.getOffset() + selection.getLength();
- ICompletionProposal[] normal = determineRubyElementProposals(viewer,
- documentOffset);
List templates = determineTemplateProposals(viewer, documentOffset);
ICompletionProposal[] templateArray = new ICompletionProposal[templates
.size()];
@@ -150,7 +115,7 @@
for (Iterator iter = templates.iterator(); iter.hasNext(); i++) {
templateArray[i] = (ICompletionProposal) iter.next();
}
- ICompletionProposal[] merged = merge(normal, templateArray);
+ ICompletionProposal[] merged = templateArray;
ICompletionProposal[] keywords = determineKeywordProposals(viewer,
documentOffset);
@@ -188,45 +153,6 @@
return merged;
}
- /**
- * @param viewer
- * @param documentOffset
- * @return
- */
- private ICompletionProposal[] determineRubyElementProposals(
- ITextViewer viewer, int documentOffset) {
- Collection completionProposals = getDocumentsRubyElementsInScope(documentOffset);
- String prefix = getCurrentPrefix(viewer.getDocument().get(),
- documentOffset);
- // following the JDT convention, if there's no text already entered,
- // then don't suggest imported elements
- if (prefix.length() > 0) {
- // FIXME Add elements from required/loaded files!
- }
-
- List possibleProposals = new ArrayList();
- for (Iterator iter = completionProposals.iterator(); iter.hasNext();) {
- String proposal = (String) iter.next();
- if (proposal.startsWith(prefix) && !proposal.equals(prefix)) {
- String message = "{0}";
- IContextInformation info = new ContextInformation(proposal,
- MessageFormat
- .format(message, new Object[] { proposal }));
- possibleProposals
- .add(new CompletionProposal(proposal.substring(prefix
- .length(), proposal.length()), documentOffset,
- 0, proposal.length() - prefix.length(), null,
- proposal, info, MessageFormat.format(
- "Ruby keyword: {0}",
- new Object[] { proposal })));
- }
- }
- ICompletionProposal[] result = new ICompletionProposal[possibleProposals
- .size()];
- possibleProposals.toArray(result);
- return result;
- }
-
/*
* (non-Javadoc)
*
@@ -357,331 +283,7 @@
}
return false;
}
-
- /**
- * Gets all the distinct elements in the current RubyScript
- * @param offset
- *
- * @return a List of the names of all the elements in the current RubyScript
- */
- private Collection getDocumentsRubyElementsInScope(int offset) {
- IRubyScript script = fManager.getWorkingCopy(fEditor.getEditorInput());
- String source = "";
- Collection elements = new ArrayList();
- try {
- // Get the script's source. If possible, get the most recent contents.
- if ( script instanceof RubyScript ) {
- source = new String(((RubyScript)script).getContents());
- } else {
- source = script.getSource();
- }
-
- // FIXME Ugly hacking here to handle where we have invalid syntax by invoking after a period
- StringBuffer sourceBuff = new StringBuffer(source);
- offset--;
- char charAtOffset = (char) sourceBuff.charAt(offset);
- if (charAtOffset == '.') {
- sourceBuff.deleteCharAt(offset);
- offset--;
- }
- source = sourceBuff.toString();
-
- // XXX Combine this code with the code in RubyScript.codeComplete() (into a new CompletionEngine class?)
-
- // Get all references projects
- List<IRubyProject> projects = new ArrayList<IRubyProject>();
- projects.add(script.getRubyProject());
- projects.addAll(script.getRubyProject().getReferencedProjects());
-
- // Parse
- Node rootNode = (new RubyParser()).parse(source);
- if ( rootNode == null ) { return elements; }
-
- // Find the enclosing method to get locals and args
- Node enclosingMethodNode = ClosestSpanningNodeLocator.Instance().findClosestSpanner(rootNode, offset, new INodeAcceptor() {
- public boolean doesAccept(Node node) {
- return ( node instanceof DefnNode || node instanceof DefsNode );
- }
- });
-
- // Add local vars and arguments
- if ( enclosingMethodNode != null ) {
- ScopeNode scopeNode = null;
- if ( enclosingMethodNode instanceof DefnNode ) { scopeNode = (ScopeNode)((DefnNode)enclosingMethodNode).getBodyNode(); }
- if ( enclosingMethodNode instanceof DefsNode ) { scopeNode = (ScopeNode)((DefsNode)enclosingMethodNode).getBodyNode(); }
- if ( scopeNode != null && scopeNode.getLocalNames().length > 0 ) {
- elements.addAll( Arrays.asList (scopeNode.getLocalNames()) );
- }
- }
-
- // Find the enclosing type (class or module) to get instance and classvars from
- Node enclosingTypeNode = ClosestSpanningNodeLocator.Instance().findClosestSpanner(rootNode, offset, new INodeAcceptor() {
- public boolean doesAccept(Node node) {
- return ( node instanceof ClassNode || node instanceof ModuleNode );
- }
- });
-
- // Add members from enclosing type
- if ( enclosingTypeNode != null ) {
- elements.addAll( getMembersAvailableInsideType( enclosingTypeNode, script ) );
- }
-
- // Add all globals, classes, and modules
- for (Iterator iter = projects.iterator(); iter.hasNext();) {
- IRubyProject nextProject = (IRubyProject)(iter.next());
- elements.addAll(getElementsOfType( nextProject, new int[] { IRubyElement.GLOBAL }));
- elements.addAll(addClassesAndModulesInProject( nextProject ));
- }
- } catch ( RubyModelException rme ) {
- System.out.println("RubyModelException in RubyCompletionProcessor::getElementsInScope()");
- rme.printStackTrace();
- // Return empty 'elements'
- } catch ( SyntaxException se ) {
- System.out.println("SyntaxError in RubyCompletionProcessor::getElementsInScope()");
- se.printStackTrace();
- // Return empty 'elements'
- }
- return elements;
- }
-
- private Collection addClassesAndModulesInProject(IRubyProject project) {
- return getElementsOfType(project, new int[] { IRubyElement.TYPE });
- }
-
- private Collection getElementsOfType(IParent element, int[] types) {
- Collection suggestions = new ArrayList();
- try {
- IRubyElement[] elements = element.getChildren();
- if (elements == null)
- return suggestions;
- for (int x = 0; x < elements.length; x++) {
- IRubyElement child = elements[x];
- for (int i = 0; i < types.length; i++) {
- if (child.getElementType() == types[i]) {
- suggestions.add(child.getElementName());
- break;
- }
- }
- if (child instanceof IParent)
- suggestions
- .addAll(getElementsOfType((IParent) child, types));
- }
- } catch (RubyModelException e) {
- e.printStackTrace();
- }
- return suggestions;
- }
-
- /**
- * Gets the memebrs available inside a type node (ModuleNode, ClassNode):
- * - Instance variables
- * - Class variables
- * - Methods
- *
- * @param typeNode
- * @return
- */
- private List<String> getMembersAvailableInsideType(Node typeNode, IRubyScript script) throws RubyModelException {
- List<String> elements = new LinkedList<String>();
- if ( typeNode == null ) { return elements; }
-
- // Get type name
- String typeName = null;
- if ( typeNode instanceof ClassNode ) { typeName = ((Colon2Node)((ClassNode)typeNode).getCPath()).getName(); }
- if ( typeNode instanceof ModuleNode ) { typeName = ((Colon2Node)((ModuleNode)typeNode).getCPath()).getName(); }
- if ( typeName == null ) { return elements; }
-
- // XXX rubyType may not be in script, but rather be defined in another script
-// IType rubyType = new RubyType( (RubyElement)script, typeName );
- //Better method:
- // Find the named type
-// IType rubyType = findTypeFromAllProjects(typeName, script);
-
-// System.out.println(" -- Located RubyType info.");
-// System.out.println(" -- Superclass: " + rubyType.getSuperclassName() );
-
-// if ( rubyType != null ) {
-// String[] includedModuleNames = rubyType.getIncludedModuleNames();
-// if ( includedModuleNames != null ) {
-// for ( String moduleName : rubyType.getIncludedModuleNames() ) {
-// System.out.println(" -- Includes module: " + moduleName);
-// }
-// }
-// }
-
-
-
- // Get superclass and add its public members
- List<Node> superclassNodes = getSuperclassNodes( typeNode, script );
-
- for ( Node superclassNode : superclassNodes ) {
- elements.addAll( getMembersAvailableInsideType( superclassNode, script ) );
- }
-
- // Get public members of mixins
- List<String> mixinNames = getIncludedMixinNames( typeName, script );
- for ( String mixinName : mixinNames ) {
- List<Node> mixinDeclarations = getTypeDeclarationNodes( mixinName, script );
- for ( Node mixinDeclaration : mixinDeclarations ) {
- elements.addAll( getMembersAvailableInsideType( mixinDeclaration, script ) );
- }
- }
-
- // Get instance and class variables available in the enclosing type
- List<Node> instanceAndClassVars = ScopedNodeLocator.Instance().findNodesInScope(typeNode, new INodeAcceptor() {
- public boolean doesAccept(Node node) {
- return ( node instanceof InstVarNode ||
- node instanceof InstAsgnNode ||
- node instanceof ClassVarNode ||
- node instanceof ClassVarDeclNode ||
- node instanceof ClassVarAsgnNode );
- }
- });
-
- if ( instanceAndClassVars != null ) {
- // Get the unique names of instance and class variables
- Set instanceAndClassVarNames = new HashSet(instanceAndClassVars.size());
- for ( Node varNode : instanceAndClassVars ) {
- String name = getNameReflectively(varNode);
- if ( name != null ) {
- instanceAndClassVarNames.add(name);
- }
- }
-
- // Add instance and class variables to matched elements
- elements.addAll( instanceAndClassVarNames );
- }
-
- // Get method names defined by DefnNodes and DefsNodes
- List<Node> methodDefinitions = ScopedNodeLocator.Instance().findNodesInScope(typeNode, new INodeAcceptor() {
- public boolean doesAccept(Node node) {
- return ( node instanceof DefnNode ) || ( node instanceof DefsNode );
- }
- });
- for ( Node methodDefinition : methodDefinitions ) {
- if ( methodDefinition instanceof DefnNode ) { elements.add( ((DefnNode)methodDefinition).getName() ); }
- if ( methodDefinition instanceof DefsNode ) { elements.add( ((DefsNode)methodDefinition).getName() ); }
- }
-
- // Get instance and class vars defined by [c]attr_* calls
- elements.addAll( AttributeLocator.Instance().findInstanceAttributesInScope(typeNode) );
-
- return elements;
- }
-
- /**
- * Finds all nodes that declare a type that is a superclass of the specified node. Example:
- *
- * """
- * class Klass;def meth_1;1;end;end
- * class Klass;def meth_2;2;end;end
- *
- * class SubKlass < Klass;end
- * """
- *
- * Issuing getSuperClassNodes() on the ClassNode declaring SubKlass would return two ClassNodes;
- * one for each definition of Klass.
- *
- * @param typeNode Node to find superclass nodes of
- * @return List of ClassNode or ModuleNode
- */
- private List<Node> getSuperclassNodes( Node typeNode, IRubyScript script ) {
- if ( typeNode instanceof ClassNode ) {
- Node superNode = ((ClassNode)typeNode).getSuperNode();
- if ( superNode instanceof ConstNode ) {
- String superclassName = ((ConstNode)superNode).getName();
- return getTypeDeclarationNodes( superclassName, script );
- }
- }
-
- return new ArrayList<Node>();
- }
-
- private IType findTypeFromAllProjects(String typeName, IRubyScript rootScript) {
- // Grab the project and all referred projects
- List<IRubyProject> projects = new LinkedList<IRubyProject>();
- projects.add(rootScript.getRubyProject());
- projects.addAll(rootScript.getRubyProject().getReferencedProjects());
-
- List<IRubyProject> refProjects = rootScript.getRubyProject().getReferencedProjects();
-
- // Find the named type
- RubyElementRequestor completer = new RubyElementRequestor(projects.toArray(new IRubyProject[]{}));
- return completer.findType(typeName);
- }
-
- /** Lookup type declaration nodes */
- private List<Node> getTypeDeclarationNodes( String typeName, IRubyScript script ) {
- System.out.println("Being asked for the type decl node for " + typeName );
-
- // Find the named type
- IType type = findTypeFromAllProjects(typeName, script);
-
- try {
- if ( type instanceof RubyType ) {
-
- // FIXME This feels a little hacky and backwards - RubyType.getSource() and then parse... consider reworking the clients to this method to accept RubyTypes or something similar?
- // Find source and parse
- RubyType rubyType = (RubyType)type;
- String source = rubyType.getSource();
-
- // FIXME Why does the parser balk on \r chars?
- source = source.replace('\r', ' ');
- Node rootNode = (new RubyParser()).parse( source );
-
- // Bail if the parse fails
- if ( rootNode == null ) { return new ArrayList(); }
-
- // Return any type declaration nodes in included source
- return ScopedNodeLocator.Instance().findNodesInScope(rootNode, new INodeAcceptor() {
- public boolean doesAccept(Node node) {
- return ( node instanceof ClassNode ) ||
- ( node instanceof ModuleNode );
- }
- });
- }
-
- } catch ( RubyModelException rme ) {
- rme.printStackTrace();
- }
-
- return new ArrayList<Node>(0);
- }
-
- private List<String> getIncludedMixinNames( String typeName, IRubyScript script ) {
- IType rubyType = new RubyType( (RubyElement)script, typeName );
-
- try {
- String[] includedModuleNames = rubyType.getIncludedModuleNames();
- if ( includedModuleNames != null ) {
- return Arrays.asList(rubyType.getIncludedModuleNames());
- } else {
- return new ArrayList<String>(0);
- }
- } catch (RubyModelException e) {
- return new ArrayList<String>(0);
- }
- }
-
- /**
- * Gets the name of a node by reflectively invoking "getName()" on it;
- * helper method just to cut many "instanceof/cast" pairs.
- * @param node
- * @return name or null
- */
- // TODO Copy/pasted from DefaultOccurrencesFinder, refactor these two methods to a common location.
- private String getNameReflectively( Node node ) {
- try {
- Method getNameMethod = node.getClass().getMethod("getName", new Class[]{});
- Object name = getNameMethod.invoke( node, new Object[0] );
- return (String)name;
- } catch (Exception e) {
- return null;
- }
- }
-
-
private ICompletionProposal[] determineKeywordProposals(ITextViewer viewer,
int documentOffset) {
initKeywordProposals();
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java 2006-09-21 22:30:10 UTC (rev 1615)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java 2006-09-22 00:00:16 UTC (rev 1616)
@@ -206,26 +206,9 @@
// default:
// return null;
// }
- switch (proposal.getKind()) {
- case CompletionProposal.KEYWORD:
- return createKeywordProposal(proposal);
- case CompletionProposal.METHOD_REF:
- case CompletionProposal.METHOD_NAME_REFERENCE:
- return createMethodReferenceProposal(proposal);
- default:
- return createKeywordProposal(proposal);
- }
+ return createProposal(proposal);
}
- private IRubyCompletionProposal createMethodReferenceProposal(CompletionProposal proposal) {
- String completion= proposal.getCompletion();
- int start= proposal.getReplaceStart();
- int length= getLength(proposal);
- String label= proposal.getName();
- int relevance= computeRelevance(proposal);
- Image image = getImage(fLabelProvider.createImageDescriptor(proposal));
- return new RubyCompletionProposal(completion, start, length, image, label, relevance);
- }
/**
* Returns the ruby script that the receiver operates on, or
@@ -250,13 +233,14 @@
return (descriptor == null) ? null : fRegistry.get(descriptor);
}
- private IRubyCompletionProposal createKeywordProposal(CompletionProposal proposal) {
+ private IRubyCompletionProposal createProposal(CompletionProposal proposal) {
String completion= proposal.getCompletion();
int start= proposal.getReplaceStart();
int length= getLength(proposal);
String label= proposal.getName();
int relevance= computeRelevance(proposal);
- return new RubyCompletionProposal(completion, start, length, null, label, relevance);
+ Image image = getImage(fLabelProvider.createImageDescriptor(proposal));
+ return new RubyCompletionProposal(completion, start, length, image, label, relevance);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-09-21 22:30:19
|
Revision: 1615
http://svn.sourceforge.net/rubyeclipse/?rev=1615&view=rev
Author: cawilliams
Date: 2006-09-21 15:30:10 -0700 (Thu, 21 Sep 2006)
Log Message:
-----------
extract code completion into new CompletionEngine class, fix getSource() for RubyScript
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2006-09-21 22:30:10 UTC (rev 1615)
@@ -0,0 +1,129 @@
+package org.rubypeople.rdt.internal.codeassist;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.rubypeople.rdt.core.CompletionProposal;
+import org.rubypeople.rdt.core.CompletionRequestor;
+import org.rubypeople.rdt.core.Flags;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.ti.DefaultTypeInferrer;
+import org.rubypeople.rdt.internal.ti.ITypeGuess;
+import org.rubypeople.rdt.internal.ti.ITypeInferrer;
+
+public class CompletionEngine {
+ private CompletionRequestor requestor;
+
+ public CompletionEngine(CompletionRequestor requestor) {
+ this.requestor = requestor;
+ }
+
+ public void complete(IRubyScript script, int offset) throws RubyModelException {
+ this.requestor.beginReporting();
+ if (offset < 0)
+ offset = 0;
+ ITypeInferrer inferrer = new DefaultTypeInferrer();
+
+ StringBuffer source = new StringBuffer(script.getSource());
+ int replaceStart = offset + 1;
+ // Read from offset back until we hit a: space, period
+ // if we hit a period, use character before period as offset for
+ // inferrer
+ // if we hit a space, use character after space?
+ for (int i = offset; i >= 0; i--) {
+ char curChar = (char) source.charAt(i);
+ if (curChar == '.') {
+ if (offset == i) { // if it's the first character we looked at,
+ // fix syntax
+ source.deleteCharAt(i);
+ offset--;
+ break;
+ }
+ // TODO Grab the prefix we just ate up and use it to filter
+ // responses?
+ offset = i - 1;
+ break;
+ }
+ if (Character.isWhitespace(curChar)) {
+ offset = i + 1;
+ break;
+ }
+ }
+ System.out.println((char) source.charAt(offset));
+
+ List<ITypeGuess> guesses = inferrer.infer(source.toString(), offset);
+ // TODO Grab the project and all referred projects!
+ IRubyProject[] projects = new IRubyProject[1];
+ projects[0] = script.getRubyProject();
+ RubyElementRequestor completer = new RubyElementRequestor(projects);
+ for (Iterator iter = guesses.iterator(); iter.hasNext();) {
+ ITypeGuess guess = (ITypeGuess) iter.next();
+ IType type = completer.findType(guess.getType());
+ suggestMethods(requestor, replaceStart, completer, guess, type);
+ }
+ }
+
+ private void suggestMethods(CompletionRequestor requestor,
+ int replaceStart, RubyElementRequestor completer, ITypeGuess guess,
+ IType type) throws RubyModelException {
+ if (type == null)
+ return;
+
+ suggestMethods(requestor, replaceStart, guess.getConfidence(), type);
+ // Now grab methods from all the included modules
+ String[] modules = type.getIncludedModuleNames();
+ for (int x = 0; x < modules.length; x++) {
+ IType tmpType = completer.findType(modules[x]);
+ suggestMethods(requestor, replaceStart, guess.getConfidence(),
+ tmpType);
+ }
+ String superClass = type.getSuperclassName();
+ // FIXME This shouldn't happen! Object shouldn't be a parent of itself!
+ if (type.getElementName().equals("Object")
+ && superClass.equals("Object"))
+ return;
+ IType parentClass = completer.findType(superClass);
+ suggestMethods(requestor, replaceStart, completer, guess, parentClass);
+ }
+
+ private void suggestMethods(CompletionRequestor requestor,
+ int replaceStart, int confidence, IType type)
+ throws RubyModelException {
+ if (type == null)
+ return;
+ IMethod[] methods = type.getMethods();
+ for (int k = 0; k < methods.length; k++) {
+ IMethod method = methods[k];
+ String name = method.getElementName();
+ CompletionProposal proposal = new CompletionProposal(
+ CompletionProposal.METHOD_REF, name, confidence);
+ // TODO Handle replacement start index correctly
+ proposal
+ .setReplaceRange(replaceStart, replaceStart + name.length());
+ int flags = Flags.AccDefault;
+ if (method.isSingleton()) {
+ flags |= Flags.AccStatic;
+ }
+ switch (method.getVisibility()) {
+ case IMethod.PRIVATE:
+ flags |= Flags.AccPrivate;
+ break;
+ case IMethod.PUBLIC:
+ flags |= Flags.AccPublic;
+ break;
+ case IMethod.PROTECTED:
+ flags |= Flags.AccProtected;
+ break;
+ default:
+ break;
+ }
+ proposal.setFlags(flags);
+ requestor.accept(proposal);
+ }
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java 2006-09-17 00:02:25 UTC (rev 1614)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java 2006-09-21 22:30:10 UTC (rev 1615)
@@ -24,31 +24,22 @@
*/
package org.rubypeople.rdt.internal.core;
-import java.io.BufferedReader;
import java.io.CharArrayReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.jruby.ast.Node;
import org.jruby.lexer.yacc.SyntaxException;
-import org.rubypeople.rdt.core.CompletionProposal;
import org.rubypeople.rdt.core.CompletionRequestor;
-import org.rubypeople.rdt.core.Flags;
import org.rubypeople.rdt.core.IBuffer;
import org.rubypeople.rdt.core.ICodeAssist;
import org.rubypeople.rdt.core.IImportContainer;
import org.rubypeople.rdt.core.IImportDeclaration;
-import org.rubypeople.rdt.core.IMethod;
import org.rubypeople.rdt.core.IOpenable;
import org.rubypeople.rdt.core.IProblemRequestor;
import org.rubypeople.rdt.core.IRubyElement;
@@ -60,13 +51,10 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.WorkingCopyOwner;
-import org.rubypeople.rdt.internal.codeassist.RubyElementRequestor;
+import org.rubypeople.rdt.internal.codeassist.CompletionEngine;
import org.rubypeople.rdt.internal.core.buffer.BufferManager;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.core.util.Util;
-import org.rubypeople.rdt.internal.ti.DefaultTypeInferrer;
-import org.rubypeople.rdt.internal.ti.ITypeGuess;
-import org.rubypeople.rdt.internal.ti.ITypeInferrer;
/**
@@ -309,31 +297,10 @@
*
* @see org.rubypeople.rdt.core.ISourceReference#getSource()
*/
- public String getSource() {
- // TODO Cache the contents and only reload if the file hasn't changed!
- BufferedReader reader = null;
- String source = null;
- try {
- StringBuffer buffer = new StringBuffer();
- reader = new BufferedReader(new InputStreamReader(underlyingFile.getContents()));
- String line = null;
- while ((line = reader.readLine()) != null) {
- buffer.append(line);
- buffer.append("\n");
- }
- source = buffer.toString();
- } catch (CoreException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- if (reader != null) reader.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return source;
+ public String getSource() throws RubyModelException {
+ IBuffer buffer = getBuffer();
+ if (buffer == null) return ""; //$NON-NLS-1$
+ return buffer.getContents();
}
/**
@@ -664,77 +631,7 @@
}
public void codeComplete(int offset, CompletionRequestor requestor) throws RubyModelException {
- if (offset < 0) offset = 0;
- ITypeInferrer inferrer = new DefaultTypeInferrer();
-
- // FIXME Ugly hacking here to handle where we have invalid syntax by invoking after a period
- StringBuffer source = new StringBuffer(new String(getContents()));
- int replaceStart = offset + 1;
- char charAtOffset = (char) source.charAt(offset);
- if (charAtOffset == '.') {
- source.deleteCharAt(offset);
- offset--;
- }
- charAtOffset = (char) source.charAt(offset);
-
- List<ITypeGuess> guesses = inferrer.infer(source.toString(), offset);
- // TODO Grab the project and all referred projects!
- IRubyProject[] projects = new IRubyProject[1];
- projects[0] = getRubyProject();
- RubyElementRequestor completer = new RubyElementRequestor(projects);
- for (Iterator iter = guesses.iterator(); iter.hasNext();) {
- ITypeGuess guess = (ITypeGuess) iter.next();
- IType type = completer.findType(guess.getType());
- suggestMethods(requestor, replaceStart, completer, guess, type);
- }
+ CompletionEngine engine = new CompletionEngine(requestor);
+ engine.complete(this, offset);
}
-
- private void suggestMethods(CompletionRequestor requestor, int replaceStart, RubyElementRequestor completer, ITypeGuess guess, IType type) throws RubyModelException {
- if (type == null) return;
-
- suggestMethods(requestor, replaceStart, guess.getConfidence(), type);
- // Now grab methods from all the included modules
- String[] modules = type.getIncludedModuleNames();
- for (int x = 0; x < modules.length; x++) {
- IType tmpType = completer.findType(modules[x]);
- suggestMethods(requestor, replaceStart, guess.getConfidence(), tmpType);
- }
- String superClass = type.getSuperclassName();
-// FIXME This shouldn't happen! Object shouldn't be a parent of itself!
- if (type.getElementName().equals("Object") && superClass.equals("Object")) return;
- IType parentClass = completer.findType(superClass);
- suggestMethods(requestor, replaceStart, completer, guess, parentClass);
- }
-
- private void suggestMethods(CompletionRequestor requestor, int replaceStart, int confidence, IType type) throws RubyModelException {
- if (type == null) return;
- IMethod[] methods = type.getMethods();
- for (int k = 0; k < methods.length; k++) {
- IMethod method = methods[k];
- String name = method.getElementName();
- CompletionProposal proposal = new CompletionProposal(
- CompletionProposal.METHOD_REF, name, confidence);
- // TODO Handle replacement start index correctly
- proposal.setReplaceRange(replaceStart, replaceStart + name.length());
- int flags = Flags.AccDefault;
- if (method.isSingleton()){
- flags |= Flags.AccStatic;
- }
- switch (method.getVisibility()) {
- case IMethod.PRIVATE:
- flags |= Flags.AccPrivate;
- break;
- case IMethod.PUBLIC:
- flags |= Flags.AccPublic;
- break;
- case IMethod.PROTECTED:
- flags |= Flags.AccProtected;
- break;
- default:
- break;
- }
- proposal.setFlags(flags);
- requestor.accept(proposal);
- }
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2006-09-17 00:02:31
|
Revision: 1614
http://svn.sourceforge.net/rubyeclipse/?rev=1614&view=rev
Author: mirkostocker
Date: 2006-09-16 17:02:25 -0700 (Sat, 16 Sep 2006)
Log Message:
-----------
tests for the new DocumentationCommentRule
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TC_RubyPartitionScanner.java
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TC_RubyPartitionScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TC_RubyPartitionScanner.java 2006-09-17 00:01:21 UTC (rev 1613)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/text/TC_RubyPartitionScanner.java 2006-09-17 00:02:25 UTC (rev 1614)
@@ -38,14 +38,22 @@
assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 5));
assertEquals(IDocument.DEFAULT_CONTENT_TYPE, this.getContentType(source, 6));
}
-
+
public void testMultilineComment() {
String source = "=begin\nComment\n=end";
assertEquals(RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT, this.getContentType(source, 0));
assertEquals(RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT, this.getContentType(source, 10));
- }
-
+
+ source = "=begin\n"+
+ " for multiline comments, the =begin and =end must\n" +
+ " appear in the first column\n" +
+ "=end";
+ assertEquals(RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT, this.getContentType(source, 0));
+ assertEquals(RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT, this.getContentType(source, source.length() / 2));
+ assertEquals(RubyPartitionScanner.RUBY_MULTI_LINE_COMMENT, this.getContentType(source, source.length() - 1));
+ }
+
public void testMultilineCommentNotOnFirstColumn() {
String source = " =begin\nComment\n=end";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2006-09-17 00:01:31
|
Revision: 1613
http://svn.sourceforge.net/rubyeclipse/?rev=1613&view=rev
Author: mirkostocker
Date: 2006-09-16 17:01:21 -0700 (Sat, 16 Sep 2006)
Log Message:
-----------
new rule for documentation comments that checks if the =end is on the beginning of a line. fixes ticket#205.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/DocumentationCommentRule.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/DocumentationCommentRule.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/DocumentationCommentRule.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/DocumentationCommentRule.java 2006-09-17 00:01:21 UTC (rev 1613)
@@ -0,0 +1,51 @@
+package org.rubypeople.rdt.internal.ui.text;
+
+import java.io.EOFException;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.MultiLineRule;
+
+public class DocumentationCommentRule extends MultiLineRule {
+
+ private final static String endSequence = "=end";
+
+ public DocumentationCommentRule(IToken token) {
+ super("=begin", "", token);
+ setColumnConstraint(0);
+ }
+
+ @Override
+ protected boolean endSequenceDetected(ICharacterScanner scanner) {
+ if(scanner.getColumn() != 0)
+ return false;
+
+ String line = "";
+ do {
+ try {
+ line = readLine(scanner);
+ } catch (EOFException e) {
+ return true;
+ }
+ }
+ while(! endSequence.equals(line));
+
+ return true;
+ }
+
+ private String readLine(ICharacterScanner scanner) throws EOFException {
+ StringBuffer line = new StringBuffer();
+
+ while(true) {
+ int c = scanner.read();
+ if((char) c == '\n' || (char) c == '\r')
+ break;
+ else if (c == ICharacterScanner.EOF)
+ throw new EOFException();
+ else
+ line.append((char) c);
+ }
+
+ return line.toString();
+ }
+}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2006-09-11 20:02:13 UTC (rev 1612)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyPartitionScanner.java 2006-09-17 00:01:21 UTC (rev 1613)
@@ -115,12 +115,7 @@
}, "?", "/", Token.UNDEFINED));
rules.add(new EndOfLineRule("#", singleLineComment));
- // Multiline comments
- MultiLineRule multiLineCommentRule = new MultiLineRule("=begin",
- "=end", multiLineComment);
- multiLineCommentRule.setColumnConstraint(0);
- rules.add(multiLineCommentRule);
-
+ rules.add(new DocumentationCommentRule(multiLineComment));
rules.add(new HereDocPatternRule(hereDoc));
// FIXME Create Hyrbid of RuleBasedPartitionScanner which allows IRule
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-09-11 20:04:11
|
Revision: 1612
http://svn.sourceforge.net/rubyeclipse/?rev=1612&view=rev
Author: mbarchfe
Date: 2006-09-11 13:02:13 -0700 (Mon, 11 Sep 2006)
Log Message:
-----------
changes to generate docbook with jdk 1.5
Modified Paths:
--------------
trunk/org.rubypeople.rdt.doc.user/build.xml
trunk/org.rubypeople.rdt.doc.user/buildDocbook.xml
trunk/org.rubypeople.rdt.doc.user/customizationLayer.xsl
Added Paths:
-----------
trunk/org.rubypeople.rdt.doc.user/docbook/
trunk/org.rubypeople.rdt.doc.user/docbook/README
trunk/org.rubypeople.rdt.doc.user/docbook/docbook-xml-4.2.zip
trunk/org.rubypeople.rdt.doc.user/docbook/docbook-xsl-1.70.1.zip
trunk/org.rubypeople.rdt.doc.user/lib/
trunk/org.rubypeople.rdt.doc.user/lib/README
trunk/org.rubypeople.rdt.doc.user/lib/saxon_6.6.5.jar
Modified: trunk/org.rubypeople.rdt.doc.user/build.xml
===================================================================
--- trunk/org.rubypeople.rdt.doc.user/build.xml 2006-09-10 01:11:13 UTC (rev 1611)
+++ trunk/org.rubypeople.rdt.doc.user/build.xml 2006-09-11 20:02:13 UTC (rev 1612)
@@ -15,9 +15,6 @@
<property name="featureVersion" value="0.6.0"/>
<!-- featureVersion might also be set from outside -->
<echo message="Using featureVersion=${featureVersion}"/>
- <property name="docbook.root" value="../../docbook"/>
- <!-- docbook.root might also be set from outside -->
- <echo message="Using docbook.root=${docbook.root}"/>
<target name="init" depends="properties">
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
@@ -74,9 +71,7 @@
</target>
<target name="clean" depends="init" description="Clean the plug-in: org.rubypeople.rdt.doc.user of all the zips, jars and logs created.">
- <delete file="${plugin.destination}/org.rubypeople.rdt.doc.user_${featureVersion}.jar"/>
- <delete file="${plugin.destination}/org.rubypeople.rdt.doc.user_${featureVersion}.zip"/>
- <delete dir="${temp.folder}"/>
+ <ant antfile="buildDocbook.xml" target="clean"/>
</target>
<target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder.">
Modified: trunk/org.rubypeople.rdt.doc.user/buildDocbook.xml
===================================================================
--- trunk/org.rubypeople.rdt.doc.user/buildDocbook.xml 2006-09-10 01:11:13 UTC (rev 1611)
+++ trunk/org.rubypeople.rdt.doc.user/buildDocbook.xml 2006-09-11 20:02:13 UTC (rev 1612)
@@ -5,17 +5,26 @@
<echo message="Please always call this script from build.xml"/>
</target>
- <target name="init">
+ <property name="docbook.xsl.dir" value="docbook/docbook-xsl"/>
+ <property name="docbook.dtd.dir" value="docbook/dtd"/>
+
+ <available type="dir" file="${docbook.xsl.dir}" property="is.docbook.unpacked"/>
+
+ <target name="docbook.unpack" unless="is.docbook.unpacked">
+ <property name="docbook.xsl.version" value="1.70.1"/>
+ <unzip src="docbook/docbook-xsl-${docbook.xsl.version}.zip" dest="docbook"/>
+ <move file="docbook/docbook-xsl-${docbook.xsl.version}" tofile="${docbook.xsl.dir}" />
+ <mkdir dir="${docbook.dtd.dir}"/>
+ <unzip src="docbook/docbook-xml-4.2.zip" dest="${docbook.dtd.dir}"/>
+ </target>
+
+ <target name="init" depends="docbook.unpack">
<fail unless="featureVersion" message="Property featureVersion must be set. Please always call this script from build.xml"/>
- <fail unless="featureVersion" message="Property docbook.root must be set. Please always call this script from build.xml"/>
- <property name="docbook.xsl.dir" value="${docbook.root}/docbook-xsl-1.64.1"/>
- <property name="docbook.dtd.dir" value="${docbook.root}/dtd"/>
- <condition property="docbook.dir.exists">
- <available file="${docbook.root}"/>
- </condition>
+ <available type="dir" file="${docbook.xsl.dir}" property="did.unpack.work" />
+ <fail unless="did.unpack.work" message="Docbook xsl directory ${} was not created."/>
</target>
- <target name="clean.docbook.generated">
+ <target name="clean.docbook.generated">
<delete file="toc.xml"/>
<delete file="docbook.done"/>
<delete>
@@ -28,7 +37,6 @@
<copy file="customizationLayer.xsl" tofile="customizationLayerCopy.xsl"/>
<replace file="customizationLayerCopy.xsl">
<replacefilter token="@@VERSION@@" value="${featureVersion}"/>
- <replacefilter token="@@DOCBOOKROOT@@" value="${docbook.root}"/>
</replace>
</target>
@@ -38,9 +46,18 @@
</replace>
</target>
- <target name="html" depends="init,clean.docbook.generated,replaceVarInCustomizationLayer" if="docbook.dir.exists">
- <!--${docbook.xsl.dir}/eclipse/eclipse.xsl -->
- <style includes="docbook.xml" basedir="." destdir="." extension=".done" style="customizationLayerCopy.xsl">
+ <target name="html" depends="init,clean.docbook.generated,replaceVarInCustomizationLayer">
+ <!-- docbook recommends to use the saxon comiler. With jdk1.4 we could also use xalan (which ships with jdk1.4)
+ but with the jdk1.5 built-in XSLTC we get errors related to chunks.
+
+ Please also note that the saxon_6.6.5.jar has been modified *not* to register the AElfred parser as XML parser
+ -->
+ <style classpath="lib/saxon_6.6.5.jar"
+ includes="docbook.xml"
+ basedir="."
+ destdir="."
+ extension=".done"
+ style="customizationLayerCopy.xsl">
<param name="base.dir" expression="html/"/>
<param name="manifest.in.base.dir" expression="0"/>
<param name="eclipse.plugin.id" expression="org.rubypeople.rdt.doc.user"/>
@@ -53,4 +70,10 @@
<antcall target="replaceVersionInPluginXml"/>
</target>
+ <target name="clean">
+ <delete dir="${docbook.xsl.dir}"/>
+ <delete dir="${docbook.dtd.dir}"/>
+ <antcall target="clean.docbook.generated"/>
+ </target>
+
</project>
Modified: trunk/org.rubypeople.rdt.doc.user/customizationLayer.xsl
===================================================================
--- trunk/org.rubypeople.rdt.doc.user/customizationLayer.xsl 2006-09-10 01:11:13 UTC (rev 1611)
+++ trunk/org.rubypeople.rdt.doc.user/customizationLayer.xsl 2006-09-11 20:02:13 UTC (rev 1612)
@@ -7,7 +7,7 @@
an URIResolver. But thats probably more effort than replacing
the token @@DOCBOOKROOT@@ with ant -->
-<xsl:import href="@@DOCBOOKROOT@@/docbook-xsl-1.64.1/eclipse/eclipse.xsl"/>
+<xsl:import href="./docbook/docbook-xsl/eclipse/eclipse.xsl"/>
<xsl:param name="htmlhelp.title" >ABC</xsl:param>
Added: trunk/org.rubypeople.rdt.doc.user/docbook/README
===================================================================
--- trunk/org.rubypeople.rdt.doc.user/docbook/README (rev 0)
+++ trunk/org.rubypeople.rdt.doc.user/docbook/README 2006-09-11 20:02:13 UTC (rev 1612)
@@ -0,0 +1,7 @@
+Place the docbook dtd's and xsl scripts as zip file into this directory.
+The build process will unpack the xsl zip file into a folder docbook-xsl
+(by renaming the original directory entry which contains the version
+number). The dtds will be extracted into the folder dtd.
+
+Download the xsl files from http://sourceforge.net/projects/docbook/
+and the docbook dtds from http://www.docbook.org/xml.
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.doc.user/docbook/docbook-xml-4.2.zip
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.doc.user/docbook/docbook-xml-4.2.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.doc.user/docbook/docbook-xsl-1.70.1.zip
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.doc.user/docbook/docbook-xsl-1.70.1.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.doc.user/lib/README
===================================================================
--- trunk/org.rubypeople.rdt.doc.user/lib/README (rev 0)
+++ trunk/org.rubypeople.rdt.doc.user/lib/README 2006-09-11 20:02:13 UTC (rev 1612)
@@ -0,0 +1,13 @@
+The saxon lib was downloaded from http://saxon.sourceforge.net/.
+It has been modified not to prvide AElfred as XML parser by removing
+the jar file entry META-INF/services/javax.xml.parsers.SAXParserFactory.
+
+Aelfred seems to have a problem resolving the DTD mods. When
+using an xmlcatalog for the docbook DTD, it produces the following
+errormessage:
+
+java.net.MalformedURLException: no protocol: dbnotnx.mod
+
+: Fatal Error!
+Failure reading file:///C:/workspaces/rdt-subversive-workspace/org.rubypeople.rdt.doc.user/docbook.xml
+Cause: java.net.MalformedURLException: no protocol: dbnotnx.mod
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.doc.user/lib/saxon_6.6.5.jar
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.doc.user/lib/saxon_6.6.5.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2006-09-10 01:11:20
|
Revision: 1611
http://svn.sourceforge.net/rubyeclipse/?rev=1611&view=rev
Author: mirkostocker
Date: 2006-09-09 18:11:13 -0700 (Sat, 09 Sep 2006)
Log Message:
-----------
applied japgolly's patch for ticket #80
Modified Paths:
--------------
trunk/org.rubypeople.rdt.testunit/ruby/RemoteTestRunner.rb
Modified: trunk/org.rubypeople.rdt.testunit/ruby/RemoteTestRunner.rb
===================================================================
--- trunk/org.rubypeople.rdt.testunit/ruby/RemoteTestRunner.rb 2006-09-07 22:26:47 UTC (rev 1610)
+++ trunk/org.rubypeople.rdt.testunit/ruby/RemoteTestRunner.rb 2006-09-10 01:11:13 UTC (rev 1611)
@@ -127,9 +127,10 @@
end
def get_location(location)
+ location= location.join("\n") if location.is_a?(Array)
openingBracket = location.index('[')
if openingBracket
- return location[location.index('[') + 1, location.index(']') - 1].chop
+ return location[openingBracket + 1, location.index(']') - openingBracket].chop
else
# the stack trace from ruby 1.8.2 pre 3 on windows is formatted like follows:
# file:lineNo:in 'methodName'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-09-07 22:26:53
|
Revision: 1610
http://svn.sourceforge.net/rubyeclipse/?rev=1610&view=rev
Author: cawilliams
Date: 2006-09-07 15:26:47 -0700 (Thu, 07 Sep 2006)
Log Message:
-----------
add link to my blog (not just the name of it, duh!)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.webpage/htdocs/welcome.php
Modified: trunk/org.rubypeople.rdt.webpage/htdocs/welcome.php
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Markus B. <mba...@us...> - 2006-09-06 20:02:22
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv22408/src/org/rubypeople/rdt/internal/ui/search Modified Files: Tag: SRB_0-8-1 RubySearchPage.java Log Message: dirty fix for 3.2 compatibility Index: RubySearchPage.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPage.java,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** RubySearchPage.java 17 Feb 2006 20:28:07 -0000 1.6 --- RubySearchPage.java 6 Sep 2006 20:02:18 -0000 1.6.2.1 *************** *** 230,236 **** */ case ISearchPageContainer.WORKING_SET_SCOPE: ! IWorkingSet[] workingSets = getContainer().getSelectedWorkingSets(); ! String desc = Messages.format(SearchMessages.WorkingSetScope, ScopePart ! .toString(workingSets)); // scope = SearchScope.newSearchScope(desc, workingSets); } --- 230,236 ---- */ case ISearchPageContainer.WORKING_SET_SCOPE: ! // IWorkingSet[] workingSets = getContainer().getSelectedWorkingSets(); ! // String desc = Messages.format(SearchMessages.WorkingSetScope, ScopePart ! // .toString(workingSets)); // scope = SearchScope.newSearchScope(desc, workingSets); } |
|
From: Markus B. <mba...@us...> - 2006-09-06 18:53:24
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.ui In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv26873 Modified Files: Tag: SRB_0-8-1 plugin.xml Log Message: added categoryID Index: plugin.xml =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.ui/plugin.xml,v retrieving revision 1.48 retrieving revision 1.48.2.1 diff -C2 -d -r1.48 -r1.48.2.1 *** plugin.xml 4 Feb 2006 11:48:35 -0000 1.48 --- plugin.xml 6 Sep 2006 18:53:19 -0000 1.48.2.1 *************** *** 288,293 **** </extension> <extension point="org.eclipse.ui.commands"> ! <command name="Inspect Template" ! id="org.rubypeople.rdt.debug.ui.TemplateInspectCommand"/> </extension> --- 288,295 ---- </extension> <extension point="org.eclipse.ui.commands"> ! <command ! categoryId="org.eclipse.debug.ui.category.run" ! id="org.rubypeople.rdt.debug.ui.TemplateInspectCommand" ! name="Inspect Template"/> </extension> *************** *** 313,315 **** </actionSet> </extension> ! </plugin> \ No newline at end of file --- 315,317 ---- </actionSet> </extension> ! </plugin> |
|
From: Markus B. <mba...@us...> - 2006-09-06 18:53:01
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt-feature In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv26495 Modified Files: Tag: SRB_0-8-1 feature.xml Log Message: removed nl tag set unpack= true for feature plug-in. Otherwise the feature wont be displayed in the feature list Index: feature.xml =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt-feature/feature.xml,v retrieving revision 1.35 retrieving revision 1.35.2.1 diff -C2 -d -r1.35 -r1.35.2.1 *** feature.xml 5 Feb 2006 19:25:04 -0000 1.35 --- feature.xml 6 Sep 2006 18:52:57 -0000 1.35.2.1 *************** *** 5,10 **** version="0.0.0" provider-name="RubyPeople" ! plugin="org.rubypeople.rdt" ! nl="en"> <description> --- 5,9 ---- version="0.0.0" provider-name="RubyPeople" ! plugin="org.rubypeople.rdt"> <description> *************** *** 298,302 **** install-size="0" version="0.0.0" ! unpack="false"/> <plugin --- 297,301 ---- install-size="0" version="0.0.0" ! unpack="true"/> <plugin |
|
From: Markus B. <mba...@us...> - 2006-09-06 18:43:12
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv23887 Modified Files: Tag: SRB_0-8-1 plugin.xml Log Message: corrected typo Index: plugin.xml =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/plugin.xml,v retrieving revision 1.82 retrieving revision 1.82.2.1 diff -C2 -d -r1.82 -r1.82.2.1 *** plugin.xml 21 Apr 2006 21:13:29 -0000 1.82 --- plugin.xml 6 Sep 2006 18:43:07 -0000 1.82.2.1 *************** *** 464,468 **** name="%ActionDefinition.toggleComment.name" description="%ActionDefinition.toggleComment.description" ! categoryId="org.eubypeople.rdt.ui.category.source" id="org.rubypeople.rdt.ui.edit.text.ruby.toggle.comment "> </command> --- 464,468 ---- name="%ActionDefinition.toggleComment.name" description="%ActionDefinition.toggleComment.description" ! categoryId="org.rubypeople.rdt.ui.category.source" id="org.rubypeople.rdt.ui.edit.text.ruby.toggle.comment "> </command> |
|
From: <mba...@us...> - 2006-09-05 20:52:52
|
Revision: 1609
http://svn.sourceforge.net/rubyeclipse/?rev=1609&view=rev
Author: mbarchfe
Date: 2006-09-05 13:52:45 -0700 (Tue, 05 Sep 2006)
Log Message:
-----------
removed nl entry
Modified Paths:
--------------
trunk/org.rubypeople.rdt-feature/feature.xml
Modified: trunk/org.rubypeople.rdt-feature/feature.xml
===================================================================
--- trunk/org.rubypeople.rdt-feature/feature.xml 2006-09-05 20:15:28 UTC (rev 1608)
+++ trunk/org.rubypeople.rdt-feature/feature.xml 2006-09-05 20:52:45 UTC (rev 1609)
@@ -4,8 +4,7 @@
label="Ruby Development Tools"
version="0.0.0"
provider-name="RubyPeople"
- plugin="org.rubypeople.rdt"
- nl="en">
+ plugin="org.rubypeople.rdt">
<description>
Ruby Development Tools for Eclipse.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-09-05 20:15:35
|
Revision: 1608
http://svn.sourceforge.net/rubyeclipse/?rev=1608&view=rev
Author: mbarchfe
Date: 2006-09-05 13:15:28 -0700 (Tue, 05 Sep 2006)
Log Message:
-----------
set unpack=true for the feature plug-in
Modified Paths:
--------------
trunk/org.rubypeople.rdt-feature/feature.xml
Modified: trunk/org.rubypeople.rdt-feature/feature.xml
===================================================================
--- trunk/org.rubypeople.rdt-feature/feature.xml 2006-09-02 20:57:58 UTC (rev 1607)
+++ trunk/org.rubypeople.rdt-feature/feature.xml 2006-09-05 20:15:28 UTC (rev 1608)
@@ -297,7 +297,7 @@
download-size="0"
install-size="0"
version="0.0.0"
- unpack="false"/>
+ unpack="true"/>
<plugin
id="org.rubypeople.rdt.testunit"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-09-02 20:58:05
|
Revision: 1607
http://svn.sourceforge.net/rubyeclipse/?rev=1607&view=rev
Author: cawilliams
Date: 2006-09-02 13:57:58 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
a new label provider for completion proposals
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/CompletionProposalLabelProvider.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/CompletionProposalLabelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/CompletionProposalLabelProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/CompletionProposalLabelProvider.java 2006-09-02 20:57:58 UTC (rev 1607)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.text.ruby;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.jface.text.Assert;
+import org.rubypeople.rdt.core.CompletionProposal;
+import org.rubypeople.rdt.core.Flags;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.internal.ui.viewsupport.RubyElementImageProvider;
+import org.rubypeople.rdt.ui.RubyElementImageDescriptor;
+
+/**
+ * Provides labels for ruby content assist proposals. The functionality is
+ * similar to the one provided by {@link org.rubypeople.rdt.ui.RubyElementLabels},
+ * but based on signatures and {@link CompletionProposal}s.
+ *
+ * @see Signature
+ * @since 3.1
+ */
+public class CompletionProposalLabelProvider {
+ /**
+ * Creates and returns a decorated image descriptor for a completion
+ * proposal.
+ *
+ * @param proposal
+ * the proposal for which to create an image descriptor
+ * @return the created image descriptor, or <code>null</code> if no image
+ * is available
+ */
+ public ImageDescriptor createImageDescriptor(CompletionProposal proposal) {
+ final int flags = proposal.getFlags();
+
+ ImageDescriptor descriptor;
+ switch (proposal.getKind()) {
+ case CompletionProposal.METHOD_DECLARATION:
+ case CompletionProposal.METHOD_NAME_REFERENCE:
+ case CompletionProposal.METHOD_REF:
+ case CompletionProposal.POTENTIAL_METHOD_DECLARATION:
+ descriptor = RubyElementImageProvider.getMethodImageDescriptor(flags);
+ break;
+ case CompletionProposal.TYPE_REF:
+ descriptor = RubyElementImageProvider.getTypeImageDescriptor(
+ false, false, false);
+ break;
+ case CompletionProposal.FIELD_REF:
+ descriptor = RubyElementImageProvider.getFieldImageDescriptor();
+ break;
+ case CompletionProposal.LOCAL_VARIABLE_REF:
+ case CompletionProposal.VARIABLE_DECLARATION:
+ descriptor = RubyPluginImages.DESC_OBJS_LOCAL_VAR;
+ break;
+ case CompletionProposal.KEYWORD:
+ descriptor = null;
+ break;
+ default:
+ descriptor = null;
+ Assert.isTrue(false);
+ }
+
+ if (descriptor == null)
+ return null;
+ return decorateImageDescriptor(descriptor, proposal);
+ }
+
+ /**
+ * Returns a version of <code>descriptor</code> decorated according to
+ * the passed <code>modifier</code> flags.
+ *
+ * @param descriptor the image descriptor to decorate
+ * @param proposal the proposal
+ * @return an image descriptor for a method proposal
+ * @see Flags
+ */
+ private ImageDescriptor decorateImageDescriptor(ImageDescriptor descriptor, CompletionProposal proposal) {
+ int adornments= 0;
+ int flags= proposal.getFlags();
+ int kind= proposal.getKind();
+
+ if (kind == CompletionProposal.FIELD_REF || kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.METHOD_DECLARATION || kind == CompletionProposal.METHOD_NAME_REFERENCE || kind == CompletionProposal.METHOD_REF)
+ if (Flags.isStatic(flags))
+ adornments |= RubyElementImageDescriptor.STATIC;
+
+ return new RubyElementImageDescriptor(descriptor, adornments, RubyElementImageProvider.SMALL_SIZE);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-09-02 20:57:29
|
Revision: 1606
http://svn.sourceforge.net/rubyeclipse/?rev=1606&view=rev
Author: cawilliams
Date: 2006-09-02 13:57:25 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
create method proposals differently from keywords, use a method image
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java 2006-09-02 20:56:55 UTC (rev 1605)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java 2006-09-02 20:57:25 UTC (rev 1606)
@@ -24,6 +24,7 @@
/** Tells whether this class is in debug mode. */
private static final boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.rubypeople.rdt.ui/debug/ResultCollector")); //$NON-NLS-1$//$NON-NLS-2$
+ private final CompletionProposalLabelProvider fLabelProvider= new CompletionProposalLabelProvider();
private final ImageDescriptorRegistry fRegistry= RubyPlugin.getImageDescriptorRegistry();
/** Triggers for variables. Do not modify. */
@@ -188,7 +189,7 @@
protected IRubyCompletionProposal createRubyCompletionProposal(CompletionProposal proposal) {
// switch (proposal.getKind()) {
// case CompletionProposal.KEYWORD:
- return createKeywordProposal(proposal);
+// return createKeywordProposal(proposal);
// case CompletionProposal.TYPE_REF:
// return createTypeProposal(proposal);
// case CompletionProposal.FIELD_REF:
@@ -205,11 +206,39 @@
// default:
// return null;
// }
+ switch (proposal.getKind()) {
+ case CompletionProposal.KEYWORD:
+ return createKeywordProposal(proposal);
+ case CompletionProposal.METHOD_REF:
+ case CompletionProposal.METHOD_NAME_REFERENCE:
+ return createMethodReferenceProposal(proposal);
+ default:
+ return createKeywordProposal(proposal);
+ }
}
+ private IRubyCompletionProposal createMethodReferenceProposal(CompletionProposal proposal) {
+ String completion= proposal.getCompletion();
+ int start= proposal.getReplaceStart();
+ int length= getLength(proposal);
+ String label= proposal.getName();
+ int relevance= computeRelevance(proposal);
+ Image image = getImage(fLabelProvider.createImageDescriptor(proposal));
+ return new RubyCompletionProposal(completion, start, length, image, label, relevance);
+ }
+ /**
+ * Returns the ruby script that the receiver operates on, or
+ * <code>null</code> if the <code>IRubyProject</code> constructor was
+ * used to create the receiver.
+ *
+ * @return the ruby script that the receiver operates on, or
+ * <code>null</code>
+ */
+ protected final IRubyScript getRubyScript() {
+ return fRubyScript;
+ }
-
/**
* Returns a cached image for the given descriptor.
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-09-02 20:57:00
|
Revision: 1605
http://svn.sourceforge.net/rubyeclipse/?rev=1605&view=rev
Author: cawilliams
Date: 2006-09-02 13:56:55 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
remove unused method and import, add hack code to temporarily fix syntax error before passing to parser, remove debug output
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCompletionProcessor.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCompletionProcessor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCompletionProcessor.java 2006-09-02 20:55:40 UTC (rev 1604)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyCompletionProcessor.java 2006-09-02 20:56:55 UTC (rev 1605)
@@ -42,25 +42,21 @@
import org.jruby.ast.Node;
import org.jruby.ast.ScopeNode;
import org.jruby.lexer.yacc.SyntaxException;
-import org.jruby.parser.RubyParserPool;
import org.rubypeople.rdt.core.IParent;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.ISourceReference;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.codeassist.RubyElementRequestor;
import org.rubypeople.rdt.internal.core.RubyElement;
import org.rubypeople.rdt.internal.core.RubyScript;
-import org.rubypeople.rdt.internal.core.RubyScriptStructureBuilder;
import org.rubypeople.rdt.internal.core.RubyType;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.corext.template.ruby.RubyContextType;
import org.rubypeople.rdt.internal.ti.util.AttributeLocator;
import org.rubypeople.rdt.internal.ti.util.ClosestSpanningNodeLocator;
import org.rubypeople.rdt.internal.ti.util.INodeAcceptor;
-import org.rubypeople.rdt.internal.ti.util.MethodDefinitionLocator;
import org.rubypeople.rdt.internal.ti.util.ScopedNodeLocator;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.RubyPluginImages;
@@ -381,6 +377,18 @@
source = script.getSource();
}
+ // FIXME Ugly hacking here to handle where we have invalid syntax by invoking after a period
+ StringBuffer sourceBuff = new StringBuffer(source);
+ offset--;
+ char charAtOffset = (char) sourceBuff.charAt(offset);
+ if (charAtOffset == '.') {
+ sourceBuff.deleteCharAt(offset);
+ offset--;
+ }
+ source = sourceBuff.toString();
+
+ // XXX Combine this code with the code in RubyScript.codeComplete() (into a new CompletionEngine class?)
+
// Get all references projects
List<IRubyProject> projects = new ArrayList<IRubyProject>();
projects.add(script.getRubyProject());
@@ -422,9 +430,6 @@
// Add all globals, classes, and modules
for (Iterator iter = projects.iterator(); iter.hasNext();) {
IRubyProject nextProject = (IRubyProject)(iter.next());
-
- System.out.println("*** Adding globals/classes/modules available in project: " + nextProject.getElementName() );
-
elements.addAll(getElementsOfType( nextProject, new int[] { IRubyElement.GLOBAL }));
elements.addAll(addClassesAndModulesInProject( nextProject ));
}
@@ -469,18 +474,6 @@
}
/**
- * @param script
- * @return
- */
- private Collection getElements(IParent element) {
- return getElementsOfType(element, new int[] { IRubyElement.TYPE,
- IRubyElement.METHOD, IRubyElement.GLOBAL,
- IRubyElement.CONSTANT, IRubyElement.CLASS_VAR,
- IRubyElement.INSTANCE_VAR });
- }
-
-
- /**
* Gets the memebrs available inside a type node (ModuleNode, ClassNode):
* - Instance variables
* - Class variables
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-09-02 20:55:46
|
Revision: 1604
http://svn.sourceforge.net/rubyeclipse/?rev=1604&view=rev
Author: cawilliams
Date: 2006-09-02 13:55:40 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
set completion proposal flags
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java 2006-09-02 20:55:14 UTC (rev 1603)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java 2006-09-02 20:55:40 UTC (rev 1604)
@@ -43,6 +43,7 @@
import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.CompletionProposal;
import org.rubypeople.rdt.core.CompletionRequestor;
+import org.rubypeople.rdt.core.Flags;
import org.rubypeople.rdt.core.IBuffer;
import org.rubypeople.rdt.core.ICodeAssist;
import org.rubypeople.rdt.core.IImportContainer;
@@ -675,7 +676,6 @@
offset--;
}
charAtOffset = (char) source.charAt(offset);
- System.out.println(charAtOffset);
List<ITypeGuess> guesses = inferrer.infer(source.toString(), offset);
// TODO Grab the project and all referred projects!
@@ -684,8 +684,6 @@
RubyElementRequestor completer = new RubyElementRequestor(projects);
for (Iterator iter = guesses.iterator(); iter.hasNext();) {
ITypeGuess guess = (ITypeGuess) iter.next();
- System.out.println("Type Inferrer thinks this is a: "
- + guess.getType());
IType type = completer.findType(guess.getType());
suggestMethods(requestor, replaceStart, completer, guess, type);
}
@@ -712,11 +710,30 @@
if (type == null) return;
IMethod[] methods = type.getMethods();
for (int k = 0; k < methods.length; k++) {
- String name = methods[k].getElementName();
+ IMethod method = methods[k];
+ String name = method.getElementName();
CompletionProposal proposal = new CompletionProposal(
CompletionProposal.METHOD_REF, name, confidence);
// TODO Handle replacement start index correctly
proposal.setReplaceRange(replaceStart, replaceStart + name.length());
+ int flags = Flags.AccDefault;
+ if (method.isSingleton()){
+ flags |= Flags.AccStatic;
+ }
+ switch (method.getVisibility()) {
+ case IMethod.PRIVATE:
+ flags |= Flags.AccPrivate;
+ break;
+ case IMethod.PUBLIC:
+ flags |= Flags.AccPublic;
+ break;
+ case IMethod.PROTECTED:
+ flags |= Flags.AccProtected;
+ break;
+ default:
+ break;
+ }
+ proposal.setFlags(flags);
requestor.accept(proposal);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-09-02 20:55:24
|
Revision: 1603
http://svn.sourceforge.net/rubyeclipse/?rev=1603&view=rev
Author: cawilliams
Date: 2006-09-02 13:55:14 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
add some more flags
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java 2006-09-02 20:54:53 UTC (rev 1602)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/Flags.java 2006-09-02 20:55:14 UTC (rev 1603)
@@ -3,16 +3,55 @@
public class Flags {
- public static boolean isPublic(int flags) {
- return flags == IMethod.PUBLIC;
- }
+ /*
+ * Modifiers
+ */
+ public static final int AccPublic = 0x0001;
+ public static final int AccPrivate = 0x0002;
+ public static final int AccProtected = 0x0004;
+ public static final int AccStatic = 0x0008;
+
+ /**
+ * Constant representing the absence of any flag
+ * @since 3.0
+ */
+ public static final int AccDefault = 0;
- public static boolean isProtected(int flags) {
- return flags == IMethod.PROTECTED;
- }
+ /**
+ * Returns whether the given integer includes the <code>private</code> modifier.
+ *
+ * @param flags the flags
+ * @return <code>true</code> if the <code>private</code> modifier is included
+ */
+ public static boolean isPrivate(int flags) {
+ return (flags & AccPrivate) != 0;
+ }
+ /**
+ * Returns whether the given integer includes the <code>protected</code> modifier.
+ *
+ * @param flags the flags
+ * @return <code>true</code> if the <code>protected</code> modifier is included
+ */
+ public static boolean isProtected(int flags) {
+ return (flags & AccProtected) != 0;
+ }
+ /**
+ * Returns whether the given integer includes the <code>public</code> modifier.
+ *
+ * @param flags the flags
+ * @return <code>true</code> if the <code>public</code> modifier is included
+ */
+ public static boolean isPublic(int flags) {
+ return (flags & AccPublic) != 0;
+ }
+ /**
+ * Returns whether the given integer includes the <code>static</code> modifier.
+ *
+ * @param flags the flags
+ * @return <code>true</code> if the <code>static</code> modifier is included
+ */
+ public static boolean isStatic(int flags) {
+ return (flags & AccStatic) != 0;
+ }
- public static boolean isPrivate(int modifierFlags) {
- return modifierFlags == IMethod.PRIVATE;
- }
-
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java 2006-09-02 20:54:53 UTC (rev 1602)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java 2006-09-02 20:55:14 UTC (rev 1603)
@@ -31,9 +31,9 @@
*/
public interface IMethod extends IRubyElement, IMember {
- public static final int PUBLIC = 0;
- public static final int PROTECTED = 1;
- public static final int PRIVATE = 2;
+ public static final int PUBLIC = Flags.AccPublic;
+ public static final int PROTECTED = Flags.AccProtected;
+ public static final int PRIVATE = Flags.AccPrivate;
public int getVisibility() throws RubyModelException;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-09-02 20:54:58
|
Revision: 1602
http://svn.sourceforge.net/rubyeclipse/?rev=1602&view=rev
Author: cawilliams
Date: 2006-09-02 13:54:53 -0700 (Sat, 02 Sep 2006)
Log Message:
-----------
add flags to completion proposals
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionProposal.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionProposal.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionProposal.java 2006-08-31 01:12:25 UTC (rev 1601)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionProposal.java 2006-09-02 20:54:53 UTC (rev 1602)
@@ -1,6 +1,5 @@
package org.rubypeople.rdt.core;
-
public class CompletionProposal {
public static final int FIELD_REF = 2;
@@ -85,6 +84,7 @@
* Defaults to null.
*/
private String name = null;
+ private int flags;
public CompletionProposal(int kind, String completion, int relevance) {
this.completionKind = kind;
@@ -119,6 +119,73 @@
public String getName() {
return name;
}
+
+ /**
+ * Returns the modifier flags relevant in the context, or
+ * <code>Flags.AccDefault</code> if none.
+ * <p>
+ * This field is available for the following kinds of
+ * completion proposals:
+ * <ul>
+ * <li><code>ANNOTATION_ATTRIBUT_REF</code> - modifier flags
+ * of the attribute that is referenced;
+ * <li><code>ANONYMOUS_CLASS_DECLARATION</code> - modifier flags
+ * of the constructor that is referenced</li>
+ * <li><code>FIELD_REF</code> - modifier flags
+ * of the field that is referenced;
+ * <code>Flags.AccEnum</code> can be used to recognize
+ * references to enum constants
+ * </li>
+ * <li><code>KEYWORD</code> - modifier flag
+ * corrresponding to the modifier keyword</li>
+ * <li><code>LOCAL_VARIABLE_REF</code> - modifier flags
+ * of the local variable that is referenced</li>
+ * <li><code>METHOD_REF</code> - modifier flags
+ * of the method that is referenced;
+ * <code>Flags.AccAnnotation</code> can be used to recognize
+ * references to annotation type members
+ * </li>
+ * <li><code>METHOD_DECLARATION</code> - modifier flags
+ * for the method that is being implemented or overridden</li>
+ * <li><code>TYPE_REF</code> - modifier flags
+ * of the type that is referenced; <code>Flags.AccInterface</code>
+ * can be used to recognize references to interfaces,
+ * <code>Flags.AccEnum</code> enum types,
+ * and <code>Flags.AccAnnotation</code> annotation types
+ * </li>
+ * <li><code>VARIABLE_DECLARATION</code> - modifier flags
+ * for the variable being declared</li>
+ * <li><code>POTENTIAL_METHOD_DECLARATION</code> - modifier flags
+ * for the method that is being created</li>
+ * </ul>
+ * For other kinds of completion proposals, this method returns
+ * <code>Flags.AccDefault</code>.
+ * </p>
+ *
+ * @return the modifier flags, or
+ * <code>Flags.AccDefault</code> if none
+ * @see Flags
+ */
+ public int getFlags() {
+ return this.flags;
+ }
+
+ /**
+ * Sets the modifier flags relevant in the context.
+ * <p>
+ * If not set, defaults to none.
+ * </p>
+ * <p>
+ * The completion engine creates instances of this class and sets
+ * its properties; this method is not intended to be used by other clients.
+ * </p>
+ *
+ * @param flags the modifier flags, or
+ * <code>Flags.AccDefault</code> if none
+ */
+ public void setFlags(int flags) {
+ this.flags = flags;
+ }
public void setReplaceRange(int startIndex, int endIndex) {
if (startIndex < 0 || endIndex < startIndex) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|