Ignore:
Timestamp:
Aug 15, 2013, 8:48:56 PM (6 years ago)
Author:
gz
Message:

Make DEFINITIONS-IN-DOCUMENT also return the type of each definition

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/hemlock/src/searchcoms.lisp

    r15872 r15880  
    498498        until (or (null (find-pattern mark pattern)) (mark> mark end))
    499499        as line = (mark-line (mark-after mark))
    500         collect (list (line-string line) (hi::get-line-origin line))
     500        collect (list (line-string line) (hi::get-line-origin line) (get-definition-type mark))
    501501        while (let ((next (line-next line)))
    502502                (when next
    503503                  (setf (mark-line mark) next)
    504504                  (setf (mark-charpos mark) 0)))))))
     505
     506(defun get-definition-type (mark)
     507  (let ((buffer (mark-buffer mark)))
     508    (mark-after mark)
     509    (let ((str (symbol-at-mark buffer mark)))
     510      (when str
     511        (multiple-value-bind (sym error)
     512                             (let* ((*package* (ccl:require-type (or (buffer-package buffer) *package*) 'package)))
     513                               (ignore-errors (values (read-from-string str))))
     514          (if error
     515            (intern (string-upcase str) *package*)
     516            sym))))))
    505517
    506518(defun move-to-definition (posn line-text &optional (leave-mark t))
     
    519531
    520532
    521 ;; Interface for getting this functionality outside of the editor
    522 ;; returns a list of (string number) where string is the first line of the definition and number is the
    523 ;; absolute position in the buffer of the start of the line.
     533;; Interface for getting this functionality outside of the editor.
     534;; Returns a list of (string number symbol) where string is the first line of the definition,
     535;; number is the absolute position in the buffer of the start of the line, and symbol is the
     536;; definition type (eg. DEFUN, DEFVAR, HI:DEFCOMMAND, etc).
    524537(defun definitions-in-document (ns-doc)
    525538  (gui::execute-in-buffer (gui::hemlock-buffer ns-doc) #'collect-definition-lines))
Note: See TracChangeset for help on using the changeset viewer.