Ludovic Courtès writes:
 > Paul Landes <[email protected]> writes:
 > 
 > > Ludovic Courtès writes:
 > >  > Paul Landes <[email protected]> writes:
 > >  > 
 > >  > > I appreciate the patch, but there will be functionality in the next
 > >  > > release that does a lot of this, including uses `completing-read' as
 > >  > > your comment mentions :)
 > >  > 
 > >  > Nice!  I didn't find it, in which branch is it?
 > >
 > > Sorry, it isn't in the repository yet.  It's in my local stuff I
 > > haven't merged with repository so for you I'm afraid it's vaporware
 > > until I add it.  The upshot is won't take long to get it in there.
 > 
 > I'd love to see it in the repo, to avoid duplicating work and to know
 > what nice features are going to land in JDEE.  ;-)
 > 
 > Maybe you could commit it in a separate branch to start with, until you
 > deem it "ready" for trunk/2.4.0?  What do you think?

I'd rather not.  But here's the pertinent code in raw form:

(defvar jde-cust-select-class-items nil
  "*History for `jde-cust-select-class' read items.")

(defvar jde-cust-select-class-fq-items nil
  "*History for `jde-cust-select-class' read items (second part of fully
qualified classes).")

(defun jde-cust-parse-class-name (classname)
  "Parse CLASSNAME into it's package and non-fully qualified name.

If CLASSNAME is the symbol `point', then deduce it from what is
at the point.

Return a list in the form:
  \(FULLY-QUALIFIED-CLASSNAME PACKAGE CLASS-NAME)
or `nil' if the passed class name doesn't look like a class (by the Sun Java
codeing standard).

The first two elements of the list are `nil' if CLASSNAME isn't fully qualifed."
  (flet ((parse-at-point
          (classname)
          (let (end-pos fq pkg)
            (when (> (length classname) 0)
              (setq end-pos (position ?. classname :from-end t))
              (if end-pos
                  (setq fq classname
                        pkg (substring fq 0 end-pos)
                        classname (substring fq (1+ end-pos))))
              (when (> (length classname) 0)
                (let ((char (substring classname 0 1)))
                  (if (string= char (upcase char))
                      (list fq pkg classname))))))))
    (if (eq classname 'point)
        (or (parse-at-point (thing-at-point 'word));;'filename))
            (parse-at-point (thing-at-point 'symbol)))
      (parse-at-point classname))))

;;;###autoload
(defun jde-cust-select-class (&optional prompt fq-prompt
                                        this-class-p confirm-fq-p)
  "Select a class interactively.  PROMPT is used to prompt the user for the
first class name, FQ-PROMPT is used only if the class name expands into more
than one fully qualified name.

PROMPT text used to prompt the user for the simple class name, or
\"Class: \" as the default.

FQ-PROMPT text used to prompt the fully qualified  class name, or \"Select
qualified class: \" as the default.

THIS-CLASS-P, if non-nil, use the current class name if no class name at point
and we are in a JDE buffer.

CONFIRM-FQ-P, if non-nil, confirm the class name even when there
is only one unique fully qualified class found for the simple
class name \(that is the class without the package part in the
name).

When called interactively, select the class and copy it to the kill ring."
  (interactive (list nil nil t))
  (if (null prompt) (setq prompt "Class: "))
  (if (null fq-prompt) (setq fq-prompt "Select qualified class: "))
  (let (ctup uinput uq-name classes initial-input fqc)
    (setq ctup (jde-cust-parse-class-name 'point))
    (if (and (null ctup)
             (eq major-mode 'jde-mode)
             this-class-p)
        (setq ctup
              (jde-cust-parse-class-name (jde-cust-buffer-class-name t))))
    (setq uinput (read-string prompt
                              (cond ((null ctup) nil)
                                    ((first ctup) (first ctup))
                                    (t (third ctup)))
                              'jde-cust-select-class-items))
    (setq ctup (jde-cust-parse-class-name uinput))
    (if (null ctup)
        (error "Doesn't appear to be a classname: `%s'" uinput))
    (setq fqc (first ctup)
          uq-name (third ctup))
    (if fqc
        (if (not (jde-jeval-r (concat "jde.util.JdeUtilities."
                                      "classExists(\""
                                      fqc "\");")))
            (error "No match for %s" uq-name))
      (setq classes (jde-jeval-r (concat "jde.util.JdeUtilities."
                                         "getQualifiedName(\""
                                         uq-name "\");")))
      (setq initial-input (jde-import-get-import uq-name))
      (if initial-input (setq initial-input (intern initial-input)))
      (setq fqc
            (cond ((= 0 (length classes))
                   (error "Not match for %s" uq-name))
                  ((and (not confirm-fq-p) (= 1 (length classes)))
                   (car classes))
                  (t (read-completing-choice
                      fq-prompt classes t
                      ;; allow a different class name for savvy clients
                      (not confirm-fq-p)
                      initial-input 'jde-cust-select-class-fq-items)))))
    (when (interactive-p)
      (kill-new fqc)
      (message "Copied `%s'" fqc))
    fqc))

;;;###autoload
(defun jde-cust-open-class-source (class)
  "REPLACE `jde-open-class-source'.
Obviates jde-open-class-source."
  (interactive (list (jde-cust-select-class "Open class: ")))
  (jde-find-class-source class))


 > >  > > Also, the direction I'd like to set is one function for class
 > >  > > reading/finding/visiting.  Currently we have two, this adds a third.
 > >  > > I'd like go keep it at one.
 > >  > 
 > >  > I agree in principle (that was the whole point of this patch: to share
 > >  > the read-class-name code between `jde-run' and `jde-debug'), but which
 > >  > functions are you referring to?
 > >
 > > - jde-open-class-at-point
 > > - jde-open-class-source
 > 
 > Hmm, these functions don't seem to have any connection with the proposed
 > `jde-read-class-name'.  `jde-read-class-name' just asks the user for a
 > class name, nothing more, the idea being that code interactively asking
 > for a class name should use it, for the sake of UI consistency.
 > 
 > Or did I misunderstand your comment?

Maybe.  Take a look at the code above.  The idea is to have one
function that takes care of every aspect of getting a class name,
including optionally trying to complete it.

It's really just a software design paradigm.  There are reasons to
have several functions instead, but in this case for house keeping
reasons, I think it's just easier to maintain one.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
jdee-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jdee-users

Reply via email to