Commits

sk  committed be47ea9

Moved repl files.

  • Participants
  • Parent commits d616eb8

Comments (0)

Files changed (26)

File .classpath

-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="output" path="bin"/>
-</classpath>

File .project

-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>org.lispdev.repl</name>
-	<comment></comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.pde.ManifestBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.pde.SchemaBuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.pde.PluginNature</nature>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-	</natures>
-</projectDescription>

File .settings/org.eclipse.jdt.core.prefs

-#Sat Jul 03 20:50:04 CDT 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6

File META-INF/MANIFEST.MF

-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Repl
-Bundle-SymbolicName: org.lispdev.repl
-Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.lispdev.repl.ReplPlugin
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.debug.core;bundle-version="3.6.0",
- org.lispdev.log;bundle-version="1.0.0",
- org.lispdev.swank;bundle-version="1.0.0"
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Export-Package: org.lispdev.repl

File build.properties

-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
-               .

File org.lispdev.repl/.classpath

+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

File org.lispdev.repl/.project

+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.lispdev.repl</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

File org.lispdev.repl/.settings/org.eclipse.jdt.core.prefs

+#Sat Jul 03 20:50:04 CDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6

File org.lispdev.repl/META-INF/MANIFEST.MF

+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Repl
+Bundle-SymbolicName: org.lispdev.repl
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.lispdev.repl.ReplPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.debug.core;bundle-version="3.6.0",
+ org.lispdev.log;bundle-version="1.0.0",
+ org.lispdev.swank;bundle-version="1.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: org.lispdev.repl

File org.lispdev.repl/build.properties

+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

File org.lispdev.repl/src/org/lispdev/repl/AbstractRepl.java

