Initial Commit
[packages] / xemacs-packages / jde / lisp / jde-java-grammar.el
1 ;;; jde-java-grammar.el
2 ;; $Revision: 1.9 $ 
3
4 ;; Author: Paul Kinnucan <paulk@mathworks.com>
5 ;; Maintainer: Paul Kinnucan
6 ;; Keywords: java, tools
7
8 ;; Copyright (C) 2000, 2001, 2004 Paul Kinnucan.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 (require 'semantic-java)
26 (require 'jde-parse)
27 (eval-when-compile
28   (require 'senator)
29   (require 'jde-which-method))
30
31 (defun jde-parse-semantic-default-setup ()
32   "Setup the semantic bovinator for the JDE.
33 Should be run when Semantic is ready to parse, that is, via
34 `semantic-init-hooks'."
35   
36   ;; Remove me from `semantic-init-hooks'
37   (remove-hook 'semantic-init-hooks 'jde-parse-semantic-default-setup)
38
39   (when jde-auto-parse-enable
40     ;; JDE delegates auto-parse to Semantic if possible.  Since
41     ;; version 1.4beta12, Semantic uses an idle timer to 
42     ;; reparse modified buffers if the corresponding minor mode is
43     ;; enabled. Activate Semantic auto-parse in this buffer, unless
44     ;; it is already enabled globally.
45     (cond
46      ;; Since Semantic 2.0beta2
47      ((boundp 'global-semantic-idle-scheduler-mode)
48       (or global-semantic-idle-scheduler-mode
49           (semantic-idle-scheduler-mode 1)))
50      ;; Since Semantic 1.4beta12
51      ((boundp 'global-semantic-auto-parse-mode)
52       (or global-semantic-auto-parse-mode
53           (semantic-auto-parse-mode 1)))
54      (t
55       ;; Default to JDE's auto-parse
56       (make-local-hook 'semantic-change-hooks)
57       (add-hook 'semantic-change-hooks
58                 'jde-parse-buffer-changed-hook t t))))
59   
60   ;; Track full reparses
61   (make-local-hook 'semantic-after-toplevel-cache-change-hook)
62   (add-hook 'semantic-after-toplevel-cache-change-hook
63             'jde-parse-update-after-parse nil t)
64
65   ;; Track partial reparses
66   (make-local-hook 'semantic-after-partial-cache-change-hook)
67   (add-hook 'semantic-after-partial-cache-change-hook
68             'jde-parse-update-after-partial-parse nil t)
69   
70   (when jde-enable-senator
71     ;; Enable `senator-minor-mode' in this buffer, unless it is
72     ;; already enabled globally (since Semantic 1.4beta12).
73     (or (and (boundp 'global-senator-minor-mode)
74              global-senator-minor-mode)
75         (senator-minor-mode 1)))
76
77   ;; imenu & speedbar setup
78   (jde-imenu-setup)
79
80   (if (and jde-which-method-mode
81            (not jde-which-method-idle-timer))
82       (setq jde-which-method-idle-timer
83             (run-with-idle-timer .25 t 'jde-which-method-update)))
84     
85   ;; initial parsing of the current buffer
86   (semantic-fetch-tags))
87
88 (provide 'jde-java-grammar)
89
90 ;;; Change History:
91
92 ;; $Log: jde-java-grammar.el,v $
93 ;; Revision 1.9  2004/12/17 04:23:36  paulk
94 ;; Update to latest version of semantic.
95 ;;
96 ;; Revision 1.8  2004/02/22 06:47:07  paulk
97 ;; Update to support cedet 1.0beta2. Thanks to David Ponce.
98 ;;
99 ;; Revision 1.7  2001/11/11 07:18:17  paulk
100 ;; Moves all the `jde-mode' code depending on Semantic
101 ;; into `jde-parse-semantic-default-setup' which is now run as a
102 ;; `semantic-init-hooks' ensuring that at this point the buffer is ready
103 ;; for parsing.
104 ;;
105 ;; This solves a nasty problem of synchronization between `jde-mode' and
106 ;; Semantic initialization.  This problem was particularly annoying in
107 ;; XEmacs where `jde-mode' buffers were not parsed the first time.  In
108 ;; some rare conditions the problem occurred with Emacs too.
109 ;;
110 ;; Thanks to David Ponce.
111 ;;
112 ;; Revision 1.6  2001/11/08 06:16:03  paulk
113 ;; Updated to support semantic 1.4 beta 12.
114 ;;
115 ;; Revision 1.5  2001/09/16 17:54:00  paulk
116 ;; David Ponce moved all Semantic setup code from `jde-mode-internal' to
117 ;; `jde-parse-semantic-default-setup' (which is called by
118 ;; `jde-mode-internal') and added a hook to support partial re-parsing
119 ;; of buffers.
120 ;;
121 ;; Revision 1.4  2001/05/19 02:35:59  paulk
122 ;; Updated to support semantic 1.4. Thanks to David Ponce.
123 ;;
124 ;; Revision 1.3  2001/02/21 05:55:38  paulk
125 ;; Added require for semantic package.
126 ;;
127 ;; Revision 1.2  2001/01/25 05:38:39  paulk
128 ;; Changed the definition of formal_parameter_list to improve performance (less
129 ;; backtracking) when parsing parameters in method and constructor
130 ;; declarations. Thanks to David Ponce.
131 ;;
132 ;; Revision 1.1  2000/10/25 04:30:31  paulk
133 ;; Initial revision.
134 ;;
135
136 ;; End of jde-java-grammar.el