]> code.delx.au - gnu-emacs/blob - lisp/cedet/semantic/wisent/java.el
lisp/cedet/semantic/scope.el (semantic-analyze-show): Fix require.
[gnu-emacs] / lisp / cedet / semantic / wisent / java.el
1 ;;; semantic/wisent/java.el --- Java LALR parser for Emacs
2
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009
4 ;; Free Software Foundation, Inc.
5
6 ;; Author: David Ponce <david@dponce.com>
7 ;; Maintainer: David Ponce <david@dponce.com>
8 ;; Created: 19 June 2001
9 ;; Keywords: syntax
10
11 ;; This file is part of GNU Emacs.
12
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.
17
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.
22
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/>.
25
26 ;;; Commentary:
27 ;;
28
29 ;;; History:
30 ;;
31
32 ;;; Code:
33
34 (require 'semantic/wisent)
35 (require 'semantic/wisent/java-wy)
36 (require 'semantic/java)
37
38 ;;; Enable Semantic in `java-mode'.
39 ;;
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
43 names in scope."
44 (setq wisent-java-wy--enums nil))
45
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)
53 (setq
54 ;; Lexical analysis
55 semantic-lex-number-expression semantic-java-number-regexp
56 semantic-lex-depth nil
57 semantic-lex-analyzer 'wisent-java-lexer
58 ;; Parsing
59 semantic-tag-expand-function 'semantic-java-expand-tag
60 ;; Environment
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
68 ;; in type parts
69 '((type . "Classes")
70 (variable . "Variables")
71 (function . "Methods"))
72 semantic-symbol->name-assoc-list
73 ;; everywhere
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)
79 )
80 ;; Setup javadoc stuff
81 (semantic-java-doc-setup))
82
83 (add-hook 'java-mode-hook 'wisent-java-default-setup)
84
85 ;;; Overridden Semantic API.
86 ;;
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)))
93
94 (define-mode-local-override semantic-get-local-variables
95 java-mode ()
96 "Get local variable declarations from the current context."
97 (let (result
98 ;; Ignore funny syntax while doing this.
99 semantic-unmatched-syntax-hook)
100 (while (not (semantic-up-context (point) 'function))
101 (save-excursion
102 (forward-char 1)
103 (push (semantic-parse-region
104 (point)
105 (save-excursion (semantic-end-of-context) (point))
106 ;; See this production in wisent-java.wy.
107 'block_statement
108 nil t)
109 result)))
110 (apply 'append result)))
111
112 (provide 'semantic/wisent/java)
113
114 ;;; semantic/wisent/java.el ends here