+package org.lispdev.repl;
+
+import java.util.Hashtable;
+import java.util.Stack;
+
+import org.lispdev.log.Trace;
+import org.lispdev.swank.ISwank;
+import org.lispdev.swank.runnables.SwankDebugActivateRunnable;
+import org.lispdev.swank.runnables.SwankDebugReturnRunnable;
+import org.lispdev.swank.runnables.SwankDebugRunnable;
+import org.lispdev.swank.runnables.SwankDebugRunnable.DebugInfo;
+import org.lispdev.swank.runnables.SwankDisconnectRunnable;
+import org.lispdev.swank.runnables.SwankPresentationRunnable;
+import org.lispdev.swank.runnables.SwankReadStringRunnable;
+import org.lispdev.swank.runnables.SwankWriteStringRunnable;
+
+/**
+ * Repl is a bridge between swank server events and user interface.
+ */
+public abstract class AbstractRepl
+{
+  private final Stack<IState> states = new Stack<IState>();
+
+  public final ISwank swank;
+
+  private class DisconnectRunnable extends SwankDisconnectRunnable
+  {
+    private final AbstractRepl repl;
+
+    public DisconnectRunnable(AbstractRepl r)
+    {
+      super(swank.getLispImplementation());
+      repl = r;
+    }
+
+    @Override
+    public void run()
+    {
+      repl.disconnected();
+    }
+  }
+
+  private class ReadRunnable extends SwankReadStringRunnable
+  {
+    private final AbstractRepl repl;
+
+    public ReadRunnable(AbstractRepl r)
+    {
+      super(swank.getLispImplementation());
+      repl = r;
+    }
+
+    @Override
+    public void run()
+    {
+      ReadStringInfo info = getInfo();
+      repl.pushState(new ReadState(repl, info));
+    }
+  }
+
+  private final Hashtable<String, DebugInfo> debugInfos =
+    new Hashtable<String, DebugInfo>();
+
+  private class DebugInfoRunnable extends SwankDebugRunnable
+  {
+    public DebugInfoRunnable()
+    {
+      super(swank.getLispImplementation());
+    }
+
+    @Override
+    public void run()
+    {
+      Trace.DEBUG.trace("DebugInfoRunnable: "+ getInfo().toString());
+      debugInfos.put(getKey(), getInfo());
+    }
+  }
+
+  private class DebugRunnable extends SwankDebugActivateRunnable
+  {
+    private final AbstractRepl repl;
+
+    public DebugRunnable(AbstractRepl r)
+    {
+      super(swank.getLispImplementation());
+      repl = r;
+    }
+
+    @Override
+    public void run()
+    {
+      String key = getKey();
+      Trace.DEBUG.trace("*debug found: " + key + "->" + debugInfos.get(key));
+      DebugState state = new DebugState(repl, debugInfos.get(key));
+      Trace.DEBUG.trace("currState:" + currState());
+      if( !currState().equals(state) )
+      {
+        pushState(state);
+      }
+    }
+  }
+
+  private class DebugStopRunnable extends SwankDebugReturnRunnable
+  {
+    private final AbstractRepl repl;
+
+    public DebugStopRunnable(AbstractRepl r)
+    {
+      super(swank.getLispImplementation());
+      repl = r;
+    }
+
+    @Override
+    public void run()
+    {
+      String key = getKey();
+      Trace.DEBUG.trace("*debug found: " + key + "->" + debugInfos.get(key));
+      DebugState state = new DebugState(repl, debugInfos.get(key));
+      Trace.DEBUG.trace("currState:" + currState());
+      if( currState().equals(state) )
+      {
+        popState();
+      }
+    }
+  }
+
+  private class PresentationRunnable extends SwankPresentationRunnable
+  {
+    private final AbstractRepl repl;
+
+    public PresentationRunnable(AbstractRepl r)
+    {
+      super(swank.getLispImplementation());
+      repl = r;
+    }
+
+    @Override
+    public void run()
+    {
+      PresentationInfo info = getInfo();
+      repl.appendOutInspectable(info.text, info.id);
+    }
+  }
+
+  private class WriteStringRunnable extends SwankWriteStringRunnable
+  {
+    private final AbstractRepl repl;
+
+    public WriteStringRunnable(AbstractRepl r)
+    {
+      super(swank.getLispImplementation());
+      repl = r;
+    }
+
+    @Override
+    public void run()
+    {
+      WriteStringInfo info = getInfo();
+      repl.appendOut(info.text);
+    }
+
+  }
+
+  private final WriteStringRunnable writeStringRunnable;
+  private final PresentationRunnable presentationRunnable;
+  private final ReadRunnable readRunnable;
+  private final DisconnectRunnable disconnectRunnable;
+  private final DebugInfoRunnable debugInfoRunnable;
+  private final DebugRunnable debugRunnable;
+  private final DebugStopRunnable debugStopRunnable;
+
+  public AbstractRepl(ISwank s)
+  {
+    swank = s;
+    readRunnable = new ReadRunnable(this);
+    disconnectRunnable = new DisconnectRunnable(this);
+    debugInfoRunnable = new DebugInfoRunnable();
+    debugRunnable = new DebugRunnable(this);
+    debugStopRunnable = new DebugStopRunnable(this);
+    writeStringRunnable = new WriteStringRunnable(this);
+    presentationRunnable = new PresentationRunnable(this);
+
+    pushState(new EvalState(this));
+    swank.addPresentationListener(presentationRunnable);
+    swank.addWriteStringListener(writeStringRunnable);
+    swank.addReadStringListener(readRunnable);
+    swank.addDisconnectListener(disconnectRunnable);
+    swank.addDebugListener(debugInfoRunnable);
+    swank.addDebugActivateListener(debugRunnable);
+    swank.addDebugReturnListener(debugStopRunnable);
+  }
+
+  public abstract void appendOut(String text);
+  public abstract void appendOutInspectable(String text, String id);
+  public abstract void packageChanged(String command);
+  public abstract void saveCommandToHistory(String command);
+  /**
+   * repl suspended to let user perform input - might need to know state
+   */
+  public abstract void doInput();
+  public abstract void disconnected();
+  public abstract void disconnecting();
+  public abstract void connected();
+  public abstract void connecting();
+  public abstract void startDebug(DebugInfo debugInfo);
+  public abstract void debugStoped();
+
+  private void pushState(IState s)
+  {
+    if( states.size() > 1 )
+    {
+      // Assuming anything above one is a debug state?
+      if( currState() instanceof DebugState )
+      {
+        ((DebugState)currState()).deactivate();
+      }
+    }
+    states.push(s);
+    Trace.DEBUG.trace("Repl is in state: " + String.valueOf(s));
+    s.activate();
+    applyState(s);
+  }
+
+  private void popState()
+  {
+    IState s = states.pop();
+    Trace.DEBUG.trace("Repl is in state: " + String.valueOf(s));
+    if( s instanceof DebugState )
+    {
+      ((DebugState)s).deactivate();
+    }
+    currState().activate();
+    applyState(currState());
+  }
+
+  protected IState currState()
+  {
+    if( states.isEmpty() )
+    { // Shouldn't ever happen, but it has
+      IState s = new EvalState(this);
+      states.push(s);
+      Trace.DEBUG.trace("Repl is in state: " + String.valueOf(s));
+    }
+    return states.peek();
+
+  }
+
+  protected abstract void applyState(IState s);
+  protected void eval(String cmd)
+  {
+    IState state = currState();
+
+    if( state.handle(cmd) )
+    {
+      popState();
+    }
+  }
+
+  public void dispose()
+  {
+    swank.removeListener(debugInfoRunnable);
+    swank.removeListener(debugRunnable);
+    swank.removeListener(disconnectRunnable);
+    swank.removeListener(readRunnable);
+    swank.removeListener(debugStopRunnable);
+    swank.removeListener(writeStringRunnable);
+    swank.removeListener(presentationRunnable);
+  }
+
+}

