Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of git://github.com/bscottm/eclipsefp

  • Loading branch information...
commit d0396e78ebeefa813cefd5b289cdd2840cc8db6f 2 parents 766114b + 804f1f3
@JPMoresmau authored
Showing with 428 additions and 307 deletions.
  1. +1 −6 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/builder/HaskellBuilder.java
  2. +0 −89 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/CommandGroup.java
  3. +50 −0 ...sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/CommandGroupSchedulingRule.java
  4. +5 −36 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/FileCommandGroup.java
  5. +46 −0 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/HaskellFileSchedulingRule.java
  6. +64 −0 ....eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/HaskellProjectSchedulingRule.java
  7. +29 −46 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/ProjectCommandGroup.java
  8. +162 −108 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/ScionInstance.java
  9. +38 −0 ...sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/WithLoadedFileCommandGroup.java
  10. +7 −2 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/internal/util/ScionText.java
  11. +7 −1 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/internal/util/sciontext.properties
  12. +8 −7 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/ProjectReloader.java
  13. +6 −2 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/ScionManager.java
  14. +2 −2 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/UITexts.java
  15. +2 −2 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/uitexts.properties
  16. +1 −6 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/ModuleCreationOperation.java
View
7 net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/builder/HaskellBuilder.java
@@ -14,7 +14,6 @@
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
/** <p>The incremental builder for Haskell projects.</p>
*
@@ -112,11 +111,7 @@ public void fullBuild( final IProgressMonitor mon ) {
getProject().accept( new BuildVisitor( subMon ) );*/
ScionInstance si = ScionPlugin.getScionInstance( getProject() );
if (si != null ) {
- Job projectJob = si.buildProject(true, false);
-
- if (projectJob != null) {
- projectJob.schedule();
- }
+ si.buildProjectWithinJob(mon, true, false);
} else {
new Exception("ScionInstance == null").printStackTrace(); //$NON-NLS-1$
}
View
89 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/CommandGroup.java
@@ -1,89 +0,0 @@
-package net.sf.eclipsefp.haskell.scion.client;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-
-/**
- * The base class for project and file command groups. It implements the primitive
- * scheduling rule, provides facilities for partial ordering of command groups when
- * neccessary.
- *
- * @author B. Scott Michel (scooter.phd@gmail.com)
- */
-public abstract class CommandGroup extends Job implements ISchedulingRule {
- /** Sequence number generator */
- private static AtomicInteger nextCmdSeq = new AtomicInteger();
- /** Sequence number used to maintain ordering between project and file command groups. */
- private int cmdSeqNo;
-
- /** The constructor, which assigns all project and file command groups have
- * a sequence number.
- *
- * @param jobName Job
- */
- public CommandGroup(String jobName) {
- super(jobName);
- cmdSeqNo = nextCmdSeq.incrementAndGet();
- setName( adornedName(jobName) );
- }
-
- /**
- * Formats the Job's name, includes the command group's sequence number for easier
- * rule scheduling debugging (should see command groups partially ordered by sequence
- * number when executed.)
- *
- * @param jobName The Job's name
- * @return "Job Name [seqno]" string.
- */
- private String adornedName(final String jobName) {
- return jobName.concat(" [").concat(String.valueOf(cmdSeqNo)).concat("]");
- }
-
- /**
- * Predicate that enforces partial ordering of command groups.
- *
- * @param rhs Right hand side of the comparison
- * @return True if this command group should be ordered before the right hand side.
- */
- public boolean orderBefore(CommandGroup rhs) {
- return (cmdSeqNo <= rhs.cmdSeqNo);
- }
-
- /**
- * ISchedulingRule contains() method: This rule contains another iff it is the same
- * scheduling rule.
- */
- public boolean contains(ISchedulingRule rule) {
- return (rule == this);
- }
-
- /**
- * ISchedulingRule isConflicting() method: Another Job conflicts iff it is the same
- * scheduling rule.
- */
- public boolean isConflicting(ISchedulingRule rule) {
- return (rule == this);
- }
-
- /**
- * Run the command group, anticipating a result.
- *
- * @return The Job status after the command group completes.
- */
- public IStatus runGroupSynchronously() {
- schedule();
-
- while (getResult() == null) {
- try {
- join();
- } catch (InterruptedException irq) {
- // Keep going...
- }
- }
-
- return getResult();
- }
-}
View
50 ...eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/CommandGroupSchedulingRule.java
@@ -0,0 +1,50 @@
+package net.sf.eclipsefp.haskell.scion.client;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+
+public class CommandGroupSchedulingRule implements ISchedulingRule {
+ /** Sequence number generator */
+ private static AtomicInteger nextCmdSeq = new AtomicInteger();
+ /** The command group sequence number for this rule */
+ private int cmdGroupSeqno;
+
+ public CommandGroupSchedulingRule() {
+ this.cmdGroupSeqno = nextCmdSeq.incrementAndGet();;
+ }
+
+ /**
+ * Accessor for the command group sequence number.
+ */
+ public int getCommandGroupSeqno() {
+ return cmdGroupSeqno;
+ }
+
+ /**
+ * Predicate that enforces partial ordering of command groups.
+ *
+ * @param rhs Right hand side of the comparison
+ * @return True if this command group should be ordered before the right hand side.
+ */
+ public boolean orderBefore(CommandGroupSchedulingRule rhs) {
+ return (cmdGroupSeqno <= rhs.cmdGroupSeqno);
+ }
+
+ /**
+ * ISchedulingRule contains() method: This rule contains another iff it is the same
+ * scheduling rule.
+ */
+ public boolean contains(ISchedulingRule rule) {
+ return (rule == this);
+ }
+
+ /**
+ * ISchedulingRule isConflicting() method: Another Job conflicts iff it is the same
+ * scheduling rule.
+ */
+ public boolean isConflicting(ISchedulingRule rule) {
+ return (rule == this);
+ }
+
+}
View
41 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/FileCommandGroup.java
@@ -5,8 +5,6 @@
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
/**
* A file command group is a Job that prevents other commands from interacting
@@ -30,7 +28,11 @@
public FileCommandGroup(String jobName, IFile theFile, int priority) {
super(jobName, theFile.getProject(), false);
this.theFile = theFile;
- setRule(this);
+
+ HaskellFileSchedulingRule rule = new HaskellFileSchedulingRule(theFile);
+
+ setRule(rule);
+ setName( adornedName(jobName, rule) );
setPriority(priority);
}
@@ -40,37 +42,4 @@ public FileCommandGroup(String jobName, IFile theFile, int priority) {
public IFile getFile() {
return theFile;
}
-
- /**
- * ISchedulingRule contains() method: This method ensures that this scheduling rule only
- * contains itself.
- *
- * @param rule The other scheduling rule
- * @return True iff the other scheduling rule is the same as this scheduling rule.
- */
- public boolean contains(ISchedulingRule rule) {
- return (rule == this);
- }
-
- /**
- * Prevent another command group from running if it is associated with the same file or
- * within the same project (the superclass enforces this.)
- *
- * @param rule The other scheduling rule.
- * @return True if the other scheduling rule conflicts.
- */
- @Override
- public boolean isConflicting(ISchedulingRule rule) {
- boolean retval = super.isConflicting(rule);
-
- if (rule instanceof FileCommandGroup) {
- FileCommandGroup fileGroup = (FileCommandGroup) rule;
- retval = retval || ( theFile.equals(fileGroup.theFile) && orderBefore(fileGroup));
- } else if (rule instanceof IResource) {
- IResource res = (IResource) rule;
- retval = retval || ( theFile.getFullPath().equals(res.getFullPath()) );
- }
-
- return retval;
- }
}
View
46 ....eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/HaskellFileSchedulingRule.java
@@ -0,0 +1,46 @@
+package net.sf.eclipsefp.haskell.scion.client;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+
+public class HaskellFileSchedulingRule extends HaskellProjectSchedulingRule {
+ private IFile theFile;
+
+ public HaskellFileSchedulingRule(final IFile theFile) {
+ super(theFile.getProject());
+ this.theFile = theFile;
+ }
+ /**
+ * ISchedulingRule contains() method: This method ensures that this scheduling rule only
+ * contains itself.
+ *
+ * @param rule The other scheduling rule
+ * @return True iff the other scheduling rule is the same as this scheduling rule.
+ */
+ public boolean contains(ISchedulingRule rule) {
+ return (rule == this);
+ }
+
+ /**
+ * Prevent another command group from running if it is associated with the same file or
+ * within the same project (the superclass enforces this.)
+ *
+ * @param rule The other scheduling rule.
+ * @return True if the other scheduling rule conflicts.
+ */
+ @Override
+ public boolean isConflicting(ISchedulingRule rule) {
+ boolean retval = super.isConflicting(rule);
+
+ if (rule instanceof HaskellFileSchedulingRule) {
+ HaskellFileSchedulingRule fileGroup = (HaskellFileSchedulingRule) rule;
+ retval = retval || ( theFile.equals(fileGroup.theFile) && orderBefore(fileGroup));
+ } else if (rule instanceof IResource) {
+ IResource res = (IResource) rule;
+ retval = retval || ( theFile.getFullPath().equals(res.getFullPath()) );
+ }
+
+ return retval;
+ }
+}
View
64 ...lipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/HaskellProjectSchedulingRule.java
@@ -0,0 +1,64 @@
+package net.sf.eclipsefp.haskell.scion.client;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+
+public class HaskellProjectSchedulingRule extends CommandGroupSchedulingRule {
+ private IProject theProject;
+
+ public HaskellProjectSchedulingRule(final IProject theProject) {
+ super();
+ this.theProject = theProject;
+ }
+
+ /**
+ * ISchedulingRule contains() method: This scheduling rule contains another
+ * scheduling rule if the other is part of the same project.
+ *
+ * @param rule
+ * The other scheduling rule
+ * @return True if this scheduling rule and the other scheduling rule are part
+ * of the same project
+ *
+ * @note Need to include this for
+ * {@link ScionInstance#buildProject(boolean, boolean)}, which has
+ * subsidiary Jobs that are contained within the same project.
+ */
+ @Override
+ public boolean contains(ISchedulingRule rule) {
+ boolean retval = super.contains(rule);
+
+ if (rule instanceof ProjectCommandGroup) {
+ retval = retval || ( theProject.equals( (ProjectCommandGroup) rule) );
+ } else if (rule instanceof IProject) {
+ retval = retval || theProject.equals( (IProject) rule );
+ } else if (rule instanceof IResource ) {
+ retval = retval || ( theProject.equals( ((IResource) rule).getProject() ) );
+ }
+
+ // This rule contains anotherProject if anotherProject is theProject or the rule
+ // is this object. This ensures nesting of tasks within the same project.
+ return retval;
+ }
+
+ /**
+ * Prevent two project command groups from running if they belong to the same
+ * project. This predicate also knows about {@link FileCommandGroup) objects
+ * and will prevent those from running as well.
+ *
+ * @param rule The scheduling rule against which this rule is being compared.
+ * @return True if the two rule conflict, i.e., belong to the same project.
+ */
+ @Override
+ public boolean isConflicting(ISchedulingRule rule) {
+ boolean retval = super.isConflicting(rule);
+
+ if (rule instanceof ProjectCommandGroup) {
+ ProjectCommandGroup projRule = (ProjectCommandGroup) rule;
+ retval = retval || ( theProject.equals(projRule.theProject) );
+ }
+
+ return retval;
+ }
+}
View
75 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/ProjectCommandGroup.java
@@ -7,8 +7,8 @@
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.Job;
/**
* A project command group is a logical grouping of commands that excludes other commands from running
@@ -16,7 +16,7 @@
*
* @author B. Scott Michel (scooter.phd@gmail.com)
*/
-public abstract class ProjectCommandGroup extends CommandGroup {
+public abstract class ProjectCommandGroup extends Job {
/** The project against which this command group holds exclusive access */
IProject theProject;
@@ -40,63 +40,46 @@ public ProjectCommandGroup(String jobName, IProject theProject) {
* @param theProject
* The command group's project.
* @param installRule
- * If true, installs the project-based command group scheduling rule.
+ * If true, installs the project-based command group scheduling rule. Subclasses should
+ * pass false in order to install their own scheduling rules.
*/
protected ProjectCommandGroup(String jobName, IProject theProject, boolean installRule) {
super(jobName);
this.theProject = theProject;
if (installRule) {
- setRule(this);
+ HaskellProjectSchedulingRule rule = new HaskellProjectSchedulingRule(theProject);
+
+ setRule(rule);
+ setName( adornedName(jobName, rule) );
}
}
-
+
/**
- * ISchedulingRule contains() method: This scheduling rule contains another
- * scheduling rule if the other is part of the same project.
- *
- * @param rule
- * The other scheduling rule
- * @return True if this scheduling rule and the other scheduling rule are part
- * of the same project
+ * Formats the Job's name, includes the command group's sequence number for easier
+ * rule scheduling debugging (should see command groups partially ordered by sequence
+ * number when executed.)
*
- * @note Need to include this for
- * {@link ScionInstance#buildProject(boolean, boolean)}, which has
- * subsidiary Jobs that are contained within the same project.
+ * @param jobName The Job's name
+ * @return "Job Name [seqno]" string.
*/
- @Override
- public boolean contains(ISchedulingRule rule) {
- boolean retval = super.contains(rule);
-
- if (rule instanceof ProjectCommandGroup) {
- retval = retval || ( theProject.equals( (ProjectCommandGroup) rule) );
- } else if (rule instanceof IProject) {
- retval = retval || theProject.equals( (IProject) rule );
- } else if (rule instanceof IResource ) {
- retval = retval || ( theProject.equals( ((IResource) rule).getProject() ) );
- }
-
- // This rule contains anotherProject if anotherProject is theProject or the rule
- // is this object. This ensures nesting of tasks within the same project.
- return retval;
+ protected String adornedName(final String jobName, CommandGroupSchedulingRule rule) {
+ return jobName.concat(" [group ").concat(String.valueOf(rule.getCommandGroupSeqno())).concat("]");
}
-
-/**
- * Prevent two project command groups from running if they belong to the same
- * project. This predicate also knows about {@link FileCommandGroup) objects
- * and will prevent those from running as well.
- *
- * @param rule The scheduling rule against which this rule is being compared.
- * @return True if the two rule conflict, i.e., belong to the same project.
+
+ /**
+ * Run the command group synchronously, expecting a result.
*/
- @Override
- public boolean isConflicting(ISchedulingRule rule) {
- boolean retval = super.isConflicting(rule);
+ public IStatus runGroupSynchronously() {
+ schedule();
- if (rule instanceof ProjectCommandGroup) {
- ProjectCommandGroup projRule = (ProjectCommandGroup) rule;
- retval = retval || ( theProject.equals(projRule.theProject) );
+ while (getResult() == null) {
+ try {
+ join();
+ } catch (InterruptedException irq) {
+ // Keep going...
+ }
}
- return retval;
+ return getResult();
}
}
View
270 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/ScionInstance.java
@@ -54,6 +54,8 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.util.SafeRunnable;
@@ -302,62 +304,12 @@ public Job buildProject(final boolean output, final boolean forceRecomp) {
retval = new ProjectCommandGroup(jobNamePrefix, getProject()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- cabalDescription = null;
- final String cabalProjectFile = getCabalFile(getProject()).getLocation().toOSString();
- final ListCabalComponentsCommand command = new ListCabalComponentsCommand(cabalProjectFile);
-
- if (!server.sendCommand(command))
- return Status.CANCEL_STATUS;
-
- components = command.getComponents();
- // if lastLoadedComponent is still present, load it last
- if (lastLoadedComponent != null) {
- List<Component> l = new ArrayList<Component>(components.size());
- Component toLoadLast = null;
- synchronized (components) {
- for (Component c : components) {
- if (c.toString().equals(lastLoadedComponent.toString())) {
- toLoadLast = c;
- } else {
- l.add(c);
- }
- }
- }
-
- if (toLoadLast != null) {
- l.add(toLoadLast);
- }
- components = l;
- }
-
- List<Component> cs = null;
- synchronized (components) {
- cs = new ArrayList<Component>(components);
- }
-
- deleteProblems(getProject());
- final CompilationResultHandler crh = new CompilationResultHandler(getProject());
-
- for (Component c : cs) {
- final LoadCommand loadCommand = new LoadCommand(getProject(), c, output, forceRecomp);
- if (!server.sendCommand(loadCommand))
- return Status.CANCEL_STATUS;
-
- crh.process(loadCommand);
- lastLoadedComponent = c;
+ try {
+ monitor.beginTask(jobNamePrefix, IProgressMonitor.UNKNOWN);
+ buildProjectInternal(monitor, output, forceRecomp);
+ } finally {
+ monitor.done();
}
-
- ParseCabalCommand pcc = new ParseCabalCommand(getCabalFile(getProject()).getLocation().toOSString());
- if (!server.sendCommand(pcc))
- return Status.CANCEL_STATUS;
- cabalDescription = pcc.getDescription();
-
- CabalDependenciesCommand cdc = new CabalDependenciesCommand(getCabalFile(getProject()).getLocation().toOSString());
- if (!server.sendCommand(cdc))
- return Status.CANCEL_STATUS;
- packagesByDB = cdc.getPackagesByDB();
-
- restoreState();
return Status.OK_STATUS;
}
};
@@ -367,7 +319,116 @@ protected IStatus run(IProgressMonitor monitor) {
return retval;
}
+
+ public boolean buildProjectWithinJob(final IProgressMonitor monitor, final boolean output, final boolean forceRecomp) {
+ boolean retval = false;
+ IJobManager mgr = Job.getJobManager();
+
+ try {
+ mgr.beginRule(project, monitor);
+ if ( checkCabalFile() ) {
+ retval = buildProjectInternal(monitor, output, forceRecomp);
+ }
+ } finally {
+ mgr.endRule(project);
+ }
+
+ return retval;
+ }
+
+ private boolean buildProjectInternal(final IProgressMonitor monitor, final boolean output, final boolean forceRecomp) {
+ boolean retval = false;
+ final String projectName = project.getName();
+
+ if ( listComponents(monitor) && loadComponents(monitor, output, forceRecomp) ) {
+ monitor.subTask( NLS.bind( ScionText.buildProject_parseCabalDescription, projectName ) );
+ ParseCabalCommand pcc = new ParseCabalCommand(getCabalFile(getProject()).getLocation().toOSString());
+ if (server.sendCommand(pcc)) {
+ cabalDescription = pcc.getDescription();
+
+ monitor.subTask( NLS.bind( ScionText.buildProject_cabalDependencies, projectName ) );
+ CabalDependenciesCommand cdc = new CabalDependenciesCommand(getCabalFile(getProject()).getLocation().toOSString());
+ if (server.sendCommand(cdc)) {
+ packagesByDB = cdc.getPackagesByDB();
+ retval = true;
+ restoreState();
+ }
+ }
+ }
+
+ return retval;
+ }
+
+ private boolean listComponents(IProgressMonitor monitor) {
+ monitor.subTask( NLS.bind( ScionText.buildProject_listComponents, project.getName() ) );
+
+ cabalDescription = null;
+ final String cabalProjectFile = getCabalFile(getProject()).getLocation().toOSString();
+ final ListCabalComponentsCommand command = new ListCabalComponentsCommand(cabalProjectFile);
+
+ if (server.sendCommand(command)) {
+ components = command.getComponents();
+
+ // if lastLoadedComponent is still present, load it last
+ if (lastLoadedComponent != null) {
+ List<Component> l = new ArrayList<Component>(components.size());
+ Component toLoadLast = null;
+ synchronized (components) {
+ for (Component c : components) {
+ if (c.toString().equals(lastLoadedComponent.toString())) {
+ toLoadLast = c;
+ } else {
+ l.add(c);
+ }
+ }
+ }
+
+ if (toLoadLast != null) {
+ l.add(toLoadLast);
+ }
+
+ components = l;
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ private boolean loadComponents(IProgressMonitor monitor, final boolean output, final boolean forceRecomp) {
+ List<Component> cs = null;
+ IProject theProject = getProject();
+ boolean failed = false;
+
+ synchronized (components) {
+ cs = new ArrayList<Component>(components);
+ }
+
+ deleteProblems(theProject);
+ final CompilationResultHandler crh = new CompilationResultHandler(theProject);
+
+ for (Component c : cs) {
+ monitor.subTask( NLS.bind ( ScionText.buildProject_loadComponents, c.toString() ) );
+
+ final LoadCommand loadCommand = new LoadCommand(theProject, c, output, forceRecomp);
+ if (server.sendCommand(loadCommand)) {
+ crh.process(loadCommand);
+ lastLoadedComponent = c;
+ } else {
+ failed = true;
+ break;
+ }
+ }
+
+ if (failed) {
+ // Clear out state
+ internalReset();
+ }
+
+ return !failed;
+ }
// ////////////////////
// Internal commands
@@ -489,11 +550,7 @@ private boolean runWithComponent( final IFile file ) {
* The file to be loaded.
*/
public boolean reloadFile(final IFile file) {
- boolean retval = runWithComponent(file);
- if ( retval )
- retval = server.sendCommand(new BackgroundTypecheckFileCommand( this, file ) );
-
- return retval;
+ return ( runWithComponent(file) && server.sendCommand(new BackgroundTypecheckFileCommand( this, file ) ) );
}
public boolean reloadFile(final IFile file, final IDocument doc) {
@@ -519,12 +576,7 @@ public boolean onError(String name, String message) {
}
};
- boolean retval = runWithComponent( file );
- if (retval){
- // load the saved file first
- retval = withLoadedFile(file, cmd );
- }
- return retval;
+ return runWithComponent( file ) && withLoadedFile( file, cmd );
}
public void unloadFile(IFile fileName) {
@@ -532,54 +584,56 @@ public void unloadFile(IFile fileName) {
loadedFile = null;
}
- public String thingAtPoint(final IDocument doc,Location location,boolean qualify,boolean typed) {
- // the scion command will only work fine if we have the proper file loaded
- final IFile file = location.getIFile(getProject());
- if (file != null){
- final String jobName = NLS.bind(ScionText.thingatpoint_job_name,file.getName());
- final ThingAtPointCommand cmd = new ThingAtPointCommand(location,qualify,typed);
- new FileCommandGroup(jobName, file, Job.SHORT) {
- @Override
- protected IStatus run( final IProgressMonitor monitor ) {
- reloadFile(file, doc);
- server.sendCommand(cmd);
- return Status.OK_STATUS;
- }
- }.runGroupSynchronously();
- return cmd.getThing();
- }
- return null;
- }
-
- public List<OutlineDef> outline( final IFile file ) {
- final String jobName = NLS.bind(ScionText.outline_job_name,file.getName());
- final OutlineCommand cmd = new OutlineCommand(file);
+ public String thingAtPoint(final IDocument doc, Location location, boolean qualify, boolean typed) {
+ // the scion command will only work fine if we have the proper file loaded
+ final IFile file = location.getIFile(getProject());
+ if (file != null) {
+ final String jobName = NLS.bind(ScionText.thingatpoint_job_name, file.getName());
+ final ThingAtPointCommand cmd = new ThingAtPointCommand(location, qualify, typed);
new FileCommandGroup(jobName, file, Job.SHORT) {
@Override
- protected IStatus run( final IProgressMonitor monitor ) {
- withLoadedFile( file, cmd );
- return Status.OK_STATUS;
+ protected IStatus run(final IProgressMonitor monitor) {
+ reloadFile(file, doc);
+ server.sendCommand(cmd);
+ return Status.OK_STATUS;
}
}.runGroupSynchronously();
- return cmd.getOutlineDefs();
+ return cmd.getThing();
+ }
+ return null;
+ }
+
+ public List<OutlineDef> outline(final IFile file) {
+ final String jobName = NLS.bind(ScionText.outline_job_name, file.getName());
+ final OutlineCommand cmd = new OutlineCommand(file);
+
+ new FileCommandGroup(jobName, file, Job.SHORT) {
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ withLoadedFile(file, cmd);
+ return Status.OK_STATUS;
+ }
+ }.runGroupSynchronously();
+
+ return cmd.getOutlineDefs();
}
- public void outline(final IFile file , final IDocument doc,final IOutlineHandler handler){
- if (file!=null && handler!=null){
- final String jobName = NLS.bind(ScionText.outline_job_name,file.getName());
- new FileCommandGroup(jobName, file, Job.SHORT) {
- @Override
- protected IStatus run( final IProgressMonitor monitor ) {
- final OutlineCommand cmd = new OutlineCommand(file);
-
- reloadFile(file, doc);
- server.sendCommand(cmd);
- handler.handleOutline(cmd.getOutlineDefs());
-
- return Status.OK_STATUS;
- }
- }.schedule();
- }
+ public void outline(final IFile file, final IDocument doc, final IOutlineHandler handler) {
+ if (file != null && handler != null) {
+ final String jobName = NLS.bind(ScionText.outline_job_name, file.getName());
+ new FileCommandGroup(jobName, file, Job.SHORT) {
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ final OutlineCommand cmd = new OutlineCommand(file);
+
+ reloadFile(file, doc);
+ server.sendCommand(cmd);
+ handler.handleOutline(cmd.getOutlineDefs());
+
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
}
private boolean withLoadedFile(final IFile file, final ScionCommand cmd) {
View
38 ...eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/WithLoadedFileCommandGroup.java
@@ -0,0 +1,38 @@
+package net.sf.eclipsefp.haskell.scion.client;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+public abstract class WithLoadedFileCommandGroup extends FileCommandGroup {
+ /**
+ * Construct a command group that operates on a file loaded in the scion-server. If the file hasn't been loaded,
+ * then arrange for it to be loaded before subsequent commands execute.
+ *
+ * @param jobName
+ * The name of the job
+ * @param theFile
+ * The file for which this command group is being executed.
+ * @param priority
+ * The Job's priority (should usually be Job.SHORT)
+ */
+ public WithLoadedFileCommandGroup(String jobName, IFile theFile, int priority) {
+ super(jobName, theFile, priority);
+ setPriority(priority);
+ }
+
+ /**
+ * The run() method inherited from Job.
+ */
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ actions();
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * The actions() method.
+ */
+ public abstract void actions();
+}
View
9 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/internal/util/ScionText.java
@@ -50,8 +50,13 @@
public static String process_result_job_arg;
public static String background_typecheck_job;
- public static String outline_job_name;
- public static String thingatpoint_job_name;
+ public static String outline_job_name;
+ public static String thingatpoint_job_name;
+
+ public static String buildProject_listComponents;
+ public static String buildProject_loadComponents;
+ public static String buildProject_parseCabalDescription;
+ public static String buildProject_cabalDependencies;
private static final String BUNDLE_NAME = ScionText.class.getPackage().getName() + ".sciontext"; //$NON-NLS-1$
View
8 net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/internal/util/sciontext.properties
@@ -33,10 +33,16 @@ warning_file_component=File {0} is not part of the modules referenced by the Cab
noproject=[None]
-build_job_name=Building {0}
+build_job_name=Scion server building {0}
process_result_job=ScionCommand result processing for {0}, server {1}.
process_result_job_arg=Result processing for {0}, server {1}, request {2}.
background_typecheck_job=Background type checking {0}
outline_job_name=Generating outline for {0}
thingatpoint_job_name=Finding thing at point in {0}
+
+# buildProjectInternal() subtask messages
+buildProject_listComponents=Listing components for {0}
+buildProject_loadComponents=Loading component {0}
+buildProject_parseCabalDescription=Parsing cabal description for {0}
+buildProject_cabalDependencies=Fetching cabal dependencies for {0}
View
15 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/ProjectReloader.java
@@ -6,6 +6,7 @@
import net.sf.eclipsefp.haskell.scion.client.ScionPlugin;
import net.sf.eclipsefp.haskell.ui.util.CabalFileChangeListener;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.jobs.Job;
/**
@@ -13,14 +14,14 @@
*
* @author JP Moresmau
*/
-public class ProjectReloader implements CabalFileChangeListener{
+public class ProjectReloader implements CabalFileChangeListener {
public void cabalFileChanged( final IFile cabalF ) {
final ScionInstance si = ScionPlugin.getScionInstance( cabalF );
- if (si != null) {
- Job projectJob = si.buildProject( false, true );
- if (projectJob != null) {
- projectJob.schedule();
- }
- }
+
+ Assert.isNotNull( si );
+
+ Job projectJob = si.buildProject( false, true );
+ Assert.isNotNull( projectJob );
+ projectJob.schedule();
}
}
View
8 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/ScionManager.java
@@ -647,6 +647,9 @@ public ScionBuildJob(final String jobTitle, final IOConsole console) {
console.clearConsole();
+ // This is a user visible task, so set the annoy bit:
+ setUser(true);
+
// If the build failed, there will be some indication of why it failed in the
// ScionBuildStatus object. This is where we get to present that back to the
// user:
@@ -662,15 +665,16 @@ public void run() {
}
} );
} else {
- // Yippee! The server built successfully: Tell user and delete the console.
+ /* Yippee! The server built successfully: Tell user and delete the console.
Display.getDefault().syncExec( new Runnable() {
public void run() {
MessageDialog.openInformation( Display.getDefault().getActiveShell(),
UITexts.scionServerProgress_completed_title,
UITexts.scionServerProgress_completed_message );
}
- } );
+ } ); */
+ // Dispose of the console on a successful build
IConsoleManager mgr = ConsolePlugin.getDefault().getConsoleManager();
mgr.removeConsoles( new IConsole[] { fConsole } );
ScionManager.this.internalBuilder = null;
View
4 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/UITexts.java
@@ -307,8 +307,8 @@
public static String scionServerProgress_title;
public static String scionServerProgress_subtask1;
public static String scionServerProgress_subtask2;
- public static String scionServerProgress_completed_title;
- public static String scionServerProgress_completed_message;
+ // public static String scionServerProgress_completed_title;
+ // public static String scionServerProgress_completed_message;
public static String noCabalImplementation_title;
public static String noCabalImplementation_message;
View
4 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/util/uitexts.properties
@@ -314,8 +314,8 @@ scionArchiveNonspecificFileException = Exception while unpacking Scion archive:
scionServerProgress_title = Scion built-in server compiling
scionServerProgress_subtask1 = Unpacking the Scion server source archive
scionServerProgress_subtask2 = Executing "cabal install"
-scionServerProgress_completed_title = Success
-scionServerProgress_completed_message = The built-in Scion server was built successfully.
+# scionServerProgress_completed_title = Success
+# scionServerProgress_completed_message = The built-in Scion server was built successfully.
noCabalImplementation_title = No Cabal Implementation
noCabalImplementation_message = Please set a default Cabal implementation in the Haskell>Scion and Cabal \
View
7 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/wizards/ModuleCreationOperation.java
@@ -20,7 +20,6 @@
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.editors.text.TextFileDocumentProvider;
@@ -131,11 +130,7 @@ public void run( final IProgressMonitor monitor ) throws InvocationTargetExcepti
prov.disconnect( f );
}
- Job projectJob = ScionPlugin.getScionInstance( generatedFile ).buildProject( false , false);
- if (projectJob != null) {
- projectJob.schedule();
- }
-
+ ScionPlugin.getScionInstance( generatedFile ).buildProjectWithinJob( monitor, false , false);
} catch( CoreException ex ) {
throw new InvocationTargetException( ex );
}
Please sign in to comment.
Something went wrong with that request. Please try again.