Skip to content

Commit

Permalink
exeFactories_101012
Browse files Browse the repository at this point in the history
(a) Create factories for specific types of servers, i.e., standard I/O stream factories for the built-in and the
    user-defined scion-servers. Keep support for the network pipe servers as well, even if they're not invoked.
(b) scion-server executable instance management moved to ScionPlugin via static methods. UI's ScionManager
  does not directly manage the project-to-scion instance association map; this is all done by ScionPlugin.
(c) ScionManager will wail once when the scion-server executable factory is changed but can't start servers.
(d) Support scion-server event changes so that editors can refresh their contents, etc.

Found issue at server startup and async commands that needs fixing -- multiple commands get sent to the
scion-server but need to be processed in temporal order. Also, looks like scion-server needs to send back
the actual request id, not its generated id because these are not necessarily kept in sync.

Still not sure why the outline page doesn't refresh...
  • Loading branch information
Scott Michel committed Oct 13, 2010
1 parent 4ef1fcb commit bb76b91
Show file tree
Hide file tree
Showing 23 changed files with 1,450 additions and 1,044 deletions.
Expand Up @@ -8,8 +8,8 @@
import java.io.IOException;
import java.io.StringWriter;
import junit.framework.TestCase;
import net.sf.eclipsefp.haskell.core.compiler.NullWriter;
import net.sf.eclipsefp.haskell.util.IProcessFactory;
import net.sf.eclipsefp.haskell.util.NullWriter;
import net.sf.eclipsefp.haskell.util.ProcessRunner;

public class ProcessRunner_Test extends TestCase {
Expand Down
Expand Up @@ -13,6 +13,7 @@
package net.sf.eclipsefp.haskell.core.compiler;

import java.io.Writer;
import net.sf.eclipsefp.haskell.util.NullWriter;
import org.eclipse.core.resources.IFile;

/**
Expand Down
3 changes: 2 additions & 1 deletion net.sf.eclipsefp.haskell.debug.ui/META-INF/MANIFEST.MF
Expand Up @@ -17,7 +17,8 @@ Require-Bundle: net.sf.eclipsefp.haskell.ghccompiler,
org.eclipse.jface.text;bundle-version="3.5.1",
org.eclipse.ui.editors;bundle-version="3.5.0",
net.sf.eclipsefp.haskell.util,
net.sf.eclipsefp.haskell.compat
net.sf.eclipsefp.haskell.compat,
net.sf.eclipsefp.haskell.scion.client;bundle-version="2.0.1"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Localization: plugin
Export-Package: net.sf.eclipsefp.haskell.debug.ui.internal;x-friends:="net.sf.eclipsefp.haskell.debug.ui.test",
Expand Down
@@ -0,0 +1,26 @@
package net.sf.eclipsefp.haskell.scion.client;

import java.io.File;
import java.io.Writer;

import net.sf.eclipsefp.haskell.scion.internal.client.NetworkScionServer;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;

public class BuiltInNetworkServerFactory implements IScionServerFactory {
/** Default constructor. */
public BuiltInNetworkServerFactory() {
// NOP
}

/** Generate a new BuiltInServer instance */
public IScionServer createScionServer(IProject project, Writer outStream) {
File directory = (project !=null) ? new File(project.getLocation().toOSString()) : null;
return new NetworkScionServer(ScionPlugin.builtinServerExecutablePath(), outStream, directory);
}

public IPath getServerExecutable() {
return ScionPlugin.builtinServerExecutablePath();
}
}
@@ -0,0 +1,31 @@
package net.sf.eclipsefp.haskell.scion.client;

import java.io.File;
import java.io.Writer;

import net.sf.eclipsefp.haskell.scion.internal.client.StdStreamScionServer;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;

/** The built-in scion server factory. This is really a special case of the user-specified
* server, where the path to the executable is well known.
*
* @author B. Scott Michel (scooter.phd@gmail.com)
*/
public class BuiltInStdStreamServerFactory implements IScionServerFactory {
/** Default constructor. */
public BuiltInStdStreamServerFactory() {
// NOP
}

/** Generate a new BuiltInServer instance */
public IScionServer createScionServer(IProject project, Writer outStream) {
File directory = (project !=null) ? new File(project.getLocation().toOSString()) : null;
return new StdStreamScionServer(ScionPlugin.builtinServerExecutablePath(), outStream, directory);
}

public IPath getServerExecutable() {
return ScionPlugin.builtinServerExecutablePath();
}
}
@@ -1,10 +1,11 @@
package net.sf.eclipsefp.haskell.scion.internal.client;
package net.sf.eclipsefp.haskell.scion.client;

