Skip to content
Browse files

executable execution, implement ILaunchShortcut2 to retrieve last use…

…d configuration
  • Loading branch information...
1 parent 75eb785 commit 1af67aa9278899ae37b9ba327bd94048470c4666 @JPMoresmau committed
View
4 docs/releasenotes/net.sf.eclipsefp.haskell_2.0.3.txt
@@ -21,6 +21,7 @@ Fixes:
- Where dependent packages are shown (project explorer, project properties)
the project is correctly loaded if need be
- When launching GHCi, only hidden packages are added via -package
+ - When running a haskell file with the "launch the selected ressource or active editor", if an existing launch configuration exists, it it reused.
Features:
- Interface to cabal install via contextual action on project
@@ -54,6 +55,8 @@ Features:
- Block following ("{- | ... -}") via Ctrl+Shift+D B
- Pragma comment ("{-# #-}") via Ctrl-Shift-C P
+ - Run as haskell application: for projects with executable components, launch the built exe file
+
Internal:
Upgrade notes:
@@ -64,6 +67,7 @@ Known issues:
Thanks to B. Scott Michel (scooter.phd@gmail.com) for his contributions.
+Thanks to all bug reporters and users for their feedback.
Thanks to all the people that expressed interest in EclipseFP and want to see it stay alive and improve!
JP Moresmau (jp@moresmau.fr)
View
94 ....core.test/src/net/sf/eclipsefp/haskell/core/internal/project/HaskellProject_PDETest.java
@@ -1,17 +1,11 @@
// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
package net.sf.eclipsefp.haskell.core.internal.project;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
import net.sf.eclipsefp.haskell.core.project.HaskellProjectManager;
import net.sf.eclipsefp.haskell.core.test.TestCaseWithProject;
import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
import net.sf.eclipsefp.haskell.util.FileUtil;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
public class HaskellProject_PDETest extends TestCaseWithProject {
@@ -52,48 +46,48 @@ public void testMultipleSourcePaths() {
assertFalse( ResourceUtil.isSourceFolder( project.getFolder( "crs" ) ) );
}
- public void testTargetExecutable_single() throws CoreException {
- HaskellProject hp = ( HaskellProject )HaskellProjectManager.get( project );
- // atm one target exe is added automatically during project creation
- assertEquals( 1, hp.getTargetNames().size() );
-
- IPath path = new Path( "bla.exe" );
- InputStream is = new ByteArrayInputStream( new byte[ 0 ] );
- IFile f=project.getFile( path );
- f.create( is, true, null );
- try {
- hp.addTargetName( path );
- assertEquals( 2, hp.getTargetNames().size() );
-
- assertTrue( ResourceUtil.isProjectExecutable( project, "bla" ));
- assertFalse( ResourceUtil.isProjectExecutable( project, "blubb" ) );
- } finally {
- f.delete( true, null );
- }
- }
-
- public void testTargetExecutable_multiple() throws CoreException {
- HaskellProject hp = ( HaskellProject )HaskellProjectManager.get( project );
- // atm one target exe is added automatically during project creation
- assertEquals( 1, hp.getTargetNames().size() );
-
- IPath path = new Path( "bin/bli.exe" );
- IPath path2 = new Path( "bla.exe" );
- InputStream is = new ByteArrayInputStream( new byte[ 0 ] );
- project.getFolder( "bin" ).create( true, true, null );
- project.getFile( path ).create( is, true, null );
- IFile f=project.getFile( path2 );
- f.create( is, true, null );
- try {
- hp.addTargetName( path );
- hp.addTargetName( path2 );
- assertEquals( 3, hp.getTargetNames().size() );
-
- assertTrue( ResourceUtil.isProjectExecutable( project, "bla" ) );
- assertTrue( ResourceUtil.isProjectExecutable( project, "bin/bli" ) );
- assertFalse( ResourceUtil.isProjectExecutable( project, "blubb" ) );
- } finally {
- f.delete( true, null );
- }
- }
+// public void testTargetExecutable_single() throws CoreException {
+// HaskellProject hp = ( HaskellProject )HaskellProjectManager.get( project );
+// // atm one target exe is added automatically during project creation
+// assertEquals( 1, hp.getTargetNames().size() );
+//
+// IPath path = new Path( "bla.exe" );
+// InputStream is = new ByteArrayInputStream( new byte[ 0 ] );
+// IFile f=project.getFile( path );
+// f.create( is, true, null );
+// try {
+// hp.addTargetName( path );
+// assertEquals( 2, hp.getTargetNames().size() );
+//
+// assertTrue( ResourceUtil.isProjectExecutable( project, "bla" ));
+// assertFalse( ResourceUtil.isProjectExecutable( project, "blubb" ) );
+// } finally {
+// f.delete( true, null );
+// }
+// }
+//
+// public void testTargetExecutable_multiple() throws CoreException {
+// HaskellProject hp = ( HaskellProject )HaskellProjectManager.get( project );
+// // atm one target exe is added automatically during project creation
+// assertEquals( 1, hp.getTargetNames().size() );
+//
+// IPath path = new Path( "bin/bli.exe" );
+// IPath path2 = new Path( "bla.exe" );
+// InputStream is = new ByteArrayInputStream( new byte[ 0 ] );
+// project.getFolder( "bin" ).create( true, true, null );
+// project.getFile( path ).create( is, true, null );
+// IFile f=project.getFile( path2 );
+// f.create( is, true, null );
+// try {
+// hp.addTargetName( path );
+// hp.addTargetName( path2 );
+// assertEquals( 3, hp.getTargetNames().size() );
+//
+// assertTrue( ResourceUtil.isProjectExecutable( project, "bla" ) );
+// assertTrue( ResourceUtil.isProjectExecutable( project, "bin/bli" ) );
+// assertFalse( ResourceUtil.isProjectExecutable( project, "blubb" ) );
+// } finally {
+// f.delete( true, null );
+// }
+// }
}
View
67 ...sefp.haskell.core/src/net/sf/eclipsefp/haskell/core/builder/CheckOutFoldersOperation.java
@@ -1,67 +0,0 @@
-// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
-package net.sf.eclipsefp.haskell.core.builder;
-
-import net.sf.eclipsefp.haskell.core.internal.util.CoreTexts;
-import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-
-/** <p>checks if the output folder and binary folder exists and creates them,
- * if necessary.</p>
- *
- * @author Leif Frenzel
- */
-public class CheckOutFoldersOperation implements IWorkspaceRunnable {
-
- private final IProject project;
-
- CheckOutFoldersOperation( final IProject project ) {
- this.project = project;
- }
-
-
- // interface methods of IWorkspaceRunnable
- //////////////////////////////////////////
-
- public void run( final IProgressMonitor monitor ) throws CoreException {
- monitor.beginTask( CoreTexts.checkOutFoldersOperation_cleaning, 50 );
- try {
- checkOutFolder( monitor ); // (50)
- } finally {
- monitor.done();
- }
- }
-
-
- // helping methods
- //////////////////
-
- private void checkOutFolder( final IProgressMonitor monitor )
- throws CoreException {
- monitor.subTask( CoreTexts.checkOutFoldersOperation_checkingOutput );
- IContainer outFolder = ResourceUtil.getOutFolder( project );
- create( outFolder, monitor );
- }
-
- private void create( final IContainer container,
- final IProgressMonitor monitor ) throws CoreException {
- if( mustCreate( container ) ) {
- IPath path = container.getProjectRelativePath();
- IFolder folder = project.getFolder( path );
- folder.create( true, true, new SubProgressMonitor( monitor, 50 ) );
- }
- }
-
- private boolean mustCreate( final IContainer container ) {
- return container != null
- && !container.equals( project )
- && !container.exists();
- }
-}
View
165 ...sefp.haskell.core/src/net/sf/eclipsefp/haskell/core/builder/CleanOutFoldersOperation.java
@@ -1,84 +1,83 @@
-// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
-package net.sf.eclipsefp.haskell.core.builder;
-
-import net.sf.eclipsefp.haskell.core.internal.util.CoreTexts;
-import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-
-/** <p>Operation for cleaning output and binary folders of a Haskell
- * project.</p>
- *
- * @author Leif Frenzel
- */
-class CleanOutFoldersOperation implements IWorkspaceRunnable {
-
- private static IResourceProxyVisitor folderCleaner = new FolderCleaner();
-
- private final IProject project;
-
- CleanOutFoldersOperation( final IProject project ) {
- this.project = project;
- }
-
- public void run( final IProgressMonitor mon ) throws CoreException {
- mon.beginTask( CoreTexts.cleanOutFoldersOperation_cleaning, 15 );
- try {
- deleteExe( mon ); // (3)
- shrubOutFolder( mon ); // (12)
- } finally {
- mon.done();
- }
- }
-
-
- // helping methods
- //////////////////
-
- private void shrubOutFolder( final IProgressMonitor mon )
- throws CoreException {
- mon.subTask( CoreTexts.cleanOutFoldersOperation_shrubbingOut );
- IContainer outFolder = ResourceUtil.getOutFolder( project );
- if( outFolder != null && !outFolder.equals( project ) ) {
- outFolder.accept( folderCleaner, IContainer.INCLUDE_PHANTOMS );
- }
- mon.worked( 12 );
- }
-
- private void deleteExe( final IProgressMonitor mon ) throws CoreException {
- mon.subTask( CoreTexts.cleanOutFoldersOperation_removingExes );
- IFile[] files = ResourceUtil.getProjectExecutables( project );
- for( IFile file: files ) {
- if( file != null && file.isAccessible() ) {
- file.delete( true, new SubProgressMonitor( mon, 3 ) );
- }
- }
- }
-
-
- // inner classes
- ////////////////
-
- private static class FolderCleaner implements IResourceProxyVisitor {
- public boolean visit( final IResourceProxy proxy ) throws CoreException {
- if( proxy.getType() == IResource.FILE ) {
- IResource resource = proxy.requestResource();
- // TODO need more general approach here
- String name = resource.getName();
- if( !name.equals( ".project" ) && !name.equals( ".hsproject" ) ) { //$NON-NLS-1$ //$NON-NLS-2$
- resource.delete( IResource.FORCE, null );
- }
- }
- return true;
- }
- }
+// Copyright (c) 2003-2005 by Leif Frenzel - see http://leiffrenzel.de
+package net.sf.eclipsefp.haskell.core.builder;
+
+import net.sf.eclipsefp.haskell.core.internal.util.CoreTexts;
+import net.sf.eclipsefp.haskell.scion.client.ScionPlugin;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+
+/** <p>Operation for cleaning output and binary folders of a Haskell
+ * project.</p>
+ *
+ * @author Leif Frenzel
+ */
+class CleanOutFoldersOperation implements IWorkspaceRunnable {
+
+ private static IResourceProxyVisitor folderCleaner = new FolderCleaner();
+
+ private final IProject project;
+
+ CleanOutFoldersOperation( final IProject project ) {
+ this.project = project;
+ }
+
+ public void run( final IProgressMonitor mon ) throws CoreException {
+ mon.beginTask( CoreTexts.cleanOutFoldersOperation_cleaning, 12 );
+ try {
+ //deleteExe( mon ); // (3)
+ shrubOutFolder( mon ); // (12)
+ } finally {
+ mon.done();
+ }
+ }
+
+
+ // helping methods
+ //////////////////
+
+ private void shrubOutFolder( final IProgressMonitor mon )
+ throws CoreException {
+ mon.subTask( CoreTexts.cleanOutFoldersOperation_shrubbingOut );
+ IContainer outFolder = project.getFolder( ScionPlugin.DIST_FOLDER );
+ //ResourceUtil.getOutFolder( project );
+ if( outFolder != null && !outFolder.equals( project ) ) {
+ outFolder.accept( folderCleaner, IContainer.INCLUDE_PHANTOMS );
+ }
+ mon.worked( 12 );
+ }
+
+// private void deleteExe( final IProgressMonitor mon ) throws CoreException {
+// mon.subTask( CoreTexts.cleanOutFoldersOperation_removingExes );
+// IFile[] files = ResourceUtil.getProjectExecutables( project );
+// for( IFile file: files ) {
+// if( file != null && file.isAccessible() ) {
+// file.delete( true, new SubProgressMonitor( mon, 3 ) );
+// }
+// }
+// }
+
+
+ // inner classes
+ ////////////////
+
+ private static class FolderCleaner implements IResourceProxyVisitor {
+ public boolean visit( final IResourceProxy proxy ) throws CoreException {
+ if( proxy.getType() == IResource.FILE ) {
+ IResource resource = proxy.requestResource();
+ // TODO need more general approach here
+ String name = resource.getName();
+ if( !name.equals( ".project" ) && !name.equals( ".hsproject" ) ) { //$NON-NLS-1$ //$NON-NLS-2$
+ resource.delete( IResource.FORCE, null );
+ }
+ }
+ return true;
+ }
+ }
}
View
15 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/project/HaskellResource.java
@@ -1,10 +1,13 @@
package net.sf.eclipsefp.haskell.core.project;
+import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
import net.sf.eclipsefp.haskell.util.FileUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
public class HaskellResource {
@@ -28,4 +31,16 @@ public boolean isSourceFolder() {
&& ResourceUtil.isSourceFolder( folder );
}
+ public boolean isProjectExecutable(){
+ if (fResource instanceof IProject){
+ IProject project=(IProject)fResource;
+ try {
+ return !ResourceUtil.getProjectExecutables( project ).isEmpty();
+ } catch (CoreException ce){
+ HaskellCorePlugin.log( ce );
+ }
+
+ }
+ return false;
+ }
}
View
133 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/util/ResourceUtil.java
@@ -2,6 +2,7 @@
package net.sf.eclipsefp.haskell.core.util;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -20,13 +21,12 @@
import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescription;
import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionLoader;
import net.sf.eclipsefp.haskell.core.cabalmodel.PackageDescriptionStanza;
-import net.sf.eclipsefp.haskell.core.internal.util.Assert;
import net.sf.eclipsefp.haskell.core.project.HaskellNature;
-import net.sf.eclipsefp.haskell.core.project.HaskellProjectManager;
-import net.sf.eclipsefp.haskell.core.project.IHaskellProject;
import net.sf.eclipsefp.haskell.scion.client.ScionInstance;
import net.sf.eclipsefp.haskell.scion.client.ScionPlugin;
import net.sf.eclipsefp.haskell.scion.types.CabalPackage;
+import net.sf.eclipsefp.haskell.scion.types.Component;
+import net.sf.eclipsefp.haskell.scion.types.Component.ComponentType;
import net.sf.eclipsefp.haskell.util.FileUtil;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -54,13 +54,27 @@
* project has the Haskell nature.
*/
- public static ArrayList<IFile> getProjectExecutablesArray( final IProject project)
+ public static List<IFile> getProjectExecutables( final IProject project)
throws CoreException
{
- Assert.isTrue( project.hasNature( HaskellNature.NATURE_ID ) );
-
- ArrayList<IFile> result = new ArrayList<IFile>();
- IHaskellProject hsProject = HaskellProjectManager.get( project );
+ ArrayList<IFile> result = new ArrayList<IFile>();
+ if (project.hasNature( HaskellNature.NATURE_ID ) ){
+
+
+ ScionInstance instance=ScionPlugin.getScionInstance( project );
+ if (instance!=null){
+ for (Component c:instance.getComponents()){
+ if (c.isBuildable() && c.getType().equals( ComponentType.EXECUTABLE )){
+ String name=FileUtil.makeExecutableName( c.getName() );
+ IFile f=project.getFile( ScionPlugin.DIST_FOLDER+File.separator+"build"+File.separator+c.getName()+File.separator+name ); //$NON-NLS-1$
+ if (f.exists()){
+ result.add( f );
+ }
+ }
+ }
+ }
+ }
+ /*IHaskellProject hsProject = HaskellProjectManager.get( project );
Set<IPath> targetNames = hsProject.getTargetNames();
for( IPath path: targetNames ) {
if (!path.isEmpty()){
@@ -69,29 +83,29 @@
result.add( file );
}
}
- }
+ }*/
return result;
}
- public static boolean isProjectExecutable(final IProject project, final String exeName)
- {
- boolean retval = false;
- String theExeName = FileUtil.makeExecutableName(exeName);
-
- try {
- ArrayList<IFile> executables = getProjectExecutablesArray(project);
- for (IFile iter: executables) {
- if (iter.getName().equals( theExeName )) {
- retval = true;
- }
- }
- } catch (CoreException e) {
- retval = false;
- }
-
- return retval;
- }
+// public static boolean isProjectExecutable(final IProject project, final String exeName)
+// {
+// boolean retval = false;
+// String theExeName = FileUtil.makeExecutableName(exeName);
+//
+// try {
+// ArrayList<IFile> executables = getProjectExecutablesArray(project);
+// for (IFile iter: executables) {
+// if (iter.getName().equals( theExeName )) {
+// retval = true;
+// }
+// }
+// } catch (CoreException e) {
+// retval = false;
+// }
+//
+// return retval;
+// }
/**
* <p>
@@ -99,9 +113,9 @@ public static boolean isProjectExecutable(final IProject project, final String e
* project must have the Haskell nature.
* </p>
*/
- public static IFile[] getProjectExecutables( final IProject project )
+ public static IFile[] getProjectExecutablesArray( final IProject project )
throws CoreException {
- ArrayList<IFile> executables = getProjectExecutablesArray(project);
+ List<IFile> executables = getProjectExecutables(project);
return executables.toArray( new IFile[ executables.size() ] );
}
@@ -112,22 +126,22 @@ public static boolean isProjectExecutable(final IProject project, final String e
* @return The IContainer object corresponding to the project's output
* folder.
*/
- public static IContainer getOutFolder(final IProject project)
- throws CoreException
- {
- Assert.isNotNull( project );
- Assert.isTrue(project.hasNature(HaskellNature.NATURE_ID));
-
- IHaskellProject hsProject = getHsProject(project);
- IPath outputPath = hsProject.getOutputPath();
- IContainer result;
- if (outputPath.equals(project.getProjectRelativePath())) {
- result = project;
- } else {
- result = project.getFolder(outputPath);
- }
- return result;
- }
+// public static IContainer getOutFolder(final IProject project)
+// throws CoreException
+// {
+// Assert.isNotNull( project );
+// Assert.isTrue(project.hasNature(HaskellNature.NATURE_ID));
+//
+// IHaskellProject hsProject = getHsProject(project);
+// IPath outputPath = hsProject.getOutputPath();
+// IContainer result;
+// if (outputPath.equals(project.getProjectRelativePath())) {
+// result = project;
+// } else {
+// result = project.getFolder(outputPath);
+// }
+// return result;
+// }
/**
* <p>
@@ -202,6 +216,29 @@ public static IResource findResource(final Object element) {
return result;
}
+ public static IResource[] getResourcesFromSelection(final ISelection selection){
+ if( selection != null && selection instanceof IStructuredSelection ) {
+ List<IResource> list = new ArrayList<IResource>();
+ IStructuredSelection ssel = ( IStructuredSelection )selection;
+ for( Object element: ssel.toList() ) {
+ IResource res = ResourceUtil.findResource( element );
+ if( res != null ) {
+ list.add( res );
+ }
+ }
+ IResource[] ress = toResourceArray( list );
+ return ress;
+ }
+ return new IResource[0];
+ }
+
+
+ public static IResource[] toResourceArray( final List<IResource> list ) {
+ IResource[] result = new IResource[ list.size() ];
+ list.toArray( result );
+ return result;
+ }
+
private static IContainer getContainer(final IProject p,final String src){
return src.equals( "." )?p:p.getFolder( src ); //$NON-NLS-1$
}
@@ -462,9 +499,9 @@ public static IFolder mkdirs( final IPath folderPath,
// helping methods
// ////////////////
- private static IHaskellProject getHsProject( final IProject project ) {
- return HaskellProjectManager.get( project );
- }
+// private static IHaskellProject getHsProject( final IProject project ) {
+// return HaskellProjectManager.get( project );
+// }
public static String getModuleName( final String fileName ) {
return fileName.substring( 0, fileName.lastIndexOf( '.' ) );
View
2 net.sf.eclipsefp.haskell.debug.ui/plugin.xml
@@ -33,7 +33,7 @@
value="1">
</count>
<iterate>
- <test
+ <test
property="net.sf.eclipsefp.haskell.core.isProjectExecutable">
</test>
</iterate>
View
75 ...g.ui/src/net/sf/eclipsefp/haskell/debug/ui/internal/launch/ExecutableLaunchOperation.java
@@ -5,26 +5,22 @@
import java.io.File;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import net.sf.eclipsefp.haskell.compat.ILaunchManagerCompat;
import net.sf.eclipsefp.haskell.core.project.HaskellNature;
+import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
import net.sf.eclipsefp.haskell.debug.core.internal.launch.ILaunchAttributes;
-import net.sf.eclipsefp.haskell.debug.ui.internal.util.UITexts;
import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.osgi.util.NLS;
/**
* <p>
@@ -41,8 +37,8 @@ void launch( final IResource resource, final IProgressMonitor monitor )
if( resource != null ) {
IProject project = resource.getProject();
if( project.hasNature( HaskellNature.NATURE_ID ) ) {
- IFile executable = findExecutable( resource );
- ILaunchConfiguration configuration = getConfiguration( executable );
+ List<IFile> executables=ResourceUtil.getProjectExecutables( project );
+ ILaunchConfiguration configuration = getConfiguration( project,executables );
if( configuration != null ) {
configuration.launch( ILaunchManager.RUN_MODE, monitor );
}
@@ -53,38 +49,45 @@ void launch( final IResource resource, final IProgressMonitor monitor )
// helping methods
//////////////////
- private IFile findExecutable( final IResource res ) throws CoreException {
- IFile result = null;
- IFile[] exes = ResourceUtil.getProjectExecutables( res.getProject() );
- for( IFile exe: exes ) {
- if( res.equals( exe ) ) {
- result = exe;
- }
- }
- if( result == null && exes.length == 1 ) {
- result = exes[ 0 ];
- }
- if( result == null ) {
- String pattern = UITexts.executableLaunchOperations_errorMsg;
- String msg = NLS.bind( pattern, res.getName() );
- String pluginId = HaskellUIPlugin.getPluginId();
- Status status = new Status( IStatus.ERROR, pluginId, 0, msg, null );
- throw new CoreException( status );
- }
- return result;
- }
+// private IFile findExecutable( final IResource res ) throws CoreException {
+// IFile result = null;
+// IFile[] exes = ResourceUtil.getProjectExecutables( res.getProject() );
+// for( IFile exe: exes ) {
+// if( res.equals( exe ) ) {
+// result = exe;
+// }
+// }
+// if( result == null && exes.length == 1 ) {
+// result = exes[ 0 ];
+// }
+// if( result == null ) {
+// String pattern = UITexts.executableLaunchOperations_errorMsg;
+// String msg = NLS.bind( pattern, res.getName() );
+// String pluginId = HaskellUIPlugin.getPluginId();
+// Status status = new Status( IStatus.ERROR, pluginId, 0, msg, null );
+// throw new CoreException( status );
+// }
+// return result;
+// }
- private ILaunchConfiguration getConfiguration( final IFile file )
+ private ILaunchConfiguration getConfiguration(final IProject project, final List<IFile> executables )
throws CoreException {
- List<ILaunchConfiguration> configurations = findConfiguration( file );
+ List<ILaunchConfiguration> configurations = findConfiguration( project );
ILaunchConfiguration result = null;
int count = configurations.size();
if( count < 1 ) {
// If there are no existing configs associated with the
// ICompilationUnit,
// create one.
- result = createConfiguration( file );
- } else if( count == 1 ) {
+ //result = createConfiguration( file );
+ for (IFile f:executables){
+ configurations.add( createConfiguration( f ) );
+ }
+ count = configurations.size();
+ }
+
+
+ if( count == 1 ) {
// If there is exactly one config associated with the
// ICompilationUnit,
// return it.
@@ -119,16 +122,16 @@ private String getExePath( final IFile executable ) {
return result;
}
- private List<ILaunchConfiguration> findConfiguration( final IFile file )
+ public static List<ILaunchConfiguration> findConfiguration( final IProject project )
throws CoreException {
- List<ILaunchConfiguration> result = Collections.emptyList();
+ List<ILaunchConfiguration> result = new ArrayList<ILaunchConfiguration>();
ILaunchConfiguration[] configurations = getConfigurations();
result = new ArrayList<ILaunchConfiguration>( configurations.length );
for( int i = 0; i < configurations.length; i++ ) {
ILaunchConfiguration configuration = configurations[ i ];
- String exePath = getExePath( file );
- String projectName = file.getProject().getName();
- if( getExePath( configuration ).equals( exePath )
+ //String exePath = getExePath( file );
+ String projectName = project.getName();
+ if( getExePath( configuration ).startsWith( project.getLocation().toOSString() )
&& getProjectName( configuration ).equals( projectName ) ) {
result.add( configuration );
}
View
41 ...ug.ui/src/net/sf/eclipsefp/haskell/debug/ui/internal/launch/ExecutableLaunchShortcut.java
@@ -3,11 +3,13 @@
// version 1.0 (EPL). See http://www.eclipse.org/legal/epl-v10.html
package net.sf.eclipsefp.haskell.debug.ui.internal.launch;
+import java.util.List;
import net.sf.eclipsefp.haskell.core.util.ResourceUtil;
import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.ui.ILaunchShortcut2;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
@@ -16,7 +18,7 @@
*
* @author Leif Frenzel
*/
-public class ExecutableLaunchShortcut implements ILaunchShortcut {
+public class ExecutableLaunchShortcut implements ILaunchShortcut2 {
// interface methods of ILaunchShortcut
///////////////////////////////////////
@@ -48,4 +50,39 @@ private void launch( final IResource resource ) {
HaskellUIPlugin.log( msg, cex );
}
}
+
+ public IResource getLaunchableResource( final IEditorPart paramIEditorPart ) {
+ return null;
+ }
+ public IResource getLaunchableResource( final ISelection paramISelection ) {
+ return null;
+ }
+ public ILaunchConfiguration[] getLaunchConfigurations(
+ final IEditorPart paramIEditorPart ) {
+ IResource resource = ResourceUtil.findResource( paramIEditorPart.getEditorInput() );
+ try {
+ List<ILaunchConfiguration> cs=ExecutableLaunchOperation.findConfiguration(resource.getProject());
+ return cs.toArray( new ILaunchConfiguration[cs.size()] );
+ } catch (CoreException cex){
+ HaskellUIPlugin.log( cex );
+ }
+ return null;
+ }
+
+ /**
+ * this allows launching a new configuration
+ */
+ public ILaunchConfiguration[] getLaunchConfigurations(
+ final ISelection paramISelection ) {
+ try {
+ IResource[] res=ResourceUtil.getResourcesFromSelection( paramISelection ) ;
+ if (res.length>0){
+ List<ILaunchConfiguration> cs=ExecutableLaunchOperation.findConfiguration(res[0].getProject());
+ return cs.toArray( new ILaunchConfiguration[cs.size()] );
+ }
+ } catch (CoreException cex){
+ HaskellUIPlugin.log( cex );
+ }
+ return null;
+ }
}
View
6 ....ui/src/net/sf/eclipsefp/haskell/debug/ui/internal/launch/InteractiveLaunchOperation.java
@@ -70,7 +70,7 @@ void launch( final IResource[] resources,final String mode,
private ILaunchConfiguration getConfiguration( final IResource[] resources,
final IFile[] files )
throws CoreException {
- List<ILaunchConfiguration> configurations = findConfig( resources );
+ List<ILaunchConfiguration> configurations = findConfig(delegate, resources );
ILaunchConfiguration result = null;
int count = configurations.size();
if( count < 1 ) {
@@ -124,7 +124,7 @@ private ILaunchConfiguration createConfiguration( final IResource[] resources,
return wc.doSave();
}
- private List<ILaunchConfiguration> findConfig( final IResource[] resources )
+ public static List<ILaunchConfiguration> findConfig( final IInteractiveLaunchOperationDelegate delegate, final IResource[] resources )
throws CoreException {
List<ILaunchConfiguration> result = Collections.emptyList();
ILaunchConfiguration[] configurations = getConfigurations();
@@ -143,7 +143,7 @@ private ILaunchConfiguration createConfiguration( final IResource[] resources,
return result;
}
- private String getFirstResName( final ILaunchConfiguration config )
+ private static String getFirstResName( final ILaunchConfiguration config )
throws CoreException {
String att = FIRST_SELECTED_RESOURCE;
return config.getAttribute( att, ILaunchAttributes.EMPTY );
View
45 ...g.ui/src/net/sf/eclipsefp/haskell/debug/ui/internal/launch/InteractiveLaunchShortcut.java
@@ -11,7 +11,8 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.ui.ILaunchShortcut2;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorPart;
@@ -25,7 +26,7 @@
*
* @author Leif Frenzel
*/
-public abstract class InteractiveLaunchShortcut implements ILaunchShortcut {
+public abstract class InteractiveLaunchShortcut implements ILaunchShortcut2 {
// methods to be implemented by subclasses
//////////////////////////////////////////
@@ -50,11 +51,13 @@ public void launch( final ISelection selection, final String mode ) {
list.add( res );
}
}
- IResource[] ress = toArray( list );
+ IResource[] ress = ResourceUtil.toResourceArray( list );
launch( ress,mode );
}
}
+
+
public void launch( final IEditorPart editor, final String mode ) {
// launched from editor part
IResource resource = ResourceUtil.findResource( editor.getEditorInput() );
@@ -79,9 +82,37 @@ private void launch( final IResource[] resources,final String mode ) {
}
}
- private IResource[] toArray( final List<IResource> list ) {
- IResource[] result = new IResource[ list.size() ];
- list.toArray( result );
- return result;
+
+ public IResource getLaunchableResource( final IEditorPart paramIEditorPart ) {
+ return null;
+ }
+ public IResource getLaunchableResource( final ISelection paramISelection ) {
+ return null;
+ }
+ public ILaunchConfiguration[] getLaunchConfigurations(
+ final IEditorPart paramIEditorPart ) {
+ IResource resource = ResourceUtil.findResource( paramIEditorPart.getEditorInput() );
+ try {
+ List<ILaunchConfiguration> cs=InteractiveLaunchOperation.findConfig( getDelegate(),new IResource[]{ resource });
+ return cs.toArray( new ILaunchConfiguration[cs.size()] );
+ } catch (CoreException cex){
+ HaskellUIPlugin.log( cex );
+ }
+ return null;
+ }
+
+ /**
+ * this allows launching a new configuration
+ */
+ public ILaunchConfiguration[] getLaunchConfigurations(
+ final ISelection paramISelection ) {
+ try {
+ List<ILaunchConfiguration> cs=InteractiveLaunchOperation.findConfig( getDelegate(), ResourceUtil.getResourcesFromSelection( paramISelection ) );
+ return cs.toArray( new ILaunchConfiguration[cs.size()] );
+ } catch (CoreException cex){
+ HaskellUIPlugin.log( cex );
+ }
+ return null;
}
+
}
View
2 ...skell.debug.ui/src/net/sf/eclipsefp/haskell/debug/ui/internal/launch/LaunchOperation.java
@@ -69,7 +69,7 @@ public static String getProjectName( final ILaunchConfiguration configuration )
return configuration.getAttribute( att, ILaunchAttributes.EMPTY );
}
- String getExePath( final ILaunchConfiguration config ) throws CoreException {
+ static String getExePath( final ILaunchConfiguration config ) throws CoreException {
String att = ILaunchAttributes.EXECUTABLE;
return config.getAttribute( att, ILaunchAttributes.EMPTY );
}
View
1 net.sf.eclipsefp.haskell.util/src/net/sf/eclipsefp/haskell/util/FileUtil.java
@@ -165,6 +165,7 @@ public static File findInPath(final String shortFileName, final FileFilter ff) {
}
return null;
}
+
/**
* Delete all contents including directories

0 comments on commit 1af67aa

Please sign in to comment.
Something went wrong with that request. Please try again.