Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evenson merge 20170423a #1

Open
wants to merge 20 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c7c72d7
abcl: radical improvements to inspection and source locations
alanruttenberg Sep 6, 2016
d9092c3
contrib/swank-fancy-inspector: show symbols in other packages which h…
alanruttenberg Nov 2, 2016
8158f24
load swank matcher earlier
alanruttenberg Dec 12, 2016
badc7cd
Add an inspector :strong-view for a view with a bolder face
alanruttenberg Dec 13, 2016
0a4d470
Make line labels in inspector (:labels) so they display nicely
alanruttenberg Dec 13, 2016
e15c416
Find definitions even if the symbol isn't found in the current package
alanruttenberg Dec 17, 2016
9bbef86
Strings may edited in an emacs buffer from the inspector
alanruttenberg Dec 23, 2016
fde90d8
Refactor utilties used by inspectors into swank/backend.lisp
alanruttenberg Dec 24, 2016
a667ad1
Fixes for searching for functions and methods
alanruttenberg Nov 5, 2016
02e748a
evenson: proposed fixes to Alan's work to align with SLIME conventions
easye Mar 27, 2017
2b9b85d
abcl: Enable load of xref package
alanruttenberg Nov 2, 2016
473c0ff
Merge abcl-introspect plus non-abcl changes
easye Mar 27, 2017
f1a4cbc
kawa: add eval-and-grab-output for slime-eval-print-last-expression
michael-p-m-white Apr 16, 2017
480e136
Added multithreading to clasp.
drmeister Mar 18, 2017
2a04c27
Only use :SPAWN if *features* has :threads
drmeister Mar 19, 2017
433e558
Added support for clasp threads
drmeister Apr 19, 2017
90771f1
Added collect-macro-forms support
drmeister Apr 19, 2017
7dc97e1
Use predicates, not widetags
snuglas Apr 21, 2017
b0cae07
merge from github.com/slime/slime/master on 2017-04-21
easye Apr 23, 2017
94e372e
Manual merge of changes from <https://github.com/alanruttenberg/slime…
easye Apr 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 87 additions & 42 deletions contrib/swank-fancy-inspector.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
(eval-when (:compile-toplevel :load-toplevel :execute)
(swank-require :swank-util))

