Commits

sk  committed 14aa66e

- Removed unused code in swank interface.
- Made all tests in swank interface to pass.

  • Participants
  • Parent commits bcc02e3

Comments (0)

Files changed (2)

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

   public void setLispVersion(String version)
   {
     lispVersion = version;
-    // LispPlugin.getDefault().updateReplStatusLine("CL:"+lispVersion
-    // +"| Cusp: "+LispPlugin.getVersion()
-    // +"| Current package: " + getPackage());
-  }
-
-  // SK: note, MANAGE_PACKAGES and USE_UNIT_TEST preferences should be
-  // accessed only through SwankInterface.getManagePackages and
-  // swankInterface.getUnitTest - because their value only have importance
-  // when lisp starts
-  private boolean managePackages = false;
-  private boolean useUnitTest = false;
-
-  public boolean getManagePackages()
-  {
-    return managePackages;
-  }
-
-  public boolean getUseUnitTest()
-  {
-    return useUnitTest;
   }
 
   public synchronized void registerLibPath(String path)
     sendEvalAndGrab(code, 1000);
   }
 
-  protected String basicStartup(boolean useUnitTest, String strIni,
-      String pluginPath)
-  {
-    if( swank.isConnected() )
-    {
-//      String startupCode =
-//          "(progn (swank:swank-require :swank-fuzzy)\n"
-//              + "(swank:swank-require :swank-asdf)\n"
-//              + "(swank:swank-require :swank-presentations)\n"
-//              + "(swank:swank-require :swank-fancy-inspector)\n"
-//              + "(swank:swank-require :swank-arglists)\n"
-//              + "(swank:swank-require :swank-presentations)\n";
-//      // + BreakpointAction.macro +"\n"+ WatchAction.macro+"\n";
-//
-//      final String plPath = (pluginPath+"/").replace("\\\\", "/").replace("\\", "/").replace("//","/");
-//      String asdfext = plPath + "lisp-extensions/asdf-extensions.lisp";
-//      startupCode += "(load \"" + asdfext + "\")\n";
-//
-//      if( useUnitTest )
-//      {
-//        startupCode +=
-//            "(load \"" + plPath + "lisp-extensions/lisp-unit.lisp"
-//                + "\")\n";
-//      }
-//      if( strIni != null && strIni != "" )
-//      {
-//        strIni = strIni.replaceAll("\\\\", "/");
-//        startupCode +=
-//            "(when (probe-file \"" + strIni + "\") (load \"" + strIni
-//                + "\"))\n";
-//      }
-//
-//      startupCode +=
-//          "(format nil \"You are running ~a ~a via LispDev Swank "
-//              // + LispPlugin.getVersion()
-//              + "\" (lisp-implementation-type) (lisp-implementation-version))"
-//              + ")";
-    String startupCode =
-    "(format nil \"You are running ~a ~a via LispDev Swank "
-        + "\" (lisp-implementation-type) (lisp-implementation-version))";
-
-      return sendEvalAndGrab(startupCode, 1000);
-      // sendEval("(swank:fancy-inspector-init)", null);
-    }
-    else
-    {
-      return null;
-    }
-  }
-
-  private String startupLib()
-  {
-    // if( isConnected() )
-    // {
-    // final String code = LispPlugin.getDefault().getLibsPathRegisterCode();
-    // if( !code.equals("")){
-    // return sendEvalAndGrab(code,1000);
-    // }
-    // else
-    // {
-    // return null;
-    // }
-    // }
-    return null;
-  }
-
   protected void runAfterConnect()
   {
-    // IPreferenceStore prefs =
-    // LispPlugin.getDefault().getPreferenceStore();
-    managePackages = false;
-    // prefs.getBoolean(PreferenceConstants.MANAGE_PACKAGES);
-    useUnitTest = false;
-    // prefs.getBoolean(PreferenceConstants.USE_UNIT_TEST);
-    String strIni = "";// prefs.getString(PreferenceConstants.LISP_INI);
-    basicStartup(useUnitTest, strIni, extDir);
-    startupLib();
     if( swank.isConnected() )
     {
       LispNode info =
     return res;
   }
 
-  public synchronized ArrayList<String> getPackagesWithTests(long timeout)
-  {
-    if( useUnitTest )
-    {
-      java.util.ArrayList<String> packageNames =
-          new java.util.ArrayList<String>();
-
-      String res =
-          sendEvalAndGrab(
-              "(let ((res '())) (dolist (pkg (swank:list-all-package-names t) res)"
-                  + "(if (lisp-unit:get-tests pkg) (push pkg res))))",
-              "COMMON-LISP-USER", timeout);
-      LispNode resnode = LispParser.parse(res).get(0);
-      for(LispNode p : resnode.getParams())
-      {
-        packageNames.add(p.value);
-      }
-      return packageNames;
-    }
-    else
-    {
-      return null;
-    }
-  }
-
-  public synchronized void sendGetInstalledPackages(SwankRunnable callBack)
-  {
-    if( managePackages )
-    {
-      String msg =
-          "(swank:eval-and-grab-output \""
-              + SwankInterfaceCore.formatCode("(get-installed-packages)")
-              + "\")";
-      swank.sendEvalRaw(msg, "com.gigamonkeys.asdf-extensions", callBack);
-    }
-    else
-    {
-      callBack.result = null;
-      callBack.run();
-    }
-  }
-
-  public synchronized LispNode getInstalledPackages(long timeout)
-  {
-    if( managePackages )
-    {
-      String res =
-          sendEvalAndGrab("(get-installed-packages)",
-              "com.gigamonkeys.asdf-extensions", timeout);
-      LispNode resnode = LispParser.parse(res);
-      return resnode;
-    }
-    else
-    {
-      return null;
-    }
-  }
-
   public synchronized void sendGetCallers(String functionName, String pkg,
       SwankRunnable callBack)
   {

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

   @Test
   public void test_sendEval()
   {
+    final String[] res = new String[2];
+    final SwankRunnable writeListener = new SwankRunnable(){
+      @Override
+      public void run()
+      {
+        for( int i = 0; i < res.length; ++i )
+        {
+          if( res[i] == null )
+          {
+            res[i] = result.getf(":write-string").value;
+            break;
+          }
+        }
+      }
+    };
+    si.swank.addListener(SwankEvent.WRITE_STRING, writeListener);
     final SwankRunnable callBack = new SwankRunnable(){
       @Override
       public void run()
       e.printStackTrace();
     } // catch
 
-    assertEquals("4", callBack.result.get(2).value);
+    si.swank.removeListener(writeListener);
 
+    assertEquals("4", res[0]);
   }
 
     /*
     si.swank.removeListener(debugInfo);
     assertEquals(true, String.valueOf(debugStart.result)
         .startsWith("(`:debug-activate` "));
-    assertEquals("(`:return` (`:abort` ) `3` )", String
-      .valueOf(callBack.result));
+    assertEquals(String.valueOf(callBack.result).
+        startsWith("(`:return` (`:abort` ) `"), true);
   }
 
     /*
     si.swank.removeListener(debugStop);
     assertEquals(true, String.valueOf(debugStart.result)
         .startsWith("(`:debug-activate` "));
-    assertEquals("(`:return` (`:abort` ) `3` )", String
-      .valueOf(callBack.result));
+    assertEquals(String.valueOf(callBack.result).
+        startsWith("(`:return` (`:abort` ) `"), true);
     assertEquals(true, String.valueOf(debugStop.result)
         .startsWith("(`:debug-return` "));
   }
       .valueOf(callBack.result.get(4).get(1)));
   }
 
-  /*
-  >>> Found default sbcl folder: /home/sk/cusp/ws/org.lispdev.swank/sbcl
-  >>> Found default sbcl folder: /home/sk/cusp/ws/org.lispdev.swank/sbcl
-  ----------------implementation:SBCL
-  ----------------slimePath:/home/sk/cusp/ws/org.lispdev.swank/slime/swank-loader.lisp
-  start
-  ----------------lispEngine:java.lang.UNIXProcess@a6d51e
-  ----------------retries:1
-  ]This is SBCL 1.0.20, an implementation of ANSI Common Lisp.]More information about SBCL is available at <http://www.sbcl.org/>.]]SBCL is free software, provided as is, with absolutely no warranty.]It is mostly in the public domain; some portions are provided under]BSD-style licenses.  See the CREDITS and COPYING files in the]distribution for more information.]* ]T]* ]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/swank-backend.fasl"]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/swank-source-path-parser.fasl"]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/swank-source-file-cache.fasl"]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/swank-sbcl.fasl"]STYLE-WARNING: redefining EMACS-INSPECT (#<BUILT-IN-CLASS T>) in DEFMETHOD]STYLE-WARNING: redefining SB-THREAD::GET-FOREGROUND in DEFUN]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/swank-gray.fasl"]STYLE-WARNING:]   Implicitly creating new generic function STREAM-READ-CHAR-WILL-HANG-P.]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/swank.fasl"]WARNING: These Swank interfaces are unimplemented:] (CALLS-WHO DISASSEMBLE-FRAME SLDB-BREAK-AT-START SLDB-BREAK-ON-RETURN]            WHO-SPECIALIZES)]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/contrib/swank-c-p-c.fasl"]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/contrib/swank-arglists.fasl"]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/contrib/swank-fuzzy.fasl"]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/contrib/swank-fancy-inspector.fasl"]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/contrib/swank-presentations.fasl"]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/contrib/swank-presentation-streams.fasl"]WARNING: change in instance length of class PRETTY-STREAM:]  current length: 25]  new length: 27]STYLE-WARNING: redefining MAKE-PRETTY-STREAM in DEFUN]STYLE-WARNING: redefining MAYBE-OUTPUT in DEFUN]STYLE-WARNING: redefining OUTPUT-LINE in DEFUN]STYLE-WARNING: redefining OUTPUT-PARTIAL-LINE in DEFUN]STYLE-WARNING: redefining FORCE-PRETTY-OUTPUT in DEFUN]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/contrib/swank-asdf.fasl"]; loading #P"/home/sk/.slime/fasl/2008-08-14/sbcl-1.0.20-linux-x86/contrib/swank-package-fu.fasl"]NIL;; SWANK: sb-thread::get-foreground ...];; Swank started at port: 4005.]* ]4005;; SWANK: sb-thread::get-foreground ...----------------connected
-  -->(:emacs-rex (swank:eval-and-grab-output "(progn (swank:swank-require :swank-fuzzy)
-  (swank:swank-require :swank-asdf)
-  (swank:swank-require :swank-presentations)
-  (swank:swank-require :swank-fancy-inspector)
-  (swank:swank-require :swank-arglists)
-  (swank:swank-require :swank-presentations)
-  (load \"/home/sk/cusp/ws/org.lispdev.swank/lisp-extensions/asdf-extensions.lisp\")
-  (format nil \"You are running ~a ~a via LispDev Swank \" (lisp-implementation-type) (lisp-implementation-version)))") nil :repl-thread 2)
-  <--(:indentation-update (("without-package-locks" . 0) ("with-timeout" . 1) ("define-source-context" . 2) ("with-unlocked-packages" . 1) ("with-locked-hash-table" . 1) ("with-unique-names" . 1) ("dx-let" . 1) ("with-float-traps-masked" . 1) ("awhen" . 1) ("defun-cached" . 2) ("dx-flet" . 1) ("once-only" . 1) ("prepare-for-fast-read-char" . 1) ("define-function-name-syntax" . 2) ("do-info" . 1) ("dovector" . 1) ("collect" . 1) ("dohash" . 1) ("named-lambda" . 2) ("with-rebound-io-syntax" . 0) ("prepare-for-fast-read-byte" . 1) ("defmacro-mundanely" . 2) ("binding*" . 1) ("named-let" . 2) ("with-sane-io-syntax" . 0) ("with-fixed-allocation" . 1) ("with-tn@fp-top" . 1) ("maybe-pseudo-atomic" . 1) ("with-empty-tn@fp-top" . 1) ("with-cycle-counter" . 0) ("with-circularity-detection" . 1) ("descend-into" . 1) ("with-single-package-locked-error" . 1) ("number-dispatch" . 1) ("with-deadline" . 1) ("with-pinned-objects" . 1) ("with-local-interrupts" . 0) ("without-interrupts" . 0) ("allow-with-interrupts" . 0) ("with-interrupts" . 0) ("with-interrupt-bindings" . 0) ("in-interruption" . 1) ("without-gcing" . 0) ("define-sequence-traverser" . 2) ("with-c-strvec" . 1) ("lambda-with-lexenv" . 3) ("with-stepping-disabled" . 0) ("with-host" . 1) ("def-output-routines" . 1) ("handling-end-of-the-world" . 0) ("with-concurrent-access-check" . 2) ("with-stepping-enabled" . 0) ("with-active-processes-lock" . 1) ("def-output-routines/variable-width" . 1) ("with-scheduler-lock" . 1) ("input-wrapper/variable-width" . 1) ("with-push-char" . 1) ("with-reader" . 1) ("with-native-pathname" . 1) ("with-finalizer-store-lock" . 0) ("with-default-decoding-replacement" . 1) ("input-wrapper" . 1) ("with-packages" . 1) ("with-standard-replacement-character" . 0) ("with-hash-table-locks" . 1) ("with-available-buffers-lock" . 1) ("with-symbol" . 1) ("with-pathname" . 1) ("output-wrapper" . 1) ("with-descriptor-handlers" . 0) ("string-dispatch" . 2) ("output-wrapper/variable-width" . 1) ("do-debug-block-locations" . 1) ("do-debug-fun-vars" . 1) ("do-debug-fun-blocks" . 1) ("with-new-session" . 1) ("with-mutex" . 1) ("with-recursive-lock" . 1) ("with-system-mutex" . 1) ("with-recursive-spinlock" . 1) ("with-session-lock" . 1) ("with-interruptions-lock" . 1) ("with-recursive-system-spinlock" . 1) ("with-system-spinlock" . 1) ("with-all-threads-lock" . 0) ("with-spinlock" . 1) ("maybe-with-pinned-objects" . 2) ("define-alien-type-translator" . 2) ("bind-fast-lexical-method-functions" . 1) ("pv-binding" . 1) ("dolist-carefully" . 1) ("bind-args" . 1) ("with-dfun-wrappers" . 3) ("simple-lexical-method-functions" . 1) ("with-pcl-lock" . 0) ("doplist" . 2) ("with-type-checked" . 1) ("pv-binding1" . 1) ("dotimes-fixnum" . 1) ("dfun-miss" . 1) ("fast-lexical-method-functions" . 1) ("bind-simple-lexical-method-functions" . 1) ("with-alien" . 1) ("alien-lambda" . 2) ("with-auxiliary-alien-types" . 1) ("define-alien-callback" . 3) ("define-instruction-macro" . 2) ("without-scheduling" . 1) ("assemble" . 1) ("do-sset-elements" . 1) ("note-dependencies" . 1) ("with-modified-segment-index-and-posn" . 1) ("sc-case" . 1) ("deftransform" . 2) ("define-vop" . 1) ("with-source-location" . 1) ("define-source-transform" . 2) ("defoptimizer" . 2) ("defknown" . 4) ("source-transform-lambda" . 1) ("define-move-fun" . 3) ("define-assembly-routine" . 2) ("def-ir1-translator" . 2) ("do-sc-pairs" . 1) ("do-physenv-ir2-blocks" . 1) ("do-nodes" . 1) ("do-packed-tns" . 1) ("do-ir2-blocks" . 1) ("do-eql-vars" . 1) ("with-component-last-block" . 1) ("do-blocks" . 1) ("define-internal-pcl-function-name-syntax" . 1) ("with-ir1-namespace" . 0) ("do-nodes-carefully" . 1) ("define-modular-fun-optimizer" . 2) ("processing-decls" . 1) ("do-nodes-backwards" . 1) ("do-uses" . 1) ("with-compiler-io-syntax" . 0) ("do-live-tns" . 1) ("do-forms-from-info" . 1) ("do-blocks-backwards" . 1) ("with-fun-name-leaf" . 1) ("with-compilation-values" . 0) ("with-fop-stack" . 1) ("expand-bind-defaults" . 2) ("def-format-directive" . 2) ("def-complex-format-directive" . 2) ("with-pretty-stream" . 1) ("with-sequence-iterator" . 2) ("dosequence" . 1) ("with-sequence-iterator-functions" . 2) ("with-new-definition-in-environment" . 1) ("with-augmented-environment" . 1) ("walker-environment-bind" . 1) ("program-destructuring-bind" . 2) ("with-loop-list-collection-head" . 1) ("with-minimax-value" . 1) ("with-compilation-hooks" . 1) ("with-struct" . 2) ("with-debootstrapping" . 0) ("with-slime-output-stream" . 1) ("defimplementation" . 2) ("defsystem" . 1) ("with-sockaddr-un" . 2) ("with-array-data" . 1) ("with-msghdr" . 2) ("with-addrinfo" . 2) ("with-sockaddr-in" . 2) ("with-in-addr" . 2) ("with-hostent" . 2) ("with-protoent" . 2) ("with-sockaddr-un-abstract" . 2) ("with-sockaddr-for" . 1) ("with-vector-sap" . 1) ("with-alien-stat" . 2) ("with-alien-utimbuf" . 2) ("with-growing-c-string" . 1) ("define-entry-point" . 2) ("define-designator" . 2) ("with-dirent" . 2) ("with-alien-termios" . 2) ("with-alien-passwd" . 2) ("with-alien-group" . 2) ("with-alien-timeval" . 2) ("with-alien-flock" . 2) ("with-swank-compilation-unit" . 1) ("with-describe-settings" . 1) ("with-buffer-syntax" . 1) ("with-availability" . 2) ("without-interrupts" . 0) ("with-connection" . 1) ("defslimefun" . 2) ("with-io-redirection" . 1) ("with-temp-package" . 1) ("presenting-object-if" . 3) ("without-slime-interrupts" . 0) ("with-bindings" . 1) ("do-symbols*" . 1) ("with-swank-error-handler" . 1) ("with-thread-description" . 1) ("with-slime-interrupts" . 0) ("presenting-object" . 2) ("with-panic-handler" . 1) ("with-struct*" . 1)))
-  <--(:new-features (:com.gigamonkeys.asdf-extensions :sb-bsd-sockets-addrinfo :asdf :sb-thread :ansi-cl :common-lisp :sbcl :sb-doc :sb-test :sb-ldb :sb-package-locks :sb-unicode :sb-eval :sb-source-locations :ieee-floating-point :x86 :unix :elf :linux :largefile :gencgc :stack-grows-downward-not-upward :c-stack-is-control-stack :compare-and-swap-vops :unwind-to-frame-and-call-vop :raw-instance-init-vops :stack-allocatable-closures :alien-callbacks :cycle-counter :linkage-table :os-provides-dlopen :os-provides-dladdr :os-provides-putwc :os-provides-suseconds-t))
-  <--(:return (:ok ("" "\"You are running SBCL 1.0.20 via LispDev Swank \"")) 2)
-  *disconnect
-  Done listening
-  Display input pipe closed.
-  Display input pipe closed.
-
-   */
-  @Test
-  public void test_basicStartup()
-  {
-    String res = si.basicStartup(false, null, si.extDir);
-    assertEquals(true,res.startsWith("\"You are running SBCL 1.0."));
-  }
-
     /*
   >>> Found default sbcl folder: /home/sk/cusp/ws/org.lispdev.swank/sbcl
   >>> Found default sbcl folder: /home/sk/cusp/ws/org.lispdev.swank/sbcl