File org.lispdev.repl/src/org/lispdev/repl/DebugState.java

+package org.lispdev.repl;
+
+import org.lispdev.swank.runnables.SwankDebugRunnable.DebugInfo;
+
+public class DebugState implements IState
+{
+  private final AbstractRepl repl;
+  private final DebugInfo debugInfo;
+
+  public DebugState(AbstractRepl r, DebugInfo debugInfo)
+  {
+    repl = r;
+    this.debugInfo = debugInfo;
+  }
+
+  @Override
+  public boolean equals(Object obj)
+  {
+    if( obj instanceof DebugState )
+    {
+      DebugState state = (DebugState)obj;
+      return state.debugInfo.equals(debugInfo);
+    }
+    return false;
+  }
+
+  @Override
+  public void activate()
+  {
+    repl.startDebug(debugInfo);
+  }
+
+  public void deactivate()
+  {
+    repl.debugStoped();
+  }
+
+  @Override
+  public boolean handle(String command)
+  {
+    return false;
+  }
+
+  @Override
+  public String toString()
+  {
+    return "DebugState:"+ String.valueOf(debugInfo);
+  }
+}

File org.lispdev.repl/src/org/lispdev/repl/EvalState.java

+package org.lispdev.repl;
+
+import org.lispdev.log.Log;
+import org.lispdev.log.Trace;
+
+public class EvalState implements IState
+{
+  private final AbstractRepl repl;
+
+  public EvalState(AbstractRepl r)
+  {
+    repl = r;
+  }
+
+  @Override
+  public void activate()
+  {
+  }
+
+  @Override
+  public boolean handle(String command)
+  {
+    Trace.DEBUG.trace("EvalStateHandle:"+command);
+    repl.saveCommandToHistory(command);
+    if( !repl.swank.isConnected() )
+    {
+      repl.connecting();
+      repl.swank.connect();
+      if( !repl.swank.isConnected() )
+      {
+        return false;
+      }
+      repl.packageChanged(repl.swank.getCurrPackage());
+      repl.connected();
+    }
+    final String cleanCommand = command.trim().replace("\r", "");
+    if( cleanCommand.toLowerCase().startsWith("(in-package ") )
+    {
+      int i0 = cleanCommand.indexOf(':');
+      int i1 = cleanCommand.indexOf(')');
+      if( i0 < 0 || i1 < 0 )
+      {
+        Log.logWarning("Bad format of in-package: " + cleanCommand);
+      }
+      else
+      {
+        final String pkg = cleanCommand.substring(i0+1, i1).trim().toUpperCase();
+        repl.swank.setPackage(pkg);
+        repl.packageChanged(pkg);
+      }
+    }
+    else if( cleanCommand.toLowerCase().matches("\\(\\s*quit\\s*\\)\\s*") )
+    {
+      repl.disconnecting();
+    }
+    repl.swank.sendEval(cleanCommand,
+        new EvalStateRunnable(repl,repl.swank.getLispImplementation()));
+
+    return false;
+  }
+
+  @Override
+  public String toString()
+  {
+    return "EvalState";
+  }
+}