(defun symbol-info (symbol)
(list (and (constantp symbol) (symbol-value symbol))
(and (fboundp symbol) (symbol-function symbol))
(and (boundp symbol) (symbol-value symbol))
(and (find-class symbol nil) (find-class symbol))
(find-package symbol)
#+armedbear (get symbol 'sys::structure-definition)))


(defmethod emacs-inspect ((symbol symbol))
(let ((package (symbol-package symbol)))
(multiple-value-bind (_symbol status)
Expand Down Expand Up @@ -39,9 +48,9 @@
;; Function
(if (fboundp symbol)
(append (if (macro-function symbol)
`("It a macro with macro-function: "
`((:label "It a macro with macro-function: ")
(:value ,(macro-function symbol)))
`("It is a function: "
`((:label "It is a function: ")
(:value ,(symbol-function symbol))))
`(" " (:action "[unbind]"
,(lambda () (fmakunbound symbol))))
Expand All @@ -61,8 +70,8 @@
;;
;; Package
(if package
`("It is " ,(string-downcase (string status))
" to the package: "
`((:label "It is ") (:label ,(string-downcase (string status)))
(:label " to the package: ")
(:value ,package ,(package-name package))
,@(if (eq :internal status)
`(" "
Expand All @@ -89,8 +98,44 @@
;; More package
(if (find-package symbol)
(label-value-line "It names the package" (find-package symbol)))

;; Same string
(lines-for-symbol-in-other-packages symbol)

(inspect-type-specifier symbol)))))

(defun lines-for-symbol-in-other-packages (symbol)
(let ((others
(loop for p in (list-all-packages)
for candidate = (find-symbol (string symbol) p)
for found = (and (not (null candidate))
(eq (symbol-package candidate) p)
(not (eq (symbol-package symbol) (symbol-package candidate)))
candidate)
for (constant function value class package structure) = (and found (symbol-info found))
for specs = (and found
(append (when value
`((:value ,value
,(if constant "constant" "bound") ", ")))
(when function
`((:value ,function "fbound" ", ")))
(when package
`((:value ,package "package" ", ")))
(when class
`((:value ,class "class") ", "))
(when structure
`((:value ,structure "structure") ", "))))
when found
collect
(let ((specs (butlast specs)))
(list* (list :value found (let ((*package* (find-package :keyword))) (format nil "~s" found)))
(if specs ": " "")
(append specs '((:newline))))))))
(if others
`("In other packages: "
(:newline)
,@(apply 'append others)))))

#-sbcl
(defun inspect-type-specifier (symbol)
(declare (ignore symbol)))
Expand Down Expand Up @@ -139,23 +184,23 @@
(cond ((not docstring) nil)
((< (+ (length label) (length docstring))
75)
(list label ": " docstring '(:newline)))
(list `(:label ,label) ": " docstring '(:newline)))
(t
(list label ":" '(:newline) " " docstring '(:newline))))))
(list `(:label ,label) ":" '(:newline) " " docstring '(:newline))))))

(unless (find-method #'emacs-inspect '() (list (find-class 'function)) nil)
(defmethod emacs-inspect ((f function))
(inspect-function f)))

(defun inspect-function (f)
(append
(label-value-line "Name" (function-name f))
`("Its argument list is: "
(list '(:label "Name:") (function-name f) '(:newline))
`((:label "Argument list: ")
,(inspector-princ (arglist f)) (:newline))
(docstring-ispec "Documentation" f t)
(if (function-lambda-expression f)
(label-value-line "Lambda Expression"
(function-lambda-expression f)))))
(function-lambda-expression f)))))

(defun method-specializers-for-inspect (method)
"Return a \"pretty\" list of the method's specializers. Normal
Expand Down Expand Up @@ -341,7 +386,7 @@ See `methods-by-applicability'.")
,@ (case (ref grouping-kind)
(:all
`((:newline)
"All Slots:"
(:label "All Slots:")
(:newline)
,@(make-slot-listing checklist object class
effective-slots direct-slots
Expand Down Expand Up @@ -451,15 +496,15 @@ See `methods-by-applicability'.")


(defmethod emacs-inspect ((gf standard-generic-function))
(flet ((lv (label value) (label-value-line label value)))
(flet ((lv (label value) `((:label ,label)": " (:value ,value ,(princ-to-string value)) (:newline))))
(append
(lv "Name" (swank-mop:generic-function-name gf))
(lv "Arguments" (swank-mop:generic-function-lambda-list gf))
(docstring-ispec "Documentation" gf t)
(lv "Method class" (swank-mop:generic-function-method-class gf))
(lv "Method combination"
(swank-mop:generic-function-method-combination gf))
`("Methods: " (:newline))
`((:label "Methods: ") (:newline))
(loop for method in (funcall *gf-method-getter* gf) append
`((:value ,method ,(inspector-princ
;; drop the name of the GF
Expand All @@ -475,23 +520,23 @@ See `methods-by-applicability'.")

(defmethod emacs-inspect ((method standard-method))
`(,@(if (swank-mop:method-generic-function method)
`("Method defined on the generic function "
`((:label "Method defined on the generic function ")
(:value ,(swank-mop:method-generic-function method)
,(inspector-princ
(swank-mop:generic-function-name
(swank-mop:method-generic-function method)))))
'("Method without a generic function"))
(:newline)
,@(docstring-ispec "Documentation" method t)
"Lambda List: " (:value ,(swank-mop:method-lambda-list method))
(:label "Lambda List: ") (:value ,(swank-mop:method-lambda-list method))
(:newline)
"Specializers: " (:value ,(swank-mop:method-specializers method)
(:label "Specializers: ") (:value ,(swank-mop:method-specializers method)
,(inspector-princ
(method-specializers-for-inspect method)))
(:newline)
"Qualifiers: " (:value ,(swank-mop:method-qualifiers method))
(:label "Qualifiers: ") (:value ,(swank-mop:method-qualifiers method))
(:newline)
"Method function: " (:value ,(swank-mop:method-function method))
(:label "Method function: ") (:value ,(swank-mop:method-function method))
(:newline)
,@(all-slots-for-inspector method)))

Expand All @@ -508,22 +553,22 @@ See `methods-by-applicability'.")
(second name)))))))

(defmethod emacs-inspect ((class standard-class))
`("Name: "
`((:label "Name: ")
(:value ,(class-name class))
(:newline)
"Super classes: "
,@(common-seperated-spec (swank-mop:class-direct-superclasses class))
(:label "Super classes: ")
,@(common-separated-spec (swank-mop:class-direct-superclasses class))
(:newline)
"Direct Slots: "
,@(common-seperated-spec
(:label "Direct Slots: ")
,@(common-separated-spec
(swank-mop:class-direct-slots class)
(lambda (slot)
`(:value ,slot ,(inspector-princ
(swank-mop:slot-definition-name slot)))))
(:newline)
"Effective Slots: "
(:label "Effective Slots: ")
,@(if (swank-mop:class-finalized-p class)
(common-seperated-spec
(common-separated-spec
(swank-mop:class-slots class)
(lambda (slot)
`(:value ,slot ,(inspector-princ
Expand All @@ -534,16 +579,16 @@ See `methods-by-applicability'.")
(:newline)
,@(let ((doc (documentation class t)))
(when doc
`("Documentation:" (:newline) ,(inspector-princ doc) (:newline))))
`((:label "Documentation:") (:newline) ,(inspector-princ doc) (:newline))))
"Sub classes: "
,@(common-seperated-spec (swank-mop:class-direct-subclasses class)
,@(common-separated-spec (swank-mop:class-direct-subclasses class)
(lambda (sub)
`(:value ,sub
,(inspector-princ (class-name sub)))))
(:newline)
"Precedence List: "
(:label "Precedence List: ")
,@(if (swank-mop:class-finalized-p class)
(common-seperated-spec
(common-separated-spec
(swank-mop:class-precedence-list class)
(lambda (class)
`(:value ,class ,(inspector-princ (class-name class)))))
Expand All @@ -554,16 +599,16 @@ See `methods-by-applicability'.")
(:newline)
,@(loop
for method in (specializer-direct-methods class)
for method-spec = (method-for-inspect-value method)
collect " "
collect `(:value ,method
,(inspector-princ
(method-for-inspect-value method)))
collect `(:value ,method ,(inspector-princ (car method-spec)))
collect `(:value ,method ,(format nil " (~{~a~^ ~})" (cdr method-spec)))
collect '(:newline)
if (documentation method t)
collect " Documentation: " and
collect (abbrev-doc (documentation method t)) and
collect '(:newline))))
"Prototype: " ,(if (swank-mop:class-finalized-p class)
(:label "Prototype: ") ,(if (swank-mop:class-finalized-p class)
`(:value ,(swank-mop:class-prototype class))
'"#<N/A (class not finalized)>")
(:newline)
Expand All @@ -574,19 +619,19 @@ See `methods-by-applicability'.")
(:value ,(swank-mop:slot-definition-name slot))
(:newline)
,@(when (swank-mop:slot-definition-documentation slot)
`("Documentation:" (:newline)
`((:label "Documentation:") (:newline)
(:value ,(swank-mop:slot-definition-documentation
slot))
(:newline)))
"Init args: "
(:label "Init args: ")
(:value ,(swank-mop:slot-definition-initargs slot))
(:newline)
"Init form: "
(:label "Init form: ")
,(if (swank-mop:slot-definition-initfunction slot)
`(:value ,(swank-mop:slot-definition-initform slot))
"#<unspecified>")
(:newline)
"Init function: "
(:label "Init function: ")
(:value ,(swank-mop:slot-definition-initfunction slot))
(:newline)
,@(all-slots-for-inspector slot)))
Expand Down Expand Up @@ -761,21 +806,21 @@ SPECIAL-OPERATOR groups."
external-symbols (sort external-symbols #'string<)
inherited-symbols (sort inherited-symbols #'string<))
`("" ;; dummy to preserve indentation.
"Name: " (:value ,package-name) (:newline)
(:label "Name: ") (:value ,package-name) (:newline)

"Nick names: " ,@(common-seperated-spec package-nicknames) (:newline)
(:label "Nick names: ") ,@(common-separated-spec package-nicknames) (:newline)

,@(when (documentation package t)
`("Documentation:" (:newline)
`((:label "Documentation:") (:newline)
,(documentation package t) (:newline)))

"Use list: " ,@(common-seperated-spec
"Uses packages: " ,@(common-separated-spec
package-use-list
(lambda (package)
`(:value ,package ,(package-name package))))
(:newline)

"Used by list: " ,@(common-seperated-spec
(:label "Used by packages: ") ,@(common-separated-spec
package-used-by-list
(lambda (package)
`(:value ,package ,(package-name package))))
Expand Down Expand Up @@ -986,7 +1031,7 @@ SPECIAL-OPERATOR groups."
(make-file-stream-ispec stream))
content))))

(defun common-seperated-spec (list &optional (callback (lambda (v)
(defun common-separated-spec (list &optional (callback (lambda (v)
`(:value ,v))))
(butlast
(loop
Expand Down
6 changes: 6 additions & 0 deletions contrib/swank-kawa.scm
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,12 @@
(l (values-to-list (eval form env))))
(apply cat (map pprint-to-string l))))

(defslimefun eval-and-grab-output (env string)
(let ((form (read (open-input-string string))))
(let-values ((values (eval form env)))
(list ""
(format #f "~{~S~^~%~}" values)))))

(df call-with-abort (f)
(try-catch (f) (ex <throwable> (exception-message ex))))

Expand Down
9 changes: 9 additions & 0 deletions packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
profile-reset
profile-package

with-struct*
lcons
lcons*
lcons-cdr
llist-range
llist-skip
llist-take
iline

with-collected-macro-forms))

(defpackage swank/rpc
Expand Down
Loading