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