Commits

Anonymous committed a99eb03

Refactoring swank to start it with launchers.

  • Participants
  • Parent commits 7f1ef24

Comments (0)

Files changed (6)

File META-INF/MANIFEST.MF

 Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Swank
-Bundle-SymbolicName: org.lispdev.swank
+Bundle-SymbolicName: org.lispdev.swank;singleton:=true
 Bundle-Version: 1.0.0.qualifier
 Bundle-Activator: org.lispdev.swank.SwankPlugin
 Require-Bundle: org.eclipse.core.runtime,
  org.junit4;bundle-version="4.5.0",
- org.lispdev.log;bundle-version="1.0.0"
+ org.lispdev.log;bundle-version="1.0.0",
+ org.eclipse.debug.core;bundle-version="3.5.1"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Export-Package: org.lispdev.swank

File build.properties

 source.. = src/
 output.. = bin/
 bin.includes = META-INF/,\
-               .
+               .,\
+               plugin.xml
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+   <extension
+         point="org.eclipse.debug.core.launchConfigurationTypes">
+      <launchConfigurationType
+            delegate="org.lispdev.swank.BaseLocalLispLaunchDelegate"
+            id="org.lispdev.swank.baseLocalLaunchConfigurationType"
+            modes="debug"
+            name="Local Lisp"
+            public="true">
+      </launchConfigurationType>
+   </extension>
+
+</plugin>

File src/org/lispdev/swank/BaseLocalLispLaunchDelegate.java

+package org.lispdev.swank;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+
+public class BaseLocalLispLaunchDelegate extends LaunchConfigurationDelegate
+{
+  public final static String ID =
+    "org.lispdev.replview.localLaunchConfigurationType";
+  public final static String ATTR_EXE = "path-to-executable-string";
+  public final static String ATTR_CMD_PARAMS = "command-line-params-list";
+  public final static String ATTR_ENV = "environment-variables-map";
+  public final static String ATTR_PORT = "port-int";
+  public final static String ATTR_EXT = "lisp-extensions-path-string";
+  //for now to folder containing lisp-extensions folder: see basicStartup
+  //function in SwankInterface
+
+
+
+  @Override
+  public void launch(ILaunchConfiguration configuration, String mode,
+      ILaunch launch, IProgressMonitor monitor) throws CoreException
+  {
+  // TODO Auto-generated method stub
+
+  }
+
+}

