Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

restart long running build process when cabal changes

  • Loading branch information...
commit 595ae6a3c830dc979a9f0ff4becbfb43a8130ffc 1 parent 52464a1
JP Moresmau authored
22 net.sf.eclipsefp.haskell.buildwrapper/src/net/sf/eclipsefp/haskell/buildwrapper/BWFacade.java
View
@@ -424,6 +424,28 @@ private void addEditorStanza(IFile file,List<String> command){
return null;
}
+ /**
+ * end long running build process if present
+ * @param file
+ */
+ public void endLongRunning(IFile file){
+ Process p=buildProcesses.get(file);
+ if (p!=null){
+ try {
+ p.getOutputStream().write(endCommand);
+ try {
+ p.getOutputStream().flush();
+ } catch (IOException ignore){
+ // noop: flush fails if the process closed properly because write flush
+ }
+ } catch (IOException ioe){
+ BuildWrapperPlugin.logError(BWText.process_launch_error, ioe);
+ } finally {
+ buildProcesses.remove(file);
+ }
+ }
+
+ }
// public BuildFlagInfo getBuildFlags(IFile file){
// BuildFlagInfo i=flagInfos.get(file);
21 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/haskell/HaskellEditor.java
View
@@ -44,8 +44,10 @@
import net.sf.eclipsefp.haskell.ui.internal.editors.text.MarkOccurrenceComputer;
import net.sf.eclipsefp.haskell.ui.internal.preferences.editor.IEditorPreferenceNames;
import net.sf.eclipsefp.haskell.ui.internal.resolve.SelectAnnotationForQuickFix;
+import net.sf.eclipsefp.haskell.ui.internal.scion.CabalFileChangeListenerManager;
import net.sf.eclipsefp.haskell.ui.internal.util.UITexts;
import net.sf.eclipsefp.haskell.ui.internal.views.outline.HaskellOutlinePage;
+import net.sf.eclipsefp.haskell.ui.util.CabalFileChangeListener;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -97,7 +99,7 @@
*
* @author Leif Frenzel
*/
-public class HaskellEditor extends TextEditor implements IEditorPreferenceNames, NameDefHandler {
+public class HaskellEditor extends TextEditor implements IEditorPreferenceNames, NameDefHandler,CabalFileChangeListener {
/** The Haskell editor's identifier. */
public static final String ID = HaskellEditor.class.getName();
/** Action string associated with a following Haddock documentation comment */
@@ -471,6 +473,7 @@ public Object getAdapter( final Class required ) {
@Override
public void dispose() {
+ CabalFileChangeListenerManager.removeDynamicListener( this );
if( outlinePage != null ) {
outlinePage.setInput( null );
}
@@ -530,6 +533,7 @@ protected void editorSaved() {
public void init( final IEditorSite site, final IEditorInput input )
throws PartInitException {
super.init( site, input );
+ CabalFileChangeListenerManager.addDynamicListener( this );
outlinePage = new HaskellOutlinePage( this );
if (lastOutlineResult!=null){
outlinePage.setInput( lastOutlineResult.getOutlineDefs() );
@@ -716,6 +720,21 @@ public void synchronize(){
}
}
+ /* (non-Javadoc)
+ * @see net.sf.eclipsefp.haskell.ui.util.CabalFileChangeListener#cabalFileChanged(org.eclipse.core.resources.IFile)
+ */
+ @Override
+ public void cabalFileChanged( final IFile cabalF ) {
+ IFile file=findFile();
+ if (file!=null){
+ BWFacade f=BuildWrapperPlugin.getFacade( file.getProject() );
+ if (f!=null){
+ // cabal has changed: restart long running job to take new packages, flags, etc
+ f.endLongRunning( file );
+ synchronize();
+ }
+ }
+ }
/**
* @return the importsManager
6 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/refactoring/RenameDelegate.java
View
@@ -109,8 +109,10 @@ private CompositeChange createRenameChange(final IProgressMonitor pm) {
// nothing found: change locally
List<Occurrence> occs=haskellEditor.getTokenScanner().getOccurrences( l.getStartOffset( haskellEditor.getDocument() ) );
Location spanLocation=haskellEditor.getOutlineSpan( getLocation().getStartOffset( haskellEditor.getDocument() ) );
- CompositeChange cc=ChangeCreator.getLocalReferencesChange(haskellEditor.findFile(),spanLocation, occs, tap.getName(), getNewName() );
- return cc;
+ if (spanLocation!=null){
+ CompositeChange cc=ChangeCreator.getLocalReferencesChange(haskellEditor.findFile(),spanLocation, occs, tap.getName(), getNewName() );
+ return cc;
+ }
}
}
}
77 ....eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/CabalFileChangeListenerManager.java
View
@@ -1,34 +1,43 @@
-package net.sf.eclipsefp.haskell.ui.internal.scion;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
-import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
-import net.sf.eclipsefp.haskell.ui.util.CabalFileChangeListener;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-/**
- * <p>Utility to retrieve cabal file change listener</p>
- *
- * @author JP Moresmau
- */
-public class CabalFileChangeListenerManager {
- private static Collection<CabalFileChangeListener> listeners=null;
-
- public static Collection<CabalFileChangeListener> getListeners(){
- if (listeners==null){
- IConfigurationElement[] elts=HaskellUIPlugin.getDefault().getExtensions( HaskellUIPlugin.ID_EXT_CabalChangeListener );
- listeners=new ArrayList<CabalFileChangeListener>(elts.length);
- for (IConfigurationElement elem:elts){
- try {
- Object o = elem.createExecutableExtension(HaskellCorePlugin.ATT_CLASS);
- listeners.add( (CabalFileChangeListener )o);
- } catch (CoreException cex) {
- HaskellCorePlugin.log( cex );
- }
- }
- }
- return listeners;
- }
-}
+package net.sf.eclipsefp.haskell.ui.internal.scion;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import net.sf.eclipsefp.haskell.core.HaskellCorePlugin;
+import net.sf.eclipsefp.haskell.ui.HaskellUIPlugin;
+import net.sf.eclipsefp.haskell.ui.util.CabalFileChangeListener;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * <p>Utility to retrieve cabal file change listener</p>
+ *
+ * @author JP Moresmau
+ */
+public class CabalFileChangeListenerManager {
+ private static Collection<CabalFileChangeListener> listeners=null;
+
+ public static Collection<CabalFileChangeListener> getListeners(){
+ if (listeners==null){
+ IConfigurationElement[] elts=HaskellUIPlugin.getDefault().getExtensions( HaskellUIPlugin.ID_EXT_CabalChangeListener );
+ listeners=Collections.synchronizedList( new ArrayList<CabalFileChangeListener>());
+ for (IConfigurationElement elem:elts){
+ try {
+ Object o = elem.createExecutableExtension(HaskellCorePlugin.ATT_CLASS);
+ listeners.add( (CabalFileChangeListener )o);
+ } catch (CoreException cex) {
+ HaskellCorePlugin.log( cex );
+ }
+ }
+ }
+ return listeners;
+ }
+
+ public static void addDynamicListener(final CabalFileChangeListener listener){
+ getListeners().add( listener );
+ }
+
+ public static void removeDynamicListener(final CabalFileChangeListener listener){
+ getListeners().remove( listener );
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.