java.el 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ;;; srecode/java.el --- Srecode Java support
  2. ;; Copyright (C) 2009-2012 Free Software Foundation, Inc.
  3. ;; Author: Eric M. Ludlam <eric@siege-engine.com>
  4. ;; This file is part of GNU Emacs.
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;;
  17. ;; Special support for the Java language.
  18. ;;; Code:
  19. (require 'srecode/dictionary)
  20. ;;;###autoload
  21. (defun srecode-semantic-handle-:java (dict)
  22. "Add macros into the dictionary DICT based on the current java file.
  23. Adds the following:
  24. FILENAME_AS_PACKAGE - file/dir converted into a java package name.
  25. FILENAME_AS_CLASS - file converted to a Java class name."
  26. ;; A symbol representing
  27. (let* ((fsym (file-name-nondirectory (buffer-file-name)))
  28. (fnox (file-name-sans-extension fsym))
  29. (dir (file-name-directory (buffer-file-name)))
  30. (fpak fsym)
  31. )
  32. (while (string-match "\\.\\| " fpak)
  33. (setq fpak (replace-match "_" t t fpak)))
  34. (if (string-match "src/" dir)
  35. (setq dir (substring dir (match-end 0)))
  36. (setq dir (file-name-nondirectory (directory-file-name dir))))
  37. (while (string-match "/" dir)
  38. (setq dir (replace-match "_" t t dir)))
  39. (srecode-dictionary-set-value dict "FILENAME_AS_PACKAGE"
  40. (concat dir "." fpak))
  41. (srecode-dictionary-set-value dict "FILENAME_AS_CLASS" fnox)
  42. ))
  43. (provide 'srecode/java)
  44. ;; Local variables:
  45. ;; generated-autoload-file: "loaddefs.el"
  46. ;; generated-autoload-load-name: "srecode/java"
  47. ;; End:
  48. ;;; srecode/java.el ends here