|
From: <caw...@us...> - 2007-07-05 14:46:42
|
Revision: 2713
http://svn.sourceforge.net/rubyeclipse/?rev=2713&view=rev
Author: cawilliams
Date: 2007-07-05 07:46:40 -0700 (Thu, 05 Jul 2007)
Log Message:
-----------
add tests and fix to handle files whose path looks absolute but is actually relative to the workspace
(i.e. /app/controllers/tags_controller.rb)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/TC_RubyConsoleTracker.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/StackTraceLine.java
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TC_StackTraceLine.java
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/TC_RubyConsoleTracker.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/TC_RubyConsoleTracker.java 2007-07-05 14:03:13 UTC (rev 2712)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/TC_RubyConsoleTracker.java 2007-07-05 14:46:40 UTC (rev 2713)
@@ -77,6 +77,26 @@
console.assertLinkCount(0);
}
+ /**
+ * From http://www.aptana.com/trac/ticket/5019
+ * @throws Exception
+ */
+ public void testBackslashesInFilePath() throws Exception {
+ fileChecker.addKnownFile("C:\\ruby\\lib\\ruby\\gems\\1.8\\gems\\rails-1.2.3\\lib/commands/server.rb");
+
+ console.lineAppend("\tfrom C:\\ruby\\lib\\ruby\\gems\\1.8\\gems\\rails-1.2.3\\lib/commands/server.rb:1") ;
+ console.assertLinkCount(1);
+ console.assertLink(6, 67, "C:\\ruby\\lib\\ruby\\gems\\1.8\\gems\\rails-1.2.3\\lib/commands/server.rb", 1, 0);
+ }
+
+ public void testWorkspaceRelativeStartingWithSlash() throws Exception {
+ fileChecker.addKnownFile("/app/controllers/tags_controller.rb");
+
+ console.lineAppend("\t/app/controllers/tags_controller.rb:5:in `index'") ;
+ console.assertLinkCount(1);
+ console.assertLink(1, 37, "/app/controllers/tags_controller.rb", 5, 0);
+ }
+
private final class MockFileExistanceChecker implements RubyConsoleTracker.FileExistanceChecker {
private List knownFiles = new ArrayList();
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/StackTraceLine.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/StackTraceLine.java 2007-07-05 14:03:13 UTC (rev 2712)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/StackTraceLine.java 2007-07-05 14:46:40 UTC (rev 2713)
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.rubypeople.rdt.internal.ui.util;
+import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -77,17 +78,22 @@
private void makeRelativeToWorkspace(IProject launchedProject) {
if (fFilename.startsWith("./")) {
fFilename = launchedProject.getFullPath().toPortableString() + fFilename.substring(1);
- return;
+ } else if (fFilename.startsWith("/")) {
+ fFilename = launchedProject.getFullPath().toPortableString() + fFilename;
} else {
fFilename = launchedProject.getFullPath().toPortableString() + '/' + fFilename;
- }
-
+ }
}
private boolean isRelativePath() {
if (fFilename.startsWith("./")) return true;
+ if (fFilename.startsWith("/")) { // If it starts with '/' it could be relative to workspace or absolute on *-nix!
+ File file = new File(fFilename);
+ if (file.exists()) return false;
+ return true;
+ }
int index = fFilename.indexOf('/');
- if (index != -1 && !fFilename.startsWith("/") && fFilename.charAt(index - 1) != ':' ) return true;
+ if (index != -1 && fFilename.charAt(index - 1) != ':' ) return true;
return false;
}
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TC_StackTraceLine.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TC_StackTraceLine.java 2007-07-05 14:03:13 UTC (rev 2712)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TC_StackTraceLine.java 2007-07-05 14:46:40 UTC (rev 2713)
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.rubypeople.rdt.internal.ui;
+import org.rubypeople.eclipse.shams.resources.ShamProject;
import org.rubypeople.rdt.internal.ui.util.StackTraceLine;
import junit.framework.TestCase;
@@ -22,6 +23,7 @@
private static final String ODD_WITH_FROM = " ^ from /RdtTestLib/anotherFile.rb:4";
private static final String WITH_OUT_FROM = "/RdtTestLib/anotherFile.rb:4";
private static final String WITH_TRAILING_SPACE = "/RdtTestLib/anotherFile.rb:4 ";
+ private static final String LOOKS_ABSOLUTE = "\t/app/controllers/tags_controller.rb:5:in `index'";
public void testWithFrom() {
assertFalse("has a stack trace", StackTraceLine.isTraceLine(WITH_TRAILING_SPACE));
@@ -94,6 +96,15 @@
assertEquals("Line Number", 12, traceLine.getLineNumber());
assertEquals("Offset", 3, traceLine.offset());
assertEquals("Length", 29, traceLine.length());
+ }
+
+ public void testLooksAbsoluteButIsRelativeToProject() {
+ StackTraceLine traceLine = new StackTraceLine(LOOKS_ABSOLUTE, new ShamProject("testing"));
+
+ assertEquals("Filename", "/testing/app/controllers/tags_controller.rb", traceLine.getFilename());
+ assertEquals("Line Number", 5, traceLine.getLineNumber());
+ assertEquals("Offset", 1, traceLine.offset());
+ assertEquals("Length", 37, traceLine.length());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|