Function: smart-java-cross-reference
smart-java-cross-reference is a byte-compiled function defined in
hmouse-tag.el.
Signature
(smart-java-cross-reference)
Documentation
If within a Java @see comment, edit the def and return non-nil, else nil.
Non-nil is returned even if the @see referent cannot be found.
Does nothing if the oo-browser command is undefined, since it requires that
package for class and feature lookups.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hmouse-tag.el
(defun smart-java-cross-reference ()
"If within a Java @see comment, edit the def and return non-nil, else nil.
Non-nil is returned even if the @see referent cannot be found.
Does nothing if the `oo-browser' command is undefined, since it requires that
package for class and feature lookups."
;;
;; Valid forms of @see cross-references are:
;; * @see #getComponent - current class attribute
;; * @see #waitForAll() - current class method, no arguments
;; * @see #checkID(int, boolean) - current class method, with arguments
;; * @see java.awt.ColorModel#getRGBdefault - library class method
;; * @see Component#paintAll - class method
;; * @see java.awt.GridBagLayout - library class
;; * @see Container - class
;;
;; For simplicity sake, this code ignores the library path given with any
;; class in favor of the OO-Browser's lookup tables. It also ignores any
;; parameters associated with a method, and thus cannot distinguish between
;; methods with the same name within a single class, which we believe to be
;; fairly bad form anyway.
;;
(let ((opoint (point)))
(if (and (memq major-mode '(java-mode java-ts-mode)) (hypb:buffer-file-name)
(fboundp 'br-env-load)
(or (looking-at "@see[ \t]+")
(and (re-search-backward "[@\n\r\f]" nil t)
(looking-at "@see[ \t]+"))))
(let ((class) (feature))
;; Ignore any library path preceding a classname (grouping 1)
(cond
((looking-at
"@see[ \t]+\\(#\\)?\\([^][(){} \t\n\r\f#]+[.]\\)?\\([^][(){} \t\n\r\f#.]+\\)[][(){} \t\n\r\f]")
(if (match-beginning 1)
(setq class nil
feature (buffer-substring-no-properties (match-beginning 3)
(match-end 3)))
(setq class (buffer-substring-no-properties (match-beginning 3) (match-end 3))
feature nil)))
((looking-at
"@see[ \t]+\\([^][(){} \t\n\r\f#]+[.]\\)?\\([^][(){} \t\n\r\f#.]+\\)#\\([^][(){} \t\n\r\f#.]+\\)")
(setq class (buffer-substring-no-properties (match-beginning 2)
(match-end 2))
feature (buffer-substring-no-properties (match-beginning 3)
(match-end 3)))))
;; Return to original point.
(goto-char opoint)
;; Lookup class / feature.
(cond
((and (null class) (null feature))
;; Invalid or unrecognized @see format, so ignore.
(message "(smart-java-cross-reference): Invalid @see cross-reference format")
(beep)
t)
;; Ensure that a Java OO-Browser environment has been loaded.
(t (if (or (and (boundp 'br-lang-prefix)
(equal br-lang-prefix "java-")
(boundp 'br-env-file) (stringp br-env-file)
(null br-env-spec))
;; Load an existing Environment based on current
;; buffer or prompt to build one. This also
;; loads the "br-java.el" library in which the
;; `java-class-def-regexp' variable used below
;; is defined.
(and (br-env-load
(car (nreverse
(smart-tags-file-list
nil
(if (boundp 'br-env-default-file)
br-env-default-file "OOBR")))))
(equal br-lang-prefix "java-")))
(cond ((null feature)
(br-edit nil class))
(t
(if (null class)
(if (save-excursion
(or (re-search-backward java-class-def-regexp nil t)
(re-search-forward java-class-def-regexp nil t)))
(setq class (buffer-substring-no-properties
(match-beginning java-class-def-name-grpn)
(match-end java-class-def-name-grpn)))
(error "(smart-java-cross-reference): This @see must be in a class definition")))
(br-edit-feature class feature t)))
(error "(smart-java-cross-reference): The OO-Browser failed to load a Java environment")))))
;; Return to original point.
(goto-char opoint)
nil)))