Initial Commit
[packages] / xemacs-packages / semantic / wisent / wisent-java-tags.el
1 ;;; wisent-java-tags.el --- Java LALR parser for Emacs
2
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 David Ponce
4
5 ;; Author: David Ponce <david@dponce.com>
6 ;; Maintainer: David Ponce <david@dponce.com>
7 ;; Created: 15 Dec 2001
8 ;; Keywords: syntax
9 ;; X-RCS: $Id: wisent-java-tags.el,v 1.1 2007-11-26 15:12:32 michaels Exp $
10
11 ;; This file is not part of GNU Emacs.
12
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.
17
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.
22
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.
27
28 ;;; Commentary:
29 ;;
30
31 ;;; History:
32 ;; 
33
34 ;;; Code:
35
36 (require 'semantic-wisent)
37 (require 'wisent-java-tags-wy)
38 (require 'semantic-java)
39 (eval-when-compile
40   (require 'semantic-util)
41   (require 'semantic-ctxt)
42   (require 'semantic-imenu)
43   (require 'senator)
44   (require 'document))
45
46 ;;;;
47 ;;;; Simple parser error reporting function
48 ;;;;
49
50 (defun wisent-java-parse-error (msg)
51   "Error reporting function called when a parse error occurs.
52 MSG is the message string to report."
53 ;;   (let ((error-start (nth 2 wisent-input)))
54 ;;     (if (number-or-marker-p error-start)
55 ;;         (goto-char error-start)))
56   (message msg)
57   ;;(debug)
58   )
59
60 ;;;;
61 ;;;; Local context
62 ;;;;
63
64 (define-mode-local-override semantic-get-local-variables
65   java-mode ()
66   "Get local values from a specific context.
67 Parse the current context for `field_declaration' nonterminals to
68 collect tags, such as local variables or prototypes.
69 This function override `get-local-variables'."
70   (let ((vars nil)
71         ;; We want nothing to do with funny syntaxing while doing this.
72         (semantic-unmatched-syntax-hook nil))
73     (while (not (semantic-up-context (point) 'function))
74       (save-excursion
75         (forward-char 1)
76         (setq vars
77               (append (semantic-parse-region
78                        (point)
79                        (save-excursion (semantic-end-of-context) (point))
80                        'field_declaration
81                        0 t)
82                       vars))))
83     vars))
84
85 ;;;;
86 ;;;; Semantic integration of the Java LALR parser
87 ;;;;
88
89 ;;;###autoload
90 (defun wisent-java-default-setup ()
91   "Hook run to setup Semantic in `java-mode'.
92 Use the alternate LALR(1) parser."
93   (wisent-java-tags-wy--install-parser)
94   (setq
95    ;; Lexical analysis
96    semantic-lex-number-expression semantic-java-number-regexp
97    semantic-lex-analyzer 'wisent-java-tags-lexer
98    ;; Parsing
99    semantic-tag-expand-function 'semantic-java-expand-tag
100    ;; Environment
101    semantic-imenu-summary-function 'semantic-format-tag-prototype
102    imenu-create-index-function 'semantic-create-imenu-index
103    semantic-type-relation-separator-character '(".")
104    semantic-command-separation-character ";"
105    document-comment-start "/**"
106    document-comment-line-prefix " *"
107    document-comment-end " */"
108    ;; speedbar and imenu buckets name
109    semantic-symbol->name-assoc-list-for-type-parts
110    ;; in type parts
111    '((type     . "Classes")
112      (variable . "Variables")
113      (function . "Methods"))
114    semantic-symbol->name-assoc-list
115    ;; everywhere
116    (append semantic-symbol->name-assoc-list-for-type-parts
117            '((include  . "Imports")
118              (package  . "Package")))
119    ;; navigation inside 'type children
120    senator-step-at-tag-classes '(function variable)
121    )
122   ;; Setup javadoc stuff
123   (semantic-java-doc-setup))
124
125 ;;;###autoload
126 (add-hook 'java-mode-hook 'wisent-java-default-setup)
127
128 (provide 'wisent-java-tags)
129
130 ;;; wisent-java-tags.el ends here