import org.eclipse.core.runtime.IProgressMonitor;

import net.sf.eclipsefp.haskell.scion.exceptions.ScionCommandException;
import net.sf.eclipsefp.haskell.scion.exceptions.ScionServerException;
import net.sf.eclipsefp.haskell.scion.exceptions.ScionServerStartupException;
import net.sf.eclipsefp.haskell.scion.internal.client.IScionCommandRunner;
import net.sf.eclipsefp.haskell.scion.internal.commands.ScionCommand;

/**
Expand All @@ -28,9 +29,14 @@ public interface IScionServer {
/**
* run the command synchronously
* @param command the command
* @param monitor the monitor to manage cancelation, etc.
* @param monitor the monitor to manage cancellation, etc.
* @throws ScionServerException
* @throws ScionCommandException
*/
void runCommandSync(ScionCommand command,IProgressMonitor monitor) throws ScionServerException, ScionCommandException;

/**
* Check server's protocol version, log a message if it's not a match.
*/
void checkProtocol(IScionCommandRunner cmdRunner);
}
@@ -0,0 +1,7 @@
package net.sf.eclipsefp.haskell.scion.client;

/** Interface for catching and processing scion server events */
public interface IScionServerEventListener {
/** Process a scion server event */
public void processScionServerEvent(ScionServerEvent ev);
}
@@ -0,0 +1,24 @@
/**
*
*/
package net.sf.eclipsefp.haskell.scion.client;

import java.io.Writer;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;


/** Scion executable factory interface.
*
* @author B. Scott Michel (scooter.phd@gmail.com)
*/
public interface IScionServerFactory {
/** Create a new ScionExectable
* @param project The associated project, which identifies the working directory for the server
* @param outStream TODO
*/
public IScionServer createScionServer(final IProject project, final Writer outStream);
/** Get the server executable IPath */
public IPath getServerExecutable();
}
@@ -0,0 +1,26 @@
package net.sf.eclipsefp.haskell.scion.client;
import java.io.File;
import java.io.Writer;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;

import net.sf.eclipsefp.haskell.scion.internal.client.NetworkScionServer;

public class NetworkStreamScionServerFactory implements IScionServerFactory {
private IPath userExecutable;

public NetworkStreamScionServerFactory(final IPath userExecutable) {
this.userExecutable = userExecutable;
}

public IScionServer createScionServer(IProject project, Writer outStream) {
File directory = (project !=null) ? new File(project.getLocation().toOSString()) : null;
return new NetworkScionServer(userExecutable, outStream, directory);
}

public IPath getServerExecutable() {
return userExecutable;
}

}
@@ -0,0 +1,43 @@
package net.sf.eclipsefp.haskell.scion.client;

import java.io.Writer;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;

import net.sf.eclipsefp.haskell.scion.internal.client.NullScionServer;

/**
* The null scion server factory.
*
* @author B. Scott Michel
*/
public class NullScionServerFactory implements IScionServerFactory {
/** Container class for the {@link NullScionServerFactory NullScionServerFactory} singleton
* instance.
*/
private final static class SingletonContainer {
private final static NullScionServerFactory theInstance = new NullScionServerFactory();
}

/** Default constructor. This is hidden so preserve singleton semantics. */
private NullScionServerFactory() {
// NOP
}

/** Get the singleton factory instance */
public final static NullScionServerFactory getDefault() {
return SingletonContainer.theInstance;
}

/** Create a new NullScionServer. In reality, this just returns another reference
* to the {@link NullScionServer NullScionServer}'s singleton. */
public IScionServer createScionServer(final IProject project, final Writer outStream) {
return NullScionServer.getDefault();
}

public IPath getServerExecutable() {
return new Path("/nullServer");
}
}

0 comments on commit bb76b91

Please sign in to comment.