|
From: <caw...@us...> - 2007-05-30 20:16:50
|
Revision: 2563
http://svn.sourceforge.net/rubyeclipse/?rev=2563&view=rev
Author: cawilliams
Date: 2007-05-30 13:16:38 -0700 (Wed, 30 May 2007)
Log Message:
-----------
fix Trac ticket #4588 - Error Stack Track Hypering Linking
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/console/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/src/org/rubypeople/rdt/internal/debug/ui/console/RubyConsoleTracker.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/console/RubyConsoleTracker.java 2007-05-30 19:36:18 UTC (rev 2562)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/console/RubyConsoleTracker.java 2007-05-30 20:16:38 UTC (rev 2563)
@@ -22,12 +22,18 @@
import java.io.File;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.debug.ui.console.IConsoleLineTracker;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.console.IHyperlink;
import org.rubypeople.rdt.internal.ui.util.StackTraceLine;
+import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
/**
* Provides links for stack traces, eg:
@@ -49,7 +55,10 @@
public boolean fileExists(String filename) {
File file = new File(filename);
- return file.exists();
+ if (file.exists()) return true;
+ IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filename));
+ if (iFile != null) return true;
+ return false;
}
}
private final FileExistanceChecker existanceChecker;
@@ -89,17 +98,30 @@
String text = fConsole.getDocument().get(offset, length);
while (StackTraceLine.isTraceLine(text)) {
- StackTraceLine stackTraceLine = new StackTraceLine(text);
+ String projectName = null;
+ try {
+ projectName = fConsole.getProcess().getLaunch().getLaunchConfiguration().getAttribute(IRubyLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ StackTraceLine stackTraceLine = new StackTraceLine(text, project);
if (! existanceChecker.fileExists(stackTraceLine.getFilename()))
return;
IHyperlink link = new RubyStackTraceHyperlink(fConsole, stackTraceLine);
fConsole.addLink(link, line.getOffset() + prefix + stackTraceLine.offset() , stackTraceLine.length());
prefix = stackTraceLine.offset() + stackTraceLine.length();
- text = text.substring(stackTraceLine.offset() + stackTraceLine.length());
- if (text.startsWith(":in `require':")) {
- text = text.substring(14);
- prefix += 14;
+ int substring = stackTraceLine.offset() + stackTraceLine.length();
+ if (text.length() < substring - 1) {
+ text = "";
+ } else {
+ text = text.substring(substring);
+ if (text.startsWith(":in `require':")) {
+ text = text.substring(14);
+ prefix += 14;
+ }
}
}
} catch (BadLocationException e) {
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-05-30 19:36:18 UTC (rev 2562)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/StackTraceLine.java 2007-05-30 20:16:38 UTC (rev 2563)
@@ -15,9 +15,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.core.resources.IProject;
import org.rubypeople.rdt.core.IRubyProject;
-import org.rubypeople.rdt.internal.ui.rubyeditor.EditorUtility;
-import org.rubypeople.rdt.ui.actions.OpenEditorActionGroup;
@@ -38,10 +37,14 @@
}
public StackTraceLine(String traceLine) {
- this(traceLine, null);
+ this(traceLine, (IProject) null);
}
+
+ public StackTraceLine(String traceLine, IRubyProject launchedProject) {
+ this(traceLine, launchedProject.getProject());
+ }
- public StackTraceLine(String traceLine, IRubyProject launchedProject) {
+ public StackTraceLine(String traceLine, IProject launchedProject) {
int prefix = 0;
Matcher matcher = OPTIONAL_PREFIX.matcher(traceLine);
if (matcher.find()) {
@@ -56,17 +59,37 @@
return;
}
- fFilename = matcher.group(1);
- if (fFilename.startsWith("./") && launchedProject != null) {
- fFilename = launchedProject.getPath().toPortableString() + fFilename.substring(1);
+ fFilename = matcher.group(1);
+ offset = matcher.start(1) + prefix;
+ if (fFilename.startsWith("[")) {
+ fFilename = fFilename.substring(1);
+ offset++;
}
String lineNumber = matcher.group(2);
fLineNumber = Integer.parseInt(lineNumber);
+ length = fFilename.length()+lineNumber.length()+1;
+ if (isRelativePath() && launchedProject != null) {
+ makeRelativeToWorkspace(launchedProject);
+ }
- offset = matcher.start(1) + prefix;
- length = fFilename.length()+lineNumber.length()+1;
}
+ private void makeRelativeToWorkspace(IProject launchedProject) {
+ if (fFilename.startsWith("./")) {
+ fFilename = launchedProject.getFullPath().toPortableString() + fFilename.substring(1);
+ return;
+ } else {
+ fFilename = launchedProject.getFullPath().toPortableString() + '/' + fFilename;
+ }
+
+ }
+
+ private boolean isRelativePath() {
+ if (fFilename.startsWith("./")) return true;
+ if (!fFilename.startsWith("/") && fFilename.charAt(fFilename.indexOf('/') - 1) != ':' ) return true;
+ return false;
+ }
+
public void openEditor() {
if (fFilename == null)
return;
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-05-30 19:36:18 UTC (rev 2562)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TC_StackTraceLine.java 2007-05-30 20:16:38 UTC (rev 2563)
@@ -26,6 +26,14 @@
public void testWithFrom() {
assertFalse("has a stack trace", StackTraceLine.isTraceLine(WITH_TRAILING_SPACE));
}
+
+ public void testRelativePathWithPeriod() {
+ assertTrue("has a stack trace", StackTraceLine.isTraceLine(" ./content/scripts/WatirScripts/byFeature/../lib/lib_atf_base.rb:240:in `treeNavigation'"));
+ }
+
+ public void testRelativePathWithoutPeriod() {
+ assertTrue("has a stack trace", StackTraceLine.isTraceLine("content/scripts/WatirScripts/byFeature/serialized_framework_validation_IT13_script.rb:43:in `test_tc85'"));
+ }
public void testWithTrailingSpace() {
assertTrue("has a stack trace", StackTraceLine.isTraceLine(WITH_FROM));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|