4 ;; SUMMARY: Java source code browser.
5 ;; USAGE: GNU Emacs Lisp Library
6 ;; KEYWORDS: c, oop, tools
11 ;; ORIG-DATE: 01-Aug-95
12 ;; LAST-MOD: 10-May-01 at 12:53:09 by Bob Weiner
14 ;; Copyright (C) 1995, 1996, 1997, 1998 BeOpen.com
15 ;; See the file BR-COPY for license information.
17 ;; This file is part of the OO-Browser.
21 ;; Use `java-browse' to invoke the java OO-Browser. Prefix arg prompts for
22 ;; name of Environment file.
26 ;; ************************************************************************
27 ;; Other required Elisp libraries
28 ;; ************************************************************************
30 (mapcar 'require '(br-start br br-java-ft))
32 ;;; ************************************************************************
34 ;;; ************************************************************************
37 (defun java-browse (&optional env-file no-ui)
38 "Invoke the Java OO-Browser.
39 This allows browsing through Java library and system class hierarchies. With
40 an optional non-nil prefix argument ENV-FILE, prompt for Environment file to
41 use. Alternatively, a string value of ENV-FILE is used as the Environment
42 file name. See also the file \"br-help\"."
44 (let ((same-lang (equal br-lang-prefix java-lang-prefix))
49 ;; Save other language Environment in memory
50 (if br-lang-prefix (br-env-copy nil))
51 (setq br-lang-prefix java-lang-prefix
52 *br-save-wconfig* nil))
53 ;; `same-env' non-nil means the new Env is the previous Env or the most
54 ;; recent previous Env of the same language as the new Env
55 (setq same-env (or (equal java-env-file env-file)
57 (or java-lib-search-dirs java-sys-search-dirs))))
60 ;; If we just switched languages, restore the cached data for the new
62 (if same-lang nil (br-env-copy t))
63 ;; Environment may appear to be the same but its loading may have
64 ;; been interrupted, so ensure all variables are initialized properly.
65 (java-browse-setup env-file)
66 (if (or (null br-paths-htable) (equal br-paths-htable br-empty-htable))
68 (br-env-try-load (or env-file br-env-file) br-env-file))))
70 ;; Create default Environment file specification if needed and none
73 (t (or env-file (file-exists-p java-env-file)
74 (br-env-create java-env-file java-lang-prefix))
75 (or env-file (setq env-file java-env-file))
77 ;; Start browsing a new Environment.
79 (java-browse-setup env-file)
80 (setq load-succeeded (br-env-init env-file same-lang nil))
82 (setq *br-save-wconfig* nil
83 java-env-file br-env-file
84 java-env-name br-env-name
85 java-sys-search-dirs br-sys-search-dirs
86 java-lib-search-dirs br-lib-search-dirs))))
91 (or (and same-lang same-env) (br-refresh))))
93 (t (message "(java-browse): You must build the Environment to browse it.")))))
95 (defun java-class-list-filter (class-list top-only-flag)
96 "Return CLASS-LIST sans any interface entries.
97 Used when Environment classes are listed in the initial listing buffer."
108 ;; interface / abstract class
109 ((string-match "\\`<" class)
110 (if br-protocols-with-classes-flag
111 (if (br-get-parents class)
114 (java-class-list-filter
115 (br-get-children class) t)))
117 ;; Regular class; because of recursion
118 ;; from the above clause, we must ensure
119 ;; that this class has no concrete parents
120 (t (setq parents (br-get-parents class))
121 (if (or (null parents)
126 (not (string-match "\\`<" parent))))
130 (br-protocols-with-classes-flag class-list)
131 (t (delq nil (mapcar (function
133 (if (string-match "\\`<" class)
138 (defun java-lang-mode ()
139 "Invoke normal-mode for programming language buffers and java-mode for any others."
141 (if (not (memq major-mode '(java-mode c++-mode c-mode)))
144 (defun java-mode-setup ()
145 "Load best available java major mode and set `br-lang-mode' to the function that invokes it."
146 (defalias 'br-lang-mode 'java-lang-mode)
148 (progn (require 'cc-mode)
149 (c-initialize-cc-mode))
152 ;;; ************************************************************************
153 ;;; Internal functions
154 ;;; ************************************************************************
156 (defun java-browse-setup (env-file)
157 "Setup language-dependent functions for OO-Browser."
160 (br-setup-constants env-file)
161 ;; Setup to add default classes to system class table after building it.
162 ;; This must come after br-setup-constants call since it clears these
164 (if (fboundp 'add-hook)
165 (add-hook 'br-after-build-sys-hook 'java-add-default-classes)
166 (setq br-after-build-sys-hook '(java-add-default-classes))))
168 (provide 'java-brows)