Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

source lookup from breakpoints

  • Loading branch information...
commit 6bafa153f7cfdcfdfc9104ddeb0cde2d08e6c76e 1 parent efc4b6c
@JPMoresmau authored
View
2  net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/util/ResourceUtil.java
@@ -137,7 +137,7 @@ public static IContainer getOutFolder(final IProject project)
for (String s:stzs.keySet()){
ret.add(getContainer( project,s ));
}
-
+ return ret;
}
} catch( CoreException ex ) {
HaskellCorePlugin.log( "getSourceFolders:"+project, ex ); //$NON-NLS-1$
View
5 ...l.debug.core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellBreakpoint.java
@@ -18,6 +18,11 @@
*/
public class HaskellBreakpoint extends LineBreakpoint {
+
+ public HaskellBreakpoint() {
+ //noop
+ }
+
/**
*
* @param resource file on which to set the breakpoint
View
18 ...re/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellSourceLookupDirector.java
@@ -0,0 +1,18 @@
+package net.sf.eclipsefp.haskell.debug.core.internal.debug;
+
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
+
+/**
+ * Source lookup director for Haskell
+ * @author JP Moresmau
+ *
+ */
+public class HaskellSourceLookupDirector extends AbstractSourceLookupDirector {
+
+
+ public void initializeParticipants() {
+ addParticipants( new ISourceLookupParticipant[]{new HaskellSourceLookupParticipant()} );
+ }
+
+}
View
21 ...INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellSourceLookupParticipant.java
@@ -0,0 +1,21 @@
+package net.sf.eclipsefp.haskell.debug.core.internal.debug;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
+
+/**
+ * Source lookup participant
+ * @author JP Moresmau
+ *
+ */
+public class HaskellSourceLookupParticipant extends
+ AbstractSourceLookupParticipant {
+
+ public String getSourceName( final Object object ) throws CoreException {
+ if (object instanceof HaskellStrackFrame){
+ return ((HaskellStrackFrame)object).getFileName();
+ }
+ return null;
+ }
+
+}
View
49 ...ERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellSourcePathComputerDelegate.java
@@ -0,0 +1,49 @@
+package net.sf.eclipsefp.haskell.debug.core.internal.debug;
+
+import java.util.Collection;
+import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
+import net.sf.eclipsefp.haskell.debug.core.internal.launch.ILaunchAttributes;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
+import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;
+import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
+
+/**
+ *
+ * @author JP Moresmau
+ *
+ */
+public class HaskellSourcePathComputerDelegate implements
+ ISourcePathComputerDelegate {
+
+ public ISourceContainer[] computeSourceContainers(
+ final ILaunchConfiguration configuration, final IProgressMonitor monitor )
+ throws CoreException {
+ String projectName=configuration.getAttribute( ILaunchAttributes.PROJECT_NAME ,""); //$NON-NLS-1$
+ IProject p=ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
+
+ Collection<IContainer> cs=ResourceUtil.getSourceFolders( p );
+ ISourceContainer[] ret=new ISourceContainer[cs.size()];
+ int a=0;
+ for (IContainer c:cs){
+ ISourceContainer sourceContainer=null;
+ if (c.getType() == IResource.PROJECT) {
+ sourceContainer = new ProjectSourceContainer((IProject)c, false);
+ } else if (c.getType() == IResource.FOLDER) {
+ sourceContainer = new FolderSourceContainer(c, true);
+ }
+ if (sourceContainer!=null){
+ ret[a++]=sourceContainer;
+ }
+ }
+ return ret;
+ }
+
+}
View
29 ....debug.core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/debug/HaskellStrackFrame.java
@@ -2,6 +2,12 @@
import java.util.regex.Matcher;
import net.sf.eclipsefp.haskell.core.util.GHCiSyntax;
+import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
+import net.sf.eclipsefp.haskell.debug.core.internal.HaskellDebugCore;
+import net.sf.eclipsefp.haskell.debug.core.internal.launch.ILaunchAttributes;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
@@ -21,6 +27,7 @@
private final HaskellThread thread;
private int lineNumber=-1;
private String name="HaskellStrackFrame";
+ private String fileName;
private int charEnd=-1;
private int charStart=-1;
@@ -29,11 +36,11 @@ public HaskellStrackFrame(final HaskellThread thread){
}
public int getCharEnd() {
- return charEnd;
+ return -1;
}
public int getCharStart() {
- return charStart;
+ return -1;
}
public int getLineNumber() {
@@ -62,10 +69,28 @@ public void setLocation( final String location ) {
charStart=Integer.parseInt(m.group(3));
charEnd=-1;
}
+ fileName=m.group( 1 );
+ try {
+ String projectName=getLaunch().getLaunchConfiguration().getAttribute( ILaunchAttributes.PROJECT_NAME ,"");
+ IProject p=ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
+ String projectLocation=p.getLocation().toOSString();
+ if (fileName.startsWith( projectLocation )){
+ fileName=fileName.substring( projectLocation.length()+1 );
+
+ fileName=ResourceUtil.getSourceFolderRelativeName( p.findMember( fileName.replace("\\","/") ) ).toString();
+ }
+ } catch (CoreException ce){
+ HaskellDebugCore.log( ce.getLocalizedMessage(), ce );
+ }
DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[]{new DebugEvent( this, DebugEvent.CHANGE, DebugEvent.CONTENT )});
}
+
+ public String getFileName() {
+ return fileName;
+ }
+
public IRegisterGroup[] getRegisterGroups() {
return new IRegisterGroup[0];
}
View
4 ....debug.core/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/core/internal/launch/ILaunchAttributes.java
@@ -17,8 +17,8 @@
String ARGUMENTS = "ARGUMENTS"; //$NON-NLS-1$
String EXECUTABLE = "EXECUTABLE"; //$NON-NLS-1$
String PROJECT_NAME = "PROJECT_NAME"; //$NON-NLS-1$
- String FILES = "FILES";
- String DELEGATE = "DELEGATE";
+ String FILES = "FILES"; //$NON-NLS-1$
+ String DELEGATE = "DELEGATE"; //$NON-NLS-1$
String SYNC_STREAMS = "SYNC_STREAMS"; //$NON-NLS-1$
String RELOAD_COMMAND = "RELOAD_COMMAND";//$NON-NLS-1$
View
22 net.sf.eclipsefp.haskell.debug.core/plugin.xml
@@ -4,12 +4,15 @@
<extension
point="org.eclipse.debug.core.launchConfigurationTypes">
<launchConfigurationType
- name="%haskellApplicationLaunchType_name"
delegate="net.sf.eclipsefp.haskell.debug.core.internal.launch.HaskellLaunchDelegate"
+ id="net.sf.eclipsefp.haskell.debug.core.internal.launch.HaskellLaunchDelegate"
modes="run, debug"
- id="net.sf.eclipsefp.haskell.debug.core.internal.launch.HaskellLaunchDelegate">
+ name="%haskellApplicationLaunchType_name"
+ sourceLocatorId="net.sf.eclipsefp.haskell.debug.core.sourceLookupDirector"
+ sourcePathComputerId="net.sf.eclipsefp.haskell.debug.core.sourcePathComputer">
</launchConfigurationType>
</extension>
+
<extension
point="org.eclipse.debug.core.breakpoints">
<breakpoint
@@ -28,4 +31,19 @@
type="org.eclipse.debug.core.lineBreakpointMarker">
</super>
</extension>
+ <extension
+ point="org.eclipse.debug.core.sourceLocators">
+ <sourceLocator
+ name="Haskell Source Lookup Director"
+ class="net.sf.eclipsefp.haskell.debug.core.internal.debug.HaskellSourceLookupDirector"
+ id="net.sf.eclipsefp.haskell.debug.core.sourceLookupDirector">
+ </sourceLocator>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.sourcePathComputers">
+ <sourcePathComputer
+ class="net.sf.eclipsefp.haskell.debug.core.internal.debug.HaskellSourcePathComputerDelegate"
+ id="net.sf.eclipsefp.haskell.debug.core.sourcePathComputer">
+ </sourcePathComputer>
+ </extension>
</plugin>
View
6 ....ui/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/debug/HaskellLineBreakpointAdapter.java
@@ -14,7 +14,11 @@
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.ITextEditor;
-
+/**
+ * Adapter for breakpoints
+ * @author JP Moresmau
+ *
+ */
public class HaskellLineBreakpointAdapter implements IToggleBreakpointsTarget {
/**
View
69 ...ebug.ui/INTERNAL/java/src/net/sf/eclipsefp/haskell/debug/ui/internal/debug/HaskellModelPresentation.java
@@ -0,0 +1,69 @@
+package net.sf.eclipsefp.haskell.debug.ui.internal.debug;
+
+import net.sf.eclipsefp.haskell.debug.core.internal.HaskellDebugCore;
+import net.sf.eclipsefp.haskell.ui.internal.editors.haskell.HaskellEditor;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.ILineBreakpoint;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.IValueDetailListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * Presentation of Haskell debug elements in Haskell source editor
+ * @author JP Moresmau
+ *
+ */
+public class HaskellModelPresentation extends LabelProvider implements IDebugModelPresentation {
+
+ public HaskellModelPresentation() {
+ //NOOP
+ }
+
+ public void computeDetail( final IValue value, final IValueDetailListener listener ) {
+ String detail = ""; //$NON-NLS-1$
+ try {
+ detail = value.getValueString();
+ } catch (DebugException e) {
+ HaskellDebugCore.log( e.getLocalizedMessage(), e );
+ }
+ listener.detailComputed(value, detail);
+ }
+
+ @Override
+ public Image getImage( final Object element ) {
+ return null;
+ }
+
+ @Override
+ public String getText( final Object element ) {
+ return null;
+ }
+
+ public void setAttribute( final String attribute, final Object value ) {
+ // noop
+ }
+
+
+ public String getEditorId( final IEditorInput input, final Object element ) {
+ if (element instanceof IFile || element instanceof ILineBreakpoint) {
+ return HaskellEditor.ID;
+ }
+ return null;
+ }
+
+ public IEditorInput getEditorInput( final Object element ) {
+ if (element instanceof IFile) {
+ return new FileEditorInput((IFile)element);
+ }
+ if (element instanceof ILineBreakpoint) {
+ return new FileEditorInput((IFile)((ILineBreakpoint)element).getMarker().getResource());
+ }
+ return null;
+ }
+
+}
View
7 net.sf.eclipsefp.haskell.debug.ui/plugin.xml
@@ -106,4 +106,11 @@
<adapter type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget"/>
</factory>
</extension>
+ <extension
+ point="org.eclipse.debug.ui.debugModelPresentations">
+ <debugModelPresentation
+ class="net.sf.eclipsefp.haskell.debug.ui.internal.debug.HaskellModelPresentation"
+ id="net.sf.eclipsefp.haskell.debug">
+ </debugModelPresentation>
+ </extension>
</plugin>
Please sign in to comment.
Something went wrong with that request. Please try again.