Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / lisp / cedet / semantic / wisent / java-tags.el
blob62204077bf288a91f57909fb9b31ff0c5416b9bd
1 ;;; semantic/wisent/java-tags.el --- Java LALR parser for Emacs
3 ;; Copyright (C) 2001-2006, 2009-2014 Free Software Foundation, Inc.
5 ;; Author: David Ponce <david@dponce.com>
6 ;; Maintainer: David Ponce <david@dponce.com>
7 ;; Created: 15 Dec 2001
8 ;; Keywords: syntax
10 ;; This file is part of GNU Emacs.
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.
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.
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/>.
25 ;;; Commentary:
28 ;;; History:
31 ;;; Code:
33 (require 'semantic/wisent)
34 (require 'semantic/wisent/javat-wy)
35 (require 'semantic/java)
37 ;;;;
38 ;;;; Simple parser error reporting function
39 ;;;;
41 (defun wisent-java-parse-error (msg)
42 "Error reporting function called when a parse error occurs.
43 MSG 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)
51 ;;;;
52 ;;;; Local context
53 ;;;;
55 (define-mode-local-override semantic-get-local-variables
56 java-mode ()
57 "Get local values from a specific context.
58 Parse the current context for `field_declaration' nonterminals to
59 collect tags, such as local variables or prototypes.
60 This function override `get-local-variables'."
61 (let ((vars nil)
62 (ct (semantic-current-tag))
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))))
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)))
82 vars))
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))))
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 "."))
100 ;;;;
101 ;;;; Semantic integration of the Java LALR parser
102 ;;;;
104 ;; In semantic/imenu.el, not part of Emacs.
105 (defvar semantic-imenu-summary-function)
107 ;;;###autoload
108 (defun wisent-java-default-setup ()
109 "Hook run to setup Semantic in `java-mode'.
110 Use the alternate LALR(1) parser."
111 (wisent-java-tags-wy--install-parser)
112 (setq
113 ;; Lexical analysis
114 semantic-lex-number-expression semantic-java-number-regexp
115 semantic-lex-analyzer 'wisent-java-tags-lexer
116 ;; Parsing
117 semantic-tag-expand-function 'semantic-java-expand-tag
118 ;; Environment
119 semantic-imenu-summary-function 'semantic-format-tag-prototype
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)
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))
141 ;; Setup javadoc stuff
142 (semantic-java-doc-setup))
144 (provide 'semantic/wisent/java-tags)
146 ;; Local variables:
147 ;; generated-autoload-file: "../loaddefs.el"
148 ;; generated-autoload-load-name: "semantic/wisent/java-tags"
149 ;; End:
151 ;;; semantic/wisent/java-tags.el ends here