Function: gud-jdb-analyze-source
gud-jdb-analyze-source is a byte-compiled function defined in
gud.el.gz.
Signature
(gud-jdb-analyze-source BUF FILE)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
;; Find the package and class definitions in Java source file FILE. Assumes
;; that FILE contains a legal Java program. BUF is a scratch buffer used
;; to hold the source during analysis.
(defun gud-jdb-analyze-source (buf file)
(let ((l nil))
(set-buffer buf)
(insert-file-contents file nil nil nil t)
(goto-char 0)
(catch 'abort
(let ((p ""))
(while (progn
(gud-jdb-skip-whitespace)
(not (eobp)))
(cond
;; Any number of semi's following a block is legal. Move point
;; past them. Note that comments and whitespace may be
;; interspersed as well.
((eq (following-char) ?\073)
(forward-char))
;; Move point past a single line comment.
((looking-at "//")
(gud-jdb-skip-single-line-comment))
;; Move point past a traditional or documentation comment.
((looking-at "/\\*")
(gud-jdb-skip-traditional-or-documentation-comment))
;; Move point past a package statement, but save the PackageName.
((looking-at "package")
(forward-char 7)
(gud-jdb-skip-whitespace-and-comments)
(let ((s (point)))
(gud-jdb-skip-id-ish-thing)
(setq p (concat (buffer-substring s (point)) "."))
(gud-jdb-skip-whitespace-and-comments)
(if (eq (following-char) ?\073)
(forward-char))))
;; Move point past an import statement.
((looking-at "import")
(forward-char 6)
(gud-jdb-skip-whitespace-and-comments)
(gud-jdb-skip-id-ish-thing)
(gud-jdb-skip-whitespace-and-comments)
(if (eq (following-char) ?\073)
(forward-char)))
;; Move point past the various kinds of ClassModifiers.
((looking-at "public")
(forward-char 6))
((looking-at "abstract")
(forward-char 8))
((looking-at "final")
(forward-char 5))
;; Move point past a ClassDeclaration, but save the class
;; Identifier.
((looking-at "class")
(forward-char 5)
(gud-jdb-skip-whitespace-and-comments)
(let ((s (point)))
(gud-jdb-skip-id-ish-thing)
(setq
l (nconc l (list (concat p (buffer-substring s (point)))))))
(gud-jdb-skip-block))
;; Move point past an interface statement.
((looking-at "interface")
(forward-char 9)
(gud-jdb-skip-block))
;; Anything else means the input is invalid.
(t
(message "Error parsing file %s." file)
(throw 'abort nil))))))
l))