File org.lispdev.repl/src/org/lispdev/repl/EvalStateRunnable.java

+package org.lispdev.repl;
+
+import org.lispdev.swank.LispImplementation;
+import org.lispdev.swank.runnables.SwankRunnable;
+
+public class EvalStateRunnable extends SwankRunnable
+{
+  private final AbstractRepl repl;
+
+  public EvalStateRunnable(AbstractRepl r, LispImplementation implementation)
+  {
+    super(implementation);
+    repl = r;
+  }
+
+  @Override
+  public void run()
+  {
+    repl.doInput();
+  }
+
+  @Override
+  public Object getInfo()
+  {
+    return null;
+  }
+}

File org.lispdev.repl/src/org/lispdev/repl/IState.java

+package org.lispdev.repl;
+
+/**
+ * Class that represents state of the REPL.
+ */
+public interface IState
+{
+  /**
+   * @param command to be evaluated
+   * @return true if REPL gets to the previous state after handling
+   */
+  boolean handle(String command);
+
+  void activate();
+}

File org.lispdev.repl/src/org/lispdev/repl/ReadState.java

+package org.lispdev.repl;
+
+import org.lispdev.swank.runnables.SwankReadStringRunnable.ReadStringInfo;
+
+public class ReadState implements IState
+{
+  private final AbstractRepl repl;
+  private final ReadStringInfo info;
+
+  public ReadState(AbstractRepl r, ReadStringInfo info)
+  {
+    repl = r;
+    this.info = info;
+  }
+
+  @Override
+  public void activate()
+  {
+  }
+
+  @Override
+  public boolean handle(String command)
+  {
+    repl.swank.sendReadString(command, info);
+
+    return true;
+  }
+
+  @Override
+  public String toString()
+  {
+    return "ReadState";
+  }
+}

File org.lispdev.repl/src/org/lispdev/repl/ReplPlugin.java

+package org.lispdev.repl;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ReplPlugin extends AbstractUIPlugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.lispdev.repl";
+
+	// The shared instance
+	private static ReplPlugin plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public ReplPlugin() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+		super.stop(context);
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static ReplPlugin getDefault() {
+		return plugin;
+	}
+
+}

File org.lispdev.repl/src/org/lispdev/repl/SwankRunnableDriver.java

+package org.lispdev.repl;
+
+import org.eclipse.swt.widgets.Display;
+import org.lispdev.swank.IRunnableDriver;
+
+public class SwankRunnableDriver implements IRunnableDriver
+{
+
+  @Override
+  public void asyncExec(Runnable r)
+  {
+    Display.getDefault().asyncExec(r);
+  }
+
+}

File src/org/lispdev/repl/AbstractRepl.java

