1 ;;; flymake-java-1.el --- Flymake for single java files
3 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
4 ;; Created: 2009-12-02 Wed
11 ;; Features that might be required by this library:
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ;; This program is free software; you can redistribute it and/or
29 ;; modify it under the terms of the GNU General Public License as
30 ;; published by the Free Software Foundation; either version 3, or
31 ;; (at your option) any later version.
33 ;; This program is distributed in the hope that it will be useful,
34 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36 ;; General Public License for more details.
38 ;; You should have received a copy of the GNU General Public License
39 ;; along with this program; see the file COPYING. If not, write to
40 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
41 ;; Floor, Boston, MA 02110-1301, USA.
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 (eval-and-compile (require 'flymake))
49 (defun flymake-init-maybe-find-buildfile-dir (source-file-name buildfile-name)
50 "Find buildfile, store its dir in buffer data and return its dir, if found."
52 (flymake-find-buildfile buildfile-name
53 (file-name-directory source-file-name))))
55 (setq flymake-base-dir buildfile-dir)
56 (flymake-log 1 "no buildfile (%s) for %s" buildfile-name source-file-name)
59 (defun flymake-complex-make-init-impl-1 (create-temp-f use-relative-base-dir use-relative-source build-file-name get-cmdline-f)
60 "Create syntax check command line for a directly checked source file.
61 Use CREATE-TEMP-F for creating temp copy."
63 (source-file-name buffer-file-name)
64 (buildfile-dir (flymake-init-maybe-find-buildfile-dir source-file-name build-file-name)))
66 (let* ((temp-source-file-name (flymake-init-create-temp-buffer-copy create-temp-f)))
67 (setq args (flymake-get-syntax-check-program-args temp-source-file-name buildfile-dir
68 use-relative-base-dir use-relative-source
72 (defun flymake-complex-java-init ()
73 (or (flymake-complex-make-init-impl-1 'flymake-create-temp-with-folder-structure nil nil "Makefile" 'flymake-get-make-cmdline)
74 (flymake-complex-make-init-impl-1 'flymake-create-temp-with-folder-structure nil nil "build.xml" 'flymake-get-make-cmdline)
75 (flymake-java-1-init)))
77 (defcustom flymake-java-1-javac "c:/Sun/SDK/jdk/bin/javac.exe"
81 (defun flymake-java-1-init ()
82 (if (not (executable-find flymake-java-1-javac))
83 (message "Can't find javac. Please customize flymake-java-1-javac")
84 (list flymake-java-1-javac
85 (list (flymake-init-create-temp-buffer-copy
86 'flymake-create-temp-with-folder-structure)))))
88 ;; (defun flymake-java-1-turn-on ()
90 ;; (if (not (executable-find flymake-java-1-javac))
91 ;; (message "Can't find javac. Please customize flymake-java-1-javac")
92 ;; (let ((flymake-allowed-file-name-masks
93 ;; '(("\\.java\\'" flymake-java-1-init flymake-simple-cleanup))))
94 ;; (when flymake-mode (flymake-mode -1))
95 ;; (flymake-mode 1))))
98 (defun flymake-java-1-load ()
99 (let ((jrec (assoc "\\.java\\'" flymake-allowed-file-name-masks)))
100 (setq flymake-allowed-file-name-masks
101 (delete jrec flymake-allowed-file-name-masks))
102 (setq flymake-allowed-file-name-masks
104 '("\\.java\\'" flymake-complex-java-init flymake-simple-java-cleanup)
105 flymake-allowed-file-name-masks))))
107 (provide 'flymake-java-1)
108 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
109 ;;; flymake-java-1.el ends here