Update copyright notices for 2013.
[bpt/emacs.git] / lisp / cedet / semantic / wisent / java-tags.el
CommitLineData
a964f5e5 1;;; semantic/wisent/java-tags.el --- Java LALR parser for Emacs
bb051423 2
ab422c4d 3;; Copyright (C) 2001-2006, 2009-2013 Free Software Foundation, Inc.
bb051423
CY
4
5;; Author: David Ponce <david@dponce.com>
6;; Maintainer: David Ponce <david@dponce.com>
a964f5e5 7;; Created: 15 Dec 2001
bb051423
CY
8;; Keywords: syntax
9
10;; This file is part of GNU Emacs.
11
12;; GNU Emacs is free software: you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation, either version 3 of the License, or
15;; (at your option) any later version.
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25;;; Commentary:
26;;
27
28;;; History:
29;;
30
31;;; Code:
32
33(require 'semantic/wisent)
a964f5e5 34(require 'semantic/wisent/javat-wy)
bb051423
CY
35(require 'semantic/java)
36
a964f5e5
CY
37;;;;
38;;;; Simple parser error reporting function
39;;;;
40
41(defun wisent-java-parse-error (msg)
42 "Error reporting function called when a parse error occurs.
43MSG is the message string to report."
44;; (let ((error-start (nth 2 wisent-input)))
45;; (if (number-or-marker-p error-start)
46;; (goto-char error-start)))
47 (message msg)
48 ;;(debug)
49 )
bb051423 50
a964f5e5
CY
51;;;;
52;;;; Local context
53;;;;
54
55(define-mode-local-override semantic-get-local-variables
56 java-mode ()
57 "Get local values from a specific context.
58Parse the current context for `field_declaration' nonterminals to
59collect tags, such as local variables or prototypes.
60This function override `get-local-variables'."
61 (let ((vars nil)
62a81506 62 (ct (semantic-current-tag))
a964f5e5
CY
63 ;; We want nothing to do with funny syntaxing while doing this.
64 (semantic-unmatched-syntax-hook nil))
65 (while (not (semantic-up-context (point) 'function))
66 (save-excursion
67 (forward-char 1)
68 (setq vars
69 (append (semantic-parse-region
70 (point)
71 (save-excursion (semantic-end-of-context) (point))
72 'field_declaration
73 0 t)
74 vars))))
62a81506
CY
75 ;; Add 'this' if in a fcn
76 (when (semantic-tag-of-class-p ct 'function)
77 ;; Append a new tag THIS into our space.
78 (setq vars (cons (semantic-tag-new-variable
79 "this" (semantic-tag-name (semantic-current-tag-parent))
80 nil)
81 vars)))
a964f5e5
CY
82 vars))
83
62a81506
CY
84;;;
85;;; Analyzer and type cache support
86;;;
87(define-mode-local-override semantic-analyze-split-name java-mode (name)
88 "Split up tag names on colon . boundaries."
89 (let ((ans (split-string name "\\.")))
90 (if (= (length ans) 1)
91 name
92 (delete "" ans))))
93
94(define-mode-local-override semantic-analyze-unsplit-name java-mode (namelist)
95 "Assemble the list of names NAMELIST into a namespace name."
96 (mapconcat 'identity namelist "."))
97
98
99
a964f5e5
CY
100;;;;
101;;;; Semantic integration of the Java LALR parser
102;;;;
103
07a79ce4 104;; In semantic/imenu.el, not part of Emacs.
f3628edd
GM
105(defvar semantic-imenu-summary-function)
106
a964f5e5 107;;;###autoload
bb051423 108(defun wisent-java-default-setup ()
a964f5e5
CY
109 "Hook run to setup Semantic in `java-mode'.
110Use the alternate LALR(1) parser."
111 (wisent-java-tags-wy--install-parser)
bb051423
CY
112 (setq
113 ;; Lexical analysis
114 semantic-lex-number-expression semantic-java-number-regexp
a964f5e5 115 semantic-lex-analyzer 'wisent-java-tags-lexer
bb051423
CY
116 ;; Parsing
117 semantic-tag-expand-function 'semantic-java-expand-tag
118 ;; Environment
119 semantic-imenu-summary-function 'semantic-format-tag-prototype
bb051423
CY
120 imenu-create-index-function 'semantic-create-imenu-index
121 semantic-type-relation-separator-character '(".")
122 semantic-command-separation-character ";"
123 ;; speedbar and imenu buckets name
124 semantic-symbol->name-assoc-list-for-type-parts
125 ;; in type parts
126 '((type . "Classes")
127 (variable . "Variables")
128 (function . "Methods"))
129 semantic-symbol->name-assoc-list
130 ;; everywhere
131 (append semantic-symbol->name-assoc-list-for-type-parts
132 '((include . "Imports")
133 (package . "Package")))
134 ;; navigation inside 'type children
135 senator-step-at-tag-classes '(function variable)
62a81506
CY
136 ;; Remove 'recursive from the default semanticdb find throttle
137 ;; since java imports never recurse.
138 semanticdb-find-default-throttle
139 (remq 'recursive (default-value 'semanticdb-find-default-throttle))
bb051423
CY
140 )
141 ;; Setup javadoc stuff
142 (semantic-java-doc-setup))
143
a964f5e5 144(provide 'semantic/wisent/java-tags)
bb051423 145
a964f5e5
CY
146;; Local variables:
147;; generated-autoload-file: "../loaddefs.el"
a964f5e5
CY
148;; generated-autoload-load-name: "semantic/wisent/java-tags"
149;; End:
150
151;;; semantic/wisent/java-tags.el ends here