-package org.lispdev.repl;
-
-import java.util.Hashtable;
-import java.util.Stack;
-
-import org.lispdev.log.Trace;
-import org.lispdev.swank.ISwank;
-import org.lispdev.swank.runnables.SwankDebugActivateRunnable;
-import org.lispdev.swank.runnables.SwankDebugReturnRunnable;
-import org.lispdev.swank.runnables.SwankDebugRunnable;
-import org.lispdev.swank.runnables.SwankDebugRunnable.DebugInfo;
-import org.lispdev.swank.runnables.SwankDisconnectRunnable;
-import org.lispdev.swank.runnables.SwankPresentationRunnable;
-import org.lispdev.swank.runnables.SwankReadStringRunnable;
-import org.lispdev.swank.runnables.SwankWriteStringRunnable;
-
-/**
- * Repl is a bridge between swank server events and user interface.
- */
-public abstract class AbstractRepl
-{
-  private final Stack<IState> states = new Stack<IState>();
-
-  public final ISwank swank;
-
-  private class DisconnectRunnable extends SwankDisconnectRunnable
-  {
-    private final AbstractRepl repl;
-
-    public DisconnectRunnable(AbstractRepl r)
-    {
-      super(swank.getLispImplementation());
-      repl = r;
-    }
-
-    @Override
-    public void run()
-    {
-      repl.disconnected();
-    }
-  }
-
-  private class ReadRunnable extends SwankReadStringRunnable
-  {
-    private final AbstractRepl repl;
-
-    public ReadRunnable(AbstractRepl r)
-    {
-      super(swank.getLispImplementation());
-      repl = r;
-    }
-
-    @Override
-    public void run()
-    {
-      ReadStringInfo info = getInfo();
-      repl.pushState(new ReadState(repl, info));
-    }
-  }
-
-  private final Hashtable<String, DebugInfo> debugInfos =
-    new Hashtable<String, DebugInfo>();
-
-  private class DebugInfoRunnable extends SwankDebugRunnable
-  {
-    public DebugInfoRunnable()
-    {
-      super(swank.getLispImplementation());
-    }
-
-    @Override
-    public void run()
-    {
-      Trace.DEBUG.trace("DebugInfoRunnable: "+ getInfo().toString());
-      debugInfos.put(getKey(), getInfo());
-    }
-  }
-
-  private class DebugRunnable extends SwankDebugActivateRunnable
-  {
-    private final AbstractRepl repl;
-
-    public DebugRunnable(AbstractRepl r)
-    {
-      super(swank.getLispImplementation());
-      repl = r;
-    }
-
-    @Override
-    public void run()
-    {
-      String key = getKey();
-      Trace.DEBUG.trace("*debug found: " + key + "->" + debugInfos.get(key));
-      DebugState state = new DebugState(repl, debugInfos.get(key));
-      Trace.DEBUG.trace("currState:" + currState());
-      if( !currState().equals(state) )
-      {
-        pushState(state);
-      }
-    }
-  }
-
-  private class DebugStopRunnable extends SwankDebugReturnRunnable
-  {
-    private final AbstractRepl repl;
-
-    public DebugStopRunnable(AbstractRepl r)
-    {
-      super(swank.getLispImplementation());
-      repl = r;
-    }
-
-    @Override
-    public void run()
-    {
-      String key = getKey();
-      Trace.DEBUG.trace("*debug found: " + key + "->" + debugInfos.get(key));
-      DebugState state = new DebugState(repl, debugInfos.get(key));
-      Trace.DEBUG.trace("currState:" + currState());
-      if( currState().equals(state) )
-      {
-        popState();
-      }
-    }
-  }
-
-  private class PresentationRunnable extends SwankPresentationRunnable
-  {
-    private final AbstractRepl repl;
-
-    public PresentationRunnable(AbstractRepl r)
-    {
-      super(swank.getLispImplementation());
-      repl = r;
-    }
-
-    @Override
-    public void run()
-    {
-      PresentationInfo info = getInfo();
-      repl.appendOutInspectable(info.text, info.id);
-    }
-  }
-
-  private class WriteStringRunnable extends SwankWriteStringRunnable
-  {
-    private final AbstractRepl repl;
-
-    public WriteStringRunnable(AbstractRepl r)
-    {
-      super(swank.getLispImplementation());
-      repl = r;
-    }
-
-    @Override
-    public void run()
-    {
-      WriteStringInfo info = getInfo();
-      repl.appendOut(info.text);
-    }
-
-  }
-
-  private final WriteStringRunnable writeStringRunnable;
-  private final PresentationRunnable presentationRunnable;
-  private final ReadRunnable readRunnable;
-  private final DisconnectRunnable disconnectRunnable;
-  private final DebugInfoRunnable debugInfoRunnable;
-  private final DebugRunnable debugRunnable;
-  private final DebugStopRunnable debugStopRunnable;
-
-  public AbstractRepl(ISwank s)
-  {
-    swank = s;
-    readRunnable = new ReadRunnable(this);
-    disconnectRunnable = new DisconnectRunnable(this);
-    debugInfoRunnable = new DebugInfoRunnable();
-    debugRunnable = new DebugRunnable(this);
-    debugStopRunnable = new DebugStopRunnable(this);
-    writeStringRunnable = new WriteStringRunnable(this);
-    presentationRunnable = new PresentationRunnable(this);
-
-    pushState(new EvalState(this));
-    swank.addPresentationListener(presentationRunnable);
-    swank.addWriteStringListener(writeStringRunnable);
-    swank.addReadStringListener(readRunnable);
-    swank.addDisconnectListener(disconnectRunnable);
-    swank.addDebugListener(debugInfoRunnable);
-    swank.addDebugActivateListener(debugRunnable);
-    swank.addDebugReturnListener(debugStopRunnable);
-  }
-
-  public abstract void appendOut(String text);
-  public abstract void appendOutInspectable(String text, String id);
-  public abstract void packageChanged(String command);
-  public abstract void saveCommandToHistory(String command);
-  /**
-   * repl suspended to let user perform input - might need to know state
-   */
-  public abstract void doInput();
-  public abstract void disconnected();
-  public abstract void disconnecting();
-  public abstract void connected();
-  public abstract void connecting();
-  public abstract void startDebug(DebugInfo debugInfo);
-  public abstract void debugStoped();
-
-  private void pushState(IState s)
-  {
-    if( states.size() > 1 )
-    {
-      // Assuming anything above one is a debug state?
-      if( currState() instanceof DebugState )
-      {
-        ((DebugState)currState()).deactivate();
-      }
-    }
-    states.push(s);
-    Trace.DEBUG.trace("Repl is in state: " + String.valueOf(s));
-    s.activate();
-    applyState(s);
-  }
-
-  private void popState()
-  {
-    IState s = states.pop();
-    Trace.DEBUG.trace("Repl is in state: " + String.valueOf(s));
-    if( s instanceof DebugState )
-    {
-      ((DebugState)s).deactivate();
-    }
-    currState().activate();
-    applyState(currState());
-  }
-
-  protected IState currState()
-  {
-    if( states.isEmpty() )
-    { // Shouldn't ever happen, but it has
-      IState s = new EvalState(this);
-      states.push(s);
-      Trace.DEBUG.trace("Repl is in state: " + String.valueOf(s));
-    }
-    return states.peek();
-
-  }
-
-  protected abstract void applyState(IState s);
-  protected void eval(String cmd)
-  {
-    IState state = currState();
-
-    if( state.handle(cmd) )
-    {
-      popState();
-    }
-  }
-
-  public void dispose()
-  {
-    swank.removeListener(debugInfoRunnable);
-    swank.removeListener(debugRunnable);
-    swank.removeListener(disconnectRunnable);
-    swank.removeListener(readRunnable);
-    swank.removeListener(debugStopRunnable);
-    swank.removeListener(writeStringRunnable);
-    swank.removeListener(presentationRunnable);
-  }
-
-}

