Update CEDET from upstream.
[bpt/emacs.git] / lisp / cedet / srecode / java.el
CommitLineData
07a79ce4 1;;; srecode/java.el --- Srecode Java support
4d902e6f 2
acaf905b 3;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
4d902e6f
CY
4
5;; Author: Eric M. Ludlam <eric@siege-engine.com>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Commentary:
23;;
24;; Special support for the Java language.
25
26;;; Code:
27
28(require 'srecode/dictionary)
62a81506
CY
29(require 'semantic/tag)
30
31(eval-when-compile
32 (require 'semantic/find))
4d902e6f
CY
33
34;;;###autoload
35(defun srecode-semantic-handle-:java (dict)
36 "Add macros into the dictionary DICT based on the current java file.
37Adds the following:
38FILENAME_AS_PACKAGE - file/dir converted into a java package name.
39FILENAME_AS_CLASS - file converted to a Java class name."
62a81506 40 ;; Symbols needed by empty files.
4d902e6f
CY
41 (let* ((fsym (file-name-nondirectory (buffer-file-name)))
42 (fnox (file-name-sans-extension fsym))
43 (dir (file-name-directory (buffer-file-name)))
44 (fpak fsym)
45 )
46 (while (string-match "\\.\\| " fpak)
47 (setq fpak (replace-match "_" t t fpak)))
48 (if (string-match "src/" dir)
49 (setq dir (substring dir (match-end 0)))
50 (setq dir (file-name-nondirectory (directory-file-name dir))))
62a81506 51 (setq dir (directory-file-name dir))
4d902e6f 52 (while (string-match "/" dir)
62a81506
CY
53 (setq dir (replace-match "." t t dir)))
54 (srecode-dictionary-set-value dict "FILENAME_AS_PACKAGE" dir)
4d902e6f 55 (srecode-dictionary-set-value dict "FILENAME_AS_CLASS" fnox)
62a81506
CY
56 )
57 ;; Symbols needed for most other files with stuff in them.
58 (let ((pkg (semantic-find-tags-by-class 'package (current-buffer))))
59 (when pkg
60 (srecode-dictionary-set-value dict "CURRENT_PACKAGE" (semantic-tag-name (car pkg)))
61 ))
62 )
4d902e6f
CY
63
64(provide 'srecode/java)
65
66;; Local variables:
67;; generated-autoload-file: "loaddefs.el"
4d902e6f
CY
68;; generated-autoload-load-name: "srecode/java"
69;; End:
70
71;;; srecode/java.el ends here