File src/org/lispdev/swank/SwankInterface.java

  */
 public class SwankInterface implements ISwank
 {
+  public SwankInterface(String extDir, int port, LispImplementation implem)
+  {
+    this.extDir = extDir;
+    this.port = port;
+    this.implem = implem;
+  }
 
-  public SwankInterface()
-  {}
+  private final int port;
+  protected SwankInterfaceCore swank;
+  protected final String extDir;
+  protected final LispImplementation implem;
 
-  protected SwankInterfaceCore swank;
-
-  protected String pluginDir;
-
-  public void initParams(IRunnableDriver r, String pluginDir,
-      LispImplementation implementation)
+  public void initParams(IRunnableDriver r)
   {
-    this.pluginDir = pluginDir;
-    swank = new SwankInterfaceCore(r, implementation, 4005);
+    swank = new SwankInterfaceCore(r, implem, port);
     // initIndents();
   }
 
   public void connect()
   {
-    if( swank != null && !swank.isConnected() && pluginDir != null
-        && pluginDir != "")
+    if( swank != null && !swank.isConnected() && extDir != null
+        && extDir != "")
     {
       swank.connect();
       runAfterConnect();
     useUnitTest = false;
     // prefs.getBoolean(PreferenceConstants.USE_UNIT_TEST);
     String strIni = "";// prefs.getString(PreferenceConstants.LISP_INI);
-    basicStartup(useUnitTest, strIni, pluginDir);
+    basicStartup(useUnitTest, strIni, extDir);
     startupLib();
     if( swank.isConnected() )
     {

File src/org/lispdev/swank/SwankInterfaceTest.java

 
 public class SwankInterfaceTest extends SwankInterface
 {
+  private static final String dir =
+    "D:\\projects\\lispdev\\ws\\org.lispdev.swank\\";
+
+  public SwankInterfaceTest()
+  {
+    super(dir,4005,SBCLImplementation.findImplementation(dir));
+  }
+
   // class for synchronization
   private class myBoolean
   {
   {
     if( !isConnected() )
     {
-      String dir = "D:\\projects\\lispdev\\ws\\org.lispdev.swank\\";
-      initParams(new TestRunnableDriver(), dir,
-          SBCLImplementation.findImplementation(dir));
+      initParams(new TestRunnableDriver());
       connect();
     }
   }
       synchronized(callBack)
       {
         sendCompileString("(defun g (x)\n  (z x))\n\n(defun z (x)\n  (y x))\n",
-            "test.lisp", pluginDir, 0, "nil", callBack);
+            "test.lisp", extDir, 0, "nil", callBack);
         callBack.wait(1000);
       } // sync
     }
         {
           synchronized(callBack)
           {
-            sendCompileString("(g 3)\n", "test.lisp", pluginDir, 40, "nil",
+            sendCompileString("(g 3)\n", "test.lisp", extDir, 40, "nil",
                 callBack);
             callBack.wait(1000);
           } // sync
       synchronized(callBack)
       {
         sendCompileString("(defun f (x)\n  (+ 2 (g x)))\n", "test.lisp",
-            pluginDir, 0, "nil", callBack);
+            extDir, 0, "nil", callBack);
         callBack.wait(1000);
       } // sync
     }
         {
           synchronized(callBack)
           {
-            sendCompileString("(f 4)\n", "test.lisp", pluginDir, 25, "nil",
+            sendCompileString("(f 4)\n", "test.lisp", extDir, 25, "nil",
                 callBack);
             callBack.wait(1000);
           } // sync
     return callBack.getReturn().getf(":swank-compilation-unit")
       .getf(":message").value.equals("undefined function: G")
       && callBack.getReturn().getf(":swank-compilation-unit")
-          .toString().contains(pluginDir + "test.lisp") ;
+          .toString().contains(extDir + "test.lisp") ;
   }
 
   // run it to find out which buffer to use in previous test
     {
       synchronized(callBack)
       {
-        sendCompileString("(defun g (x)\n  (+ 2 x))\n", "test.lisp", pluginDir,
+        sendCompileString("(defun g (x)\n  (+ 2 x))\n", "test.lisp", extDir,
             0, "nil", callBack);
         callBack.wait(1000);
       } // sync
       synchronized(callBack)
       {
         sendCompileString("(defun f (x)\n  (+ 2 (g x)))\n", "test.lisp",
-            pluginDir, 25, "nil", callBack);
+            extDir, 25, "nil", callBack);
         callBack.wait(1000);
       } // sync
     }
     } // catch
 
     assertEquals("G", callBack.getReturn().get(0).get(0).value);
-    assertEquals(pluginDir + "test.lisp", callBack.getReturn().get(0).get(1)
+    assertEquals(extDir + "test.lisp", callBack.getReturn().get(0).get(1)
       .getf(":location").getf(":buffer").value);
     assertEquals("1",
         callBack.getReturn().get(0).get(1).getf(":position").value);
     // was not able to finish in time alloted (see callBack.wait() after
     // sendGetCallers()
     assertEquals("F", callBack.getReturn().get(0).get(0).value);
-    assertEquals(pluginDir + "test.lisp", callBack.getReturn().get(0).get(1)
+    assertEquals(extDir + "test.lisp", callBack.getReturn().get(0).get(1)
       .getf(":location").getf(":buffer").value);
     assertEquals("26",
         callBack.getReturn().get(0).get(1).getf(":position").value);
     {
       synchronized(callBack)
       {
-        sendCompileString("(defun g (x)\n  (+ 2 x))", "test.lisp", pluginDir,
+        sendCompileString("(defun g (x)\n  (+ 2 x))", "test.lisp", extDir,
             0, "nil", callBack);
         callBack.wait(1000);
       } // sync
     } // catch
 
     assertEquals("(DEFUN G)", callBack.getReturn().get(0).get(0).value);
-    assertEquals(pluginDir + "test.lisp", callBack.getReturn().get(0).get(1)
+    assertEquals(extDir + "test.lisp", callBack.getReturn().get(0).get(1)
       .getf(":location").getf(":buffer").value);
     assertEquals("1",
         callBack.getReturn().get(0).get(1).getf(":position").value);
     {
       synchronized(callBack)
       {
-        sendCompileString("(defun g (x)\n  (+ 1 x))", "test.lisp", pluginDir,
+        sendCompileString("(defun g (x)\n  (+ 1 x))", "test.lisp", extDir,
             0, "nil", callBack);
         callBack.wait(1000);
       } // sync
     {
       synchronized(callBack)
       {
-        sendCompileString("(defun g (x)\n  (+ 1 x))", "test.lisp", pluginDir,
+        sendCompileString("(defun g (x)\n  (+ 1 x))", "test.lisp", extDir,
             0, "nil", callBack);
         callBack.wait(1000);
       } // sync
     {
       synchronized(callBack)
       {
-        sendCompileFile(pluginDir + "test.lisp", callBack);
+        sendCompileFile(extDir + "test.lisp", callBack);
         callBack.wait(1000);
       } // sync
     }
   @Test
   public void test_basicStartup()
   {
-    String res = basicStartup(false, null, pluginDir);
+    String res = basicStartup(false, null, extDir);
     assertEquals(true,res.startsWith("\"You are running SBCL 1.0."));
   }
 
   @Test
   public void test_haveDefinitions()
   {
-    init();
     // SK: on my system (WinXP, sbcl), I don't have SBCL sources, so
     // res = false. It might be true with SBCL sources.
     boolean res = haveDefinitions("*query-io*", ":wiz", 2000);