File src/org/lispdev/repl/DebugState.java

-package org.lispdev.repl;
-
-import org.lispdev.swank.runnables.SwankDebugRunnable.DebugInfo;
-
-public class DebugState implements IState
-{
-  private final AbstractRepl repl;
-  private final DebugInfo debugInfo;
-
-  public DebugState(AbstractRepl r, DebugInfo debugInfo)
-  {
-    repl = r;
-    this.debugInfo = debugInfo;
-  }
-
-  @Override
-  public boolean equals(Object obj)
-  {
-    if( obj instanceof DebugState )
-    {
-      DebugState state = (DebugState)obj;
-      return state.debugInfo.equals(debugInfo);
-    }
-    return false;
-  }
-
-  @Override
-  public void activate()
-  {
-    repl.startDebug(debugInfo);
-  }
-
-  public void deactivate()
-  {
-    repl.debugStoped();
-  }
-
-  @Override
-  public boolean handle(String command)
-  {
-    return false;
-  }
-
-  @Override
-  public String toString()
-  {
-    return "DebugState:"+ String.valueOf(debugInfo);
-  }
-}

File src/org/lispdev/repl/EvalState.java

-package org.lispdev.repl;
-
-import org.lispdev.log.Log;
-import org.lispdev.log.Trace;
-
-public class EvalState implements IState
-{
-  private final AbstractRepl repl;
-
-  public EvalState(AbstractRepl r)
-  {
-    repl = r;
-  }
-
-  @Override
-  public void activate()
-  {
-  }
-
-  @Override
-  public boolean handle(String command)
-  {
-    Trace.DEBUG.trace("EvalStateHandle:"+command);
-    repl.saveCommandToHistory(command);
-    if( !repl.swank.isConnected() )
-    {
-      repl.connecting();
-      repl.swank.connect();
-      if( !repl.swank.isConnected() )
-      {
-        return false;
-      }
-      repl.packageChanged(repl.swank.getCurrPackage());
-      repl.connected();
-    }
-    final String cleanCommand = command.trim().replace("\r", "");
-    if( cleanCommand.toLowerCase().startsWith("(in-package ") )
-    {
-      int i0 = cleanCommand.indexOf(':');
-      int i1 = cleanCommand.indexOf(')');
-      if( i0 < 0 || i1 < 0 )
-      {
-        Log.logWarning("Bad format of in-package: " + cleanCommand);
-      }
-      else
-      {
-        final String pkg = cleanCommand.substring(i0+1, i1).trim().toUpperCase();
-        repl.swank.setPackage(pkg);
-        repl.packageChanged(pkg);
-      }
-    }
-    else if( cleanCommand.toLowerCase().matches("\\(\\s*quit\\s*\\)\\s*") )
-    {
-      repl.disconnecting();
-    }
-    repl.swank.sendEval(cleanCommand,
-        new EvalStateRunnable(repl,repl.swank.getLispImplementation()));
-
-    return false;
-  }
-
-  @Override
-  public String toString()
-  {
-    return "EvalState";
-  }
-}

