forked from blastura/dot-emacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflymake-java.el
53 lines (45 loc) · 2.51 KB
/
flymake-java.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(defconst ecj-jar-path "/Users/anton/.emacs.d/java/ecj.jar")
(defvar flymake-java-version "1.5")
;; To display current classpath from build.xml
;; <target name="show-classpath">
;; <property name="classpath" refid="project.classpath"/>
;; <echo message="classpath= ${classpath}"/>
;; </target>
(defun flymake-java-ecj-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-ecj-create-temp-file))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "java" (list "-jar" ecj-jar-path "-Xemacs" "-d" "none"
;; "-warn:none"
"-warn:+over-ann,uselessTypeCheck";;,allJavadoc"
"-source" flymake-java-version "-target" flymake-java-version "-proceedOnError"
"-classpath" (jde-build-classpath jde-global-classpath)
;; "-log" "c:/temp/foo.xml"
local-file))))
(defun flymake-java-ecj-cleanup ()
"Cleanup after `flymake-java-ecj-init' -- delete temp file and dirs."
(flymake-safe-delete-file flymake-temp-source-file-name)
(when flymake-temp-source-file-name
(flymake-safe-delete-directory (file-name-directory flymake-temp-source-file-name))))
(defun flymake-ecj-create-temp-file (file-name prefix)
"Create the file FILE-NAME in a unique directory in the temp directory."
(file-truename (expand-file-name (file-name-nondirectory file-name)
(expand-file-name (int-to-string (abs (random))) (flymake-get-temp-dir)))))
(push '(".+\\.java$" flymake-java-ecj-init flymake-java-ecj-cleanup) flymake-allowed-file-name-masks)
(defun my-flymake-display-err-minibuf ()
"Displays the error/warning for the current line in the minibuffer"
(interactive)
(let* ((line-no (flymake-current-line-no))
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
(count (length line-err-info-list)))
(while (> count 0)
(when line-err-info-list
(let* ((file (flymake-ler-file (nth (1- count) line-err-info-list)))
(full-file (flymake-ler-full-file (nth (1- count) line-err-info-list)))
(text (flymake-ler-text (nth (1- count) line-err-info-list)))
(line (flymake-ler-line (nth (1- count) line-err-info-list))))
(message "[%s] %s" line text)))
(setq count (1- count)))))
(provide 'flymake-java)