1 ;;; semantic/wisent/java.el --- Java LALR parser for Emacs
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009
4 ;; Free Software Foundation, Inc.
6 ;; Author: David Ponce <david@dponce.com>
7 ;; Maintainer: David Ponce <david@dponce.com>
8 ;; Created: 19 June 2001
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
34 (require 'semantic
/wisent
)
35 (require 'semantic
/wisent
/java-wy
)
36 (require 'semantic
/java
)
38 ;;; Enable Semantic in `java-mode'.
40 (defun wisent-java-init-parser-context ()
41 "Initialize context of the LR parser engine.
42 Used as a local `wisent-pre-parse-hook' to cleanup the stack of enum
44 (setq wisent-java-wy--enums nil
))
46 (defun wisent-java-default-setup ()
47 "Hook run to setup Semantic in `java-mode'."
48 ;; Use the Wisent LALR(1) parser to analyze Java sources.
49 (wisent-java-wy--install-parser)
50 (semantic-make-local-hook 'wisent-pre-parse-hook
)
51 (add-hook 'wisent-pre-parse-hook
52 'wisent-java-init-parser-context nil t
)
55 semantic-lex-number-expression semantic-java-number-regexp
56 semantic-lex-depth nil
57 semantic-lex-analyzer
'wisent-java-lexer
59 semantic-tag-expand-function
'semantic-java-expand-tag
61 semantic-imenu-summary-function
'semantic-format-tag-prototype
62 semantic-imenu-expandable-tag-classes
'(type variable
)
63 imenu-create-index-function
'semantic-create-imenu-index
64 semantic-type-relation-separator-character
'(".")
65 semantic-command-separation-character
";"
66 ;; speedbar and imenu buckets name
67 semantic-symbol-
>name-assoc-list-for-type-parts
70 (variable .
"Variables")
71 (function .
"Methods"))
72 semantic-symbol-
>name-assoc-list
74 (append semantic-symbol-
>name-assoc-list-for-type-parts
75 '((include .
"Imports")
76 (package .
"Package")))
77 ;; navigation inside 'type children
78 senator-step-at-tag-classes
'(function variable
)
80 ;; Setup javadoc stuff
81 (semantic-java-doc-setup))
83 (add-hook 'java-mode-hook
'wisent-java-default-setup
)
85 ;;; Overridden Semantic API.
87 (define-mode-local-override semantic-tag-components java-mode
(tag)
88 "Return a list of components for TAG."
89 (if (semantic-tag-of-class-p tag
'function
)
90 (semantic-tag-function-arguments tag
)
91 ;; Simply return the value of the :members attribute.
92 (semantic-tag-get-attribute tag
:members
)))
94 (define-mode-local-override semantic-get-local-variables
96 "Get local variable declarations from the current context."
98 ;; Ignore funny syntax while doing this.
99 semantic-unmatched-syntax-hook
)
100 (while (not (semantic-up-context (point) 'function
))
103 (push (semantic-parse-region
105 (save-excursion (semantic-end-of-context) (point))
106 ;; See this production in wisent-java.wy.
110 (apply 'append result
)))
112 (provide 'semantic
/wisent
/java
)
114 ;;; semantic/wisent/java.el ends here