File src/org/lispdev/repl/EvalStateRunnable.java

-package org.lispdev.repl;
-
-import org.lispdev.swank.LispImplementation;
-import org.lispdev.swank.runnables.SwankRunnable;
-
-public class EvalStateRunnable extends SwankRunnable
-{
-  private final AbstractRepl repl;
-
-  public EvalStateRunnable(AbstractRepl r, LispImplementation implementation)
-  {
-    super(implementation);
-    repl = r;
-  }
-
-  @Override
-  public void run()
-  {
-    repl.doInput();
-  }
-
-  @Override
-  public Object getInfo()
-  {
-    return null;
-  }
-}

File src/org/lispdev/repl/IState.java

-package org.lispdev.repl;
-
-/**
- * Class that represents state of the REPL.
- */
-public interface IState
-{
-  /**
-   * @param command to be evaluated
-   * @return true if REPL gets to the previous state after handling
-   */
-  boolean handle(String command);
-
-  void activate();
-}

File src/org/lispdev/repl/ReadState.java

-package org.lispdev.repl;
-
-import org.lispdev.swank.runnables.SwankReadStringRunnable.ReadStringInfo;
-
-public class ReadState implements IState
-{
-  private final AbstractRepl repl;
-  private final ReadStringInfo info;
-
-  public ReadState(AbstractRepl r, ReadStringInfo info)
-  {
-    repl = r;
-    this.info = info;
-  }
-
-  @Override
-  public void activate()
-  {
-  }
-
-  @Override
-  public boolean handle(String command)
-  {
-    repl.swank.sendReadString(command, info);
-
-    return true;
-  }
-
-  @Override
-  public String toString()
-  {
-    return "ReadState";
-  }
-}

File src/org/lispdev/repl/ReplPlugin.java

-package org.lispdev.repl;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class ReplPlugin extends AbstractUIPlugin {
-
-	// The plug-in ID
-	public static final String PLUGIN_ID = "org.lispdev.repl";
-
-	// The shared instance
-	private static ReplPlugin plugin;
-	
-	/**
-	 * The constructor
-	 */
-	public ReplPlugin() {
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
-	 */
-	public void start(BundleContext context) throws Exception {
-		super.start(context);
-		plugin = this;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
-	 */
-	public void stop(BundleContext context) throws Exception {
-		plugin = null;
-		super.stop(context);
-	}
-
-	/**
-	 * Returns the shared instance
-	 *
-	 * @return the shared instance
-	 */
-	public static ReplPlugin getDefault() {
-		return plugin;
-	}
-
-}

File src/org/lispdev/repl/SwankRunnableDriver.java

-package org.lispdev.repl;
-
-import org.eclipse.swt.widgets.Display;
-import org.lispdev.swank.IRunnableDriver;
-
-public class SwankRunnableDriver implements IRunnableDriver
-{
-
-  @Override
-  public void asyncExec(Runnable r)
-  {
-    Display.getDefault().asyncExec(r);
-  }
-
-}