1 ;;; jde-java-font-lock.el -- Extra level font locking for java
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by David Ponce
5 ;; Author: David Ponce <david@dponce.com>
6 ;; Maintainer: David Ponce <david@dponce.com>
7 ;; Paul Kinnucan <paulk@mathworks.com>
8 ;; Created: September 28 1998
9 ;; Keywords: java, tools
10 ;; VC: $Id: jde-java-font-lock.el,v 1.24 2005/04/07 05:54:29 paulk Exp $
12 ;; This file is not part of Emacs
14 ;; This program is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
19 ;; This program is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with this program; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
31 ;; Adds some extra level font locking for java in `jde-mode'.
33 ;; - Numbers are fontified with `jde-java-font-lock-number-face'.
35 ;; - Packages in package and import statements are fontified with
36 ;; `jde-java-font-lock-package-face'. Last '*' of imported packages
37 ;; are fontified with `jde-java-font-lock-number-face'. Last type
38 ;; identifiers of imported packages are fontified with
39 ;; `font-lock-type-face'.
41 ;; - Modifiers are fontified with `jde-java-font-lock-modifier-face'.
43 ;; - Keywords const and goto are fontified with
44 ;; `font-lock-warning-face'. These keywords are reserved, even
45 ;; though they are not currently used.
47 ;; - Keywords super, this and default are fontified with
48 ;; `font-lock-keyword-face'.
50 ;; - User's defined identifiers (see variable
51 ;; `jde-java-font-lock-api-file') are fontified with
52 ;; `jde-java-font-lock-api-face'.
54 ;; - Capitalized identifiers and special constants null, true and
55 ;; false are fontified with `jde-java-font-lock-constant-face'.
57 ;; - Text between `' in comments and javadoc tags (including non
58 ;; official javadoc tags) are fontified with
59 ;; `jde-java-font-lock-doc-tag-face'.
61 ;; - Javadoc links (following @link tags or enclosed in HTML <a> tags)
62 ;; are fontified with `jde-java-font-lock-link-face'
64 ;; - Javadoc code samples (enclosed in HTML <code> tags or following
65 ;; @see tags) are fontified with `jde-java-font-lock-code-face'.
67 ;; - Javadoc HTML bold and strong styles are fontified with
68 ;; `jde-java-font-lock-bold-face'.
70 ;; - Javadoc HTML italic and emphasized styles are fontified with
71 ;; `jde-java-font-lock-italic-face'.
73 ;; - Javadoc HTML underlined style is fontified with
74 ;; `jde-java-font-lock-underline-face'.
76 ;; - Javadoc HTML preformatted style is fontified with
77 ;; `jde-java-font-lock-pre-face'.
79 ;; All font-lock and jde-java-font-lock faces are individually
80 ;; customizable. jde-java-font-lock faces are in the customization
81 ;; group `jde-java-font-lock-faces' which is a sub group of
82 ;; `font-lock-highlighting-faces' (Emacs) or `font-lock-faces'
85 ;; This code has been tested with GNU Emacs 20.7, 21.0 and XEmacs
86 ;; 21.1. Any comments, suggestions, bug reports or upgrade requests
87 ;; are welcome. Please send them to the maintainers.
89 ;; WARNING: It seems there is byte-code compatibility issues between
90 ;; Emacs and XEmacs. When using Emacs byte-code on XEmacs font
91 ;; locking don't work correctly for some complex matchers like those
92 ;; used to highlight imported package name :-)
96 ;; See at end of this file.
100 (require 'regexp-opt)
105 (defcustom jde-use-font-lock t
106 "*Turn on font-locking if non-nil.
107 Set to nil to disable the use of font-locking."
111 (defcustom jde-java-font-lock-max-names-by-regexp
113 "*Maximum number of user defined names that one regexp can match.
114 No limit if less than 1. For speed, the default value of 100 seems to
115 be a good compromize between the number of font lock keyword regexps
116 to match and the complexity of each regexp.
118 WARNING: It seems XEmacs search fails with a very long regexp. So if
119 you have a lot of user's defined names don't use a value less than 1!"
124 ;;;; Define the faces
127 (defgroup jde-java-font-lock-faces nil
128 "Specific JDE faces for highlighting Java sources."
129 :prefix "jde-java-font-lock-"
130 :group (if (featurep 'xemacs)
132 'font-lock-highlighting-faces))
134 (defface jde-java-font-lock-number-face
135 '((((class grayscale) (background light)) (:foreground "DimGray" :italic t))
136 (((class grayscale) (background dark)) (:foreground "LightGray" :italic t))
137 (((class color) (background light)) (:foreground "RosyBrown"))
138 (((class color) (background dark)) (:foreground "LightSalmon"))
140 "Font Lock mode face used to highlight numbers."
141 :group 'jde-java-font-lock-faces)
143 (defface jde-java-font-lock-operator-face
144 '((((class grayscale)) (:foreground "grey"))
145 (((class color)) (:foreground "medium blue"))
147 "Font Lock mode face used to highlight operators."
148 :group 'jde-java-font-lock-faces)
150 (defface jde-java-font-lock-constant-face
151 '((((type tty) (class color)) (:foreground "magenta"))
152 (((class grayscale) (background light))
153 (:foreground "LightGray" :bold t :underline t))
154 (((class grayscale) (background dark))
155 (:foreground "Gray50" :bold t :underline t))
156 (((class color) (background light)) (:foreground "CadetBlue"))
157 (((class color) (background dark)) (:foreground "Aquamarine"))
158 (t (:bold t :underline t)))
159 "Font Lock mode face used to highlight constants."
160 :group 'jde-java-font-lock-faces)
162 (defface jde-java-font-lock-api-face
163 '((((class grayscale) (background light)) (:foreground "DimGray"))
164 (((class grayscale) (background dark)) (:foreground "LightGray"))
165 (((class color) (background light)) (:foreground "dark goldenrod"))
166 (((class color) (background dark)) (:foreground "light goldenrod")))
167 "Font Lock mode face used to highlight user's defined names."
168 :group 'jde-java-font-lock-faces)
170 (defface jde-java-font-lock-link-face
171 '((t (:foreground "blue" :italic nil :underline t)))
172 "Font Lock mode face used to highlight links."
173 :group 'jde-java-font-lock-faces)
175 (defface jde-java-font-lock-package-face
176 '((((class color) (background dark)) (:foreground "steelblue1"))
177 (((class color) (background light)) (:foreground "blue3"))
179 "Font Lock Mode face used to highlight packages."
180 :group 'jde-java-font-lock-faces)
182 (defface jde-java-font-lock-doc-tag-face
183 '((((class color) (background dark)) (:foreground "light coral"))
184 (((class color) (background light)) (:foreground "green4"))
186 "Font Lock Mode face used to highlight doc tags."
187 :group 'jde-java-font-lock-faces)
189 (defface jde-java-font-lock-modifier-face
190 '((((type tty) (class color)) (:foreground "blue" :weight light))
191 (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
192 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
193 (((class color) (background light)) (:foreground "Orchid"))
194 (((class color) (background dark)) (:foreground "LightSteelBlue"))
196 "Font Lock Mode face used to highlight modifiers."
197 :group 'jde-java-font-lock-faces)
199 (defface jde-java-font-lock-private-face
200 '((((type tty) (class color)) (:foreground "blue" :weight light))
201 (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
202 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
203 (((class color) (background light)) (:foreground "Orchid"))
204 (((class color) (background dark)) (:foreground "LightSteelBlue"))
206 "Font Lock Mode face used to highlight private access."
207 :group 'jde-java-font-lock-faces)
209 (defface jde-java-font-lock-protected-face
210 '((((type tty) (class color)) (:foreground "blue" :weight light))
211 (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
212 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
213 (((class color) (background light)) (:foreground "Orchid"))
214 (((class color) (background dark)) (:foreground "LightSteelBlue"))
216 "Font Lock Mode face used to highlight protected access."
217 :group 'jde-java-font-lock-faces)
219 (defface jde-java-font-lock-public-face
220 '((((type tty) (class color)) (:foreground "blue" :weight light))
221 (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
222 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
223 (((class color) (background light)) (:foreground "Orchid"))
224 (((class color) (background dark)) (:foreground "LightSteelBlue"))
226 "Font Lock Mode face used to highlight public access."
227 :group 'jde-java-font-lock-faces)
229 (defface jde-java-font-lock-bold-face
231 "Font Lock Mode face used to highlight HTML bold text style."
232 :group 'jde-java-font-lock-faces)
234 (defface jde-java-font-lock-italic-face
236 "Font Lock Mode face used to highlight HTML italic text style."
237 :group 'jde-java-font-lock-faces)
239 (defface jde-java-font-lock-underline-face
240 '((t (:underline t)))
241 "Font Lock Mode face used to highlight HTML underlined text style."
242 :group 'jde-java-font-lock-faces)
244 (defface jde-java-font-lock-pre-face
246 "Font Lock Mode face used to highlight HTML preformatted text style."
247 :group 'jde-java-font-lock-faces)
249 (defface jde-java-font-lock-code-face
251 "Font Lock Mode face used to highlight HTML program code style."
252 :group 'jde-java-font-lock-faces)
254 ;; Define the extra font lock faces
255 (defvar jde-java-font-lock-number-face 'jde-java-font-lock-number-face
256 "Face name to use for numbers.")
257 (defvar jde-java-font-lock-operator-face 'jde-java-font-lock-operator-face
258 "Face name to use for operators.")
259 (defvar jde-java-font-lock-constant-face 'jde-java-font-lock-constant-face
260 "Face name to use for constants.")
261 (defvar jde-java-font-lock-package-face 'jde-java-font-lock-package-face
262 "Face name to use for packages.")
263 (defvar jde-java-font-lock-modifier-face 'jde-java-font-lock-modifier-face
264 "Face name to use for modifiers.")
265 (defvar jde-java-font-lock-private-face 'jde-java-font-lock-private-face
266 "Face name to use for private modifiers.")
267 (defvar jde-java-font-lock-protected-face 'jde-java-font-lock-protected-face
268 "Face name to use for protected modifiers.")
269 (defvar jde-java-font-lock-public-face 'jde-java-font-lock-public-face
270 "Face name to use for public modifiers.")
271 (defvar jde-java-font-lock-api-face 'jde-java-font-lock-api-face
272 "Face name to use for user's defined names.")
273 (defvar jde-java-font-lock-doc-tag-face 'jde-java-font-lock-doc-tag-face
274 "Face name to use for doc tags.")
275 (defvar jde-java-font-lock-link-face 'jde-java-font-lock-link-face
276 "Face name to use for links.")
277 (defvar jde-java-font-lock-bold-face 'jde-java-font-lock-bold-face
278 "Face name to use for HTML bold text style.")
279 (defvar jde-java-font-lock-italic-face 'jde-java-font-lock-italic-face
280 "Face name to use for HTML italic text style.")
281 (defvar jde-java-font-lock-underline-face 'jde-java-font-lock-underline-face
282 "Face name to use for HTML underlined text style.")
283 (defvar jde-java-font-lock-pre-face 'jde-java-font-lock-pre-face
284 "Face name to use for HTML preformatted text style.")
285 (defvar jde-java-font-lock-code-face 'jde-java-font-lock-code-face
286 "Face name to use for HTML program code style.")
289 ;;;; Useful constants
293 (defconst jde-java-font-lock-capital-letter
294 "A-Z\300-\326\330-\337_$"
295 "Java identifier capital letter.")
297 (defconst jde-java-font-lock-letter
299 (concat jde-java-font-lock-capital-letter "a-z"))
300 "Java identifier letter.")
302 (defconst jde-java-font-lock-capital-letter-or-digit
304 (concat jde-java-font-lock-capital-letter "0-9"))
305 "Java identifier capital letter or digit.")
307 (defconst jde-java-font-lock-letter-or-digit
309 (concat jde-java-font-lock-letter "0-9"))
310 "Java identifier letter or digit.")
313 (defconst jde-java-font-lock-modifier-regexp
316 (regexp-opt '("abstract"
320 ;;; removed after making each its own font -PaulL
331 "Regular expression to match Java modifiers.")
333 (defconst jde-java-font-lock-number-regexp
336 "\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>"
338 "\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>"
340 "\\<[0-9]+[.][fFdD]\\>"
344 "[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>"
346 "\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>"
348 "\\<0[xX][0-9a-fA-F]+[lL]?\\>"
350 "\\<[0-9]+[lLfFdD]?\\>"
353 "Regular expression to match Java numbers.")
355 (defconst jde-java-font-lock-operator-regexp
357 "Regular expression to match Java operators.")
359 (defconst jde-java-font-lock-capital-id-regexp
361 (concat "\\(\\b[" jde-java-font-lock-capital-letter
362 "]+[" jde-java-font-lock-capital-letter-or-digit
364 "Regular expression to match capitalised identifiers.")
367 ;;;; Support for fontification inside javadocs and comments.
370 (defun jde-java-font-lock-remove-javadoc-keywords (keywords)
371 "Remove existing javadoc font lock keywords from KEYWORDS.
372 That is those with \"@\" in their matcher regexp."
375 (setq matcher (car keywords)
376 keywords (cdr keywords))
377 (if (not (and (consp matcher)
378 (stringp (car matcher))
379 (string-match "@" (car matcher))))
380 (setq kw (cons matcher kw))))
383 (defconst jde-java-font-lock-comment-faces
384 '(font-lock-comment-face font-lock-doc-face)
385 "List of faces font-lock uses for comments.")
387 (defmacro jde-java-font-lock-at-comment (pos)
388 "Return non-nil if POS is in a comment."
389 `(memq (get-text-property ,pos 'face)
390 jde-java-font-lock-comment-faces))
392 (defsubst jde-java-font-lock-search-in-comment (regexp end)
393 "Search forward from point for regular expression REGEXP.
394 Ensure matching occurs in a java comment. Buffer position END bounds
395 the search. The match found must not extend after that position."
399 (setq p (re-search-forward regexp end t)))
400 (setq b (match-beginning 0))
401 (setq ok (and (jde-java-font-lock-at-comment b)
402 (< p (next-single-property-change
403 b 'face nil (point-max))))))
409 (defsubst jde-java-font-lock-search-in-javadoc (regexp end)
410 "Search forward from point for regular expression REGEXP.
411 Ensure matching occurs in a javadoc comment. Buffer position END
412 bounds the search. The match found must not extend after that
416 (while (and (not ok) (setq p (re-search-forward regexp end t)))
417 (setq b (match-beginning 0)
419 ok (and (re-search-backward "^\\s-*\\(/[*][*]\\)" nil t)
420 (jde-java-font-lock-at-comment
421 (goto-char (setq c (match-beginning 1))))
431 (defun jde-java-font-lock-quote-matcher (end)
432 "Font lock matcher for comment enclosed in \`\'.
433 Limit search to END position."
434 (jde-java-font-lock-search-in-comment
438 (defconst jde-java-font-lock-quote-keyword
439 '(jde-java-font-lock-quote-matcher
440 1 jde-java-font-lock-doc-tag-face t)
441 "Font lock keyword for comment enclosed in \`\'.")
443 (defun jde-java-font-lock-html-ahref-matcher (end)
444 "Font lock matcher for HTML A HREF anchor in javadoc comments.
445 Limit search to END position."
446 (jde-java-font-lock-search-in-javadoc
447 "<[Aa]\\s-+[Hh][Rr][Ee][Ff][^>]*>\\([^>]+\\)</[Aa]>"
450 (defconst jde-java-font-lock-html-ahref-keyword
451 '(jde-java-font-lock-html-ahref-matcher
452 1 jde-java-font-lock-link-face t)
453 "Font lock keyword for javadoc HTML A HREF anchor.")
456 (defun jde-java-font-lock-html-tag-regexp (tag &rest aliases)
457 "Return a regexp that matches HTML tag TAG.
458 The string between <TAG> and </TAG> is the second parenthesized
459 expression in the returned regexp. ALIASES are other names for TAG."
460 (let* ((tag-re (mapconcat
462 (mapconcat #'(lambda (c)
470 (hit-re (if (or (and (featurep 'xemacs)
471 (or (< emacs-major-version 21)
472 (and (= emacs-major-version 21)
473 (< emacs-minor-version 4))))
474 (< emacs-major-version 21))
476 ;; In GNU Emacs 21 use the "non-greedy" variant of
477 ;; the operator `*' to match the smallest possible
479 "\\(.\\|[\r\n]\\)*?")))
480 (format "<\\(%s\\)>\\(%s\\)</\\(%s\\)>" tag-re hit-re tag-re)
483 (defconst jde-java-font-lock-comment-faces
484 '(font-lock-comment-face font-lock-doc-face)
485 "List of faces font-lock uses for comments.")
487 (defmacro jde-java-font-lock-at-comment (pos)
488 "Return non-nil if POS is in a comment."
489 `(memq (get-text-property ,pos 'face)
490 jde-java-font-lock-comment-faces))
493 (defsubst jde-java-font-lock-search-in-comment (regexp end)
494 "Search forward from point for regular expression REGEXP.
495 Ensure matching occurs in a java comment. Buffer position END bounds
496 the search. The match found must not extend after that position."
500 (setq p (re-search-forward regexp end t)))
501 (setq b (match-beginning 0))
502 (setq ok (and (jde-java-font-lock-at-comment b)
503 (< p (next-single-property-change
504 b 'face nil (point-max))))))
510 (defun jde-java-font-lock-quote-matcher (end)
511 "Font lock matcher for comment enclosed in \`\'.
512 Limit search to END position."
513 (jde-java-font-lock-search-in-comment
517 (defconst jde-java-font-lock-quote-keyword
518 '(jde-java-font-lock-quote-matcher
519 1 jde-java-font-lock-doc-tag-face t)
520 "Font lock keyword for comment enclosed in \`\'.")
523 (if (featurep 'cc-fonts)
525 ;; Highlight javadoc comments through cc-fonts.
526 (defconst jde-java-font-lock-doc-comments
528 ;; Fontify javadoc tags (including non official ones)
529 (,(concat "^[ \t]*\\(/\\*\\*\\|\\*?\\)[ \t]*"
530 "\\(@[" jde-java-font-lock-letter-or-digit "]+\\)")
531 2 jde-java-font-lock-doc-tag-face t)
532 ;; Fontify @param variable name
533 ("^[ \t]*\\(/\\*\\*\\|\\*?\\)[ \t]*@param\\>[ \t]*\\(\\sw+\\)?"
534 2 font-lock-variable-name-face prepend t)
535 ;; Fontify @exception or @throws exception type
536 ("^[ \t]*\\(/\\*\\*\\|\\*?\\)[ \t]*\
537 @\\(exception\\|throws\\)\\>[ \t]*\\(\\S-+\\)?"
538 3 font-lock-type-face prepend t)
541 1 jde-java-font-lock-doc-tag-face t)
543 ("{\\(@link\\)\\>[ \t]+\\([^}]*\\)}"
544 (1 jde-java-font-lock-doc-tag-face t)
545 (2 jde-java-font-lock-link-face t))
546 ;; Fontify @see reference
547 (,(concat "^[ \t]*\\(/\\*\\*\\|\\*?\\)[ \t]*"
549 "\\([.#" jde-java-font-lock-letter-or-digit "]+\\)")
550 2 jde-java-font-lock-code-face t)
551 ;; Fontify the text of a HREF anchor
552 ("<[Aa]\\s-+[Hh][Rr][Ee][Ff][^>]*>\\([^>]+\\)</[Aa]>"
553 1 jde-java-font-lock-link-face t)
554 ;; Fontify other HTML tags
555 (,(jde-java-font-lock-html-tag-regexp "b")
556 2 jde-java-font-lock-bold-face t)
557 (,(jde-java-font-lock-html-tag-regexp "strong")
558 2 jde-java-font-lock-bold-face t)
559 (,(jde-java-font-lock-html-tag-regexp "i")
560 2 jde-java-font-lock-italic-face t)
561 (,(jde-java-font-lock-html-tag-regexp "em")
562 2 jde-java-font-lock-italic-face t)
563 (,(jde-java-font-lock-html-tag-regexp "u")
564 2 jde-java-font-lock-underline-face t)
565 (,(jde-java-font-lock-html-tag-regexp "code")
566 2 jde-java-font-lock-code-face t)
567 (,(jde-java-font-lock-html-tag-regexp "pre")
568 2 jde-java-font-lock-pre-face t)
570 "Keywords highlighted in javadoc comments.")
572 ;; Highlight javadoc comments through JDEE's own support
573 (defun jde-java-font-lock-remove-javadoc-keywords (keywords)
574 "Remove existing javadoc font lock keywords from KEYWORDS.
575 That is those with \"@\" in their matcher regexp."
578 (setq matcher (car keywords)
579 keywords (cdr keywords))
580 (if (not (and (consp matcher)
581 (stringp (car matcher))
582 (string-match "@" (car matcher))))
583 (setq kw (cons matcher kw))))
586 (defsubst jde-java-font-lock-search-in-javadoc (regexp end)
587 "Search forward from point for regular expression REGEXP.
588 Ensure matching occurs in a javadoc comment. Buffer position END
589 bounds the search. The match found must not extend after that
593 (while (and (not ok) (setq p (re-search-forward regexp end t)))
594 (setq b (match-beginning 0)
596 ok (and (re-search-backward "^\\s-*\\(/[*][*]\\)" nil t)
597 (jde-java-font-lock-at-comment
598 (goto-char (setq c (match-beginning 1))))
608 (defun jde-java-font-lock-html-ahref-matcher (end)
609 "Font lock matcher for HTML A HREF anchor in javadoc comments.
610 Limit search to END position."
611 (jde-java-font-lock-search-in-javadoc
612 "<[Aa]\\s-+[Hh][Rr][Ee][Ff][^>]*>\\([^>]+\\)</[Aa]>"
615 (defconst jde-java-font-lock-html-ahref-keyword
616 '(jde-java-font-lock-html-ahref-matcher
617 1 jde-java-font-lock-link-face t)
618 "Font lock keyword for javadoc HTML A HREF anchor.")
621 (defvar jde-java-font-lock-html-keywords nil
622 "List of HTML keywords defined so far.")
624 (defmacro jde-java-font-lock-def-html-keyword (tag face)
625 "Define a font-lock keyword for HTML TAG.
626 Data inside TAG will be highlighted with FACE.
627 A new keyword is pushed into `jde-java-font-lock-html-keywords'."
628 (let* ((matcher (intern (format "jde-java-font-lock-html-%s-matcher" tag))))
630 (add-to-list 'jde-java-font-lock-html-keywords '(,matcher 2 ,face t))
631 (defun ,matcher (end)
632 (jde-java-font-lock-search-in-javadoc
633 ,(jde-java-font-lock-html-tag-regexp tag) end)))))
635 (jde-java-font-lock-def-html-keyword "b" jde-java-font-lock-bold-face)
636 (jde-java-font-lock-def-html-keyword "strong" jde-java-font-lock-bold-face)
637 (jde-java-font-lock-def-html-keyword "i" jde-java-font-lock-italic-face)
638 (jde-java-font-lock-def-html-keyword "em" jde-java-font-lock-italic-face)
639 (jde-java-font-lock-def-html-keyword "u" jde-java-font-lock-underline-face)
640 (jde-java-font-lock-def-html-keyword "code" jde-java-font-lock-code-face)
641 (jde-java-font-lock-def-html-keyword "pre" jde-java-font-lock-pre-face)
643 (defun jde-java-font-lock-javadoc-tag-matcher (end)
644 "Font lock matcher for javadoc tags.
645 Limit search to END position."
646 (jde-java-font-lock-search-in-javadoc
648 (concat "^[ \t]*\\(/\\*\\*\\|\\*?\\)[ \t]*"
649 "\\(@[" jde-java-font-lock-letter-or-digit "]+\\)"))
652 (defconst jde-java-font-lock-javadoc-tag-keyword
653 '(jde-java-font-lock-javadoc-tag-matcher
654 2 jde-java-font-lock-doc-tag-face t)
655 "Font lock keyword for javadoc tags.")
657 (defun jde-java-font-lock-javadoc-docroot-matcher (end)
658 "Font lock matcher for javadoc @docRoot tags.
659 Limit search to END position."
660 (jde-java-font-lock-search-in-javadoc
664 (defconst jde-java-font-lock-javadoc-docroot-keyword
665 '(jde-java-font-lock-javadoc-docroot-matcher
666 1 jde-java-font-lock-doc-tag-face t)
667 "Font lock keyword for javadoc @docRoot tags.")
669 (defun jde-java-font-lock-javadoc-link-matcher (end)
670 "Font lock matcher for javadoc @link tags.
671 Limit search to END position."
672 (jde-java-font-lock-search-in-javadoc
673 "{\\(@link\\)\\>[ \t]+\\([^}]*\\)}"
676 (defconst jde-java-font-lock-javadoc-link-keyword
677 '(jde-java-font-lock-javadoc-link-matcher
678 (1 jde-java-font-lock-doc-tag-face t)
679 (2 jde-java-font-lock-link-face t))
680 "Font lock keyword for javadoc @link tags.")
682 (defun jde-java-font-lock-javadoc-see-ref-matcher (end)
683 "Font lock matcher for javadoc @see references.
684 Limit search to END position."
685 (jde-java-font-lock-search-in-javadoc
687 (concat "^[ \t]*\\(/\\*\\*\\|\\*?\\)[ \t]*"
689 "\\([.#" jde-java-font-lock-letter-or-digit "]+\\)"))
692 (defconst jde-java-font-lock-javadoc-see-ref-keyword
693 '(jde-java-font-lock-javadoc-see-ref-matcher
694 2 jde-java-font-lock-code-face t)
695 "Font lock keyword for javadoc @see references.")
697 (defun jde-java-font-lock-javadoc-param-name-matcher (end)
698 "Font lock matcher for javadoc @param names.
699 Limit search to END position."
700 (jde-java-font-lock-search-in-javadoc
701 "^[ \t]*\\(/\\*\\*\\|\\*?\\)[ \t]*@param\\>[ \t]*\\(\\sw+\\)?"
704 (defconst jde-java-font-lock-javadoc-param-name-keyword
705 '(jde-java-font-lock-javadoc-param-name-matcher
706 2 font-lock-variable-name-face prepend t)
707 "Font lock keyword for javadoc @param names.")
709 (defun jde-java-font-lock-javadoc-exception-type-matcher (end)
710 "Font lock matcher for javadoc exception types.
711 Limit search to END position."
712 (jde-java-font-lock-search-in-javadoc
713 "^[ \t]*\\(/\\*\\*\\|\\*?\\)[ \t]*\
714 @\\(exception\\|throws\\)\\>[ \t]*\\(\\S-+\\)?"
717 (defconst jde-java-font-lock-javadoc-exception-type-keyword
718 '(jde-java-font-lock-javadoc-exception-type-matcher
719 3 font-lock-type-face prepend t)
720 "Font lock keyword for javadoc exception types.")
725 ;;;; Support for fontification of user's defined names.
728 (defcustom jde-java-font-lock-api-file
729 (expand-file-name "~/jde-java-font-lock.api")
730 "*File which contains a list of user's defined names to fontify.
731 If nil no name fontification occurs. Otherwise the specified file must
732 contain one name by line. Lines not beginning with a letter are
733 ignored. When you change this file or modify its content a new cache
734 of font lock regular expressions will be rebuilt when restarting
735 Emacs. Also, you can manually rebuild the cache and update font lock
736 keywords by entering the command:
738 \\[universal-argument] \\[jde-java-font-lock-setup-keywords]."
740 :type '(choice :tag "Names"
741 (const :tag "No" nil)
742 (file :tag "In file" :format "%t\n%v")))
744 (defcustom jde-java-font-lock-api-name-filter nil
745 "*Function used to filter a name."
749 (defconst jde-java-font-lock-api-entry-regexp
751 (concat "^[" jde-java-font-lock-letter "]"
752 "[" jde-java-font-lock-letter-or-digit "]+$"))
753 "Regexp to match a valid entry in `jde-java-font-lock-api-file'.")
755 (defconst jde-java-font-lock-api-entry-match 0
756 "Index of the match data in `jde-java-font-lock-api-entry-regexp'.")
758 (defun jde-java-font-lock-api-names (&optional filter)
759 "Return the list of names in `jde-java-font-lock-api-file'.
760 If optional FILTER function is non-nil it is called for each name
761 found and must return non-nil to include it in the result list."
763 (if (and jde-java-font-lock-api-file
764 (file-readable-p jde-java-font-lock-api-file))
767 (insert-file-contents jde-java-font-lock-api-file)
768 (goto-char (point-min))
769 (while (re-search-forward jde-java-font-lock-api-entry-regexp nil t)
770 (setq k (match-string jde-java-font-lock-api-entry-match))
771 ;; Allow filtering of names
772 (if (or (null filter) (funcall filter k))
773 (setq kl (cons k kl))))))
776 (defun jde-java-font-lock-api-split-list (l n)
777 "Split list L in sub listes of N elements.
778 If L is nil return nil. If N is less than 1 all elements will be in
783 (let (split-list sub-list i)
785 (setq i 0 sub-list nil)
786 (while (and l (< i n))
787 (setq sub-list (cons (car l) sub-list)
791 (setq split-list (cons sub-list split-list))))
794 (defun jde-java-font-lock-api-build-regexps (max-matches)
795 "Build regular expressions matching names to fontify.
796 MAX-MATCHES is the maximum number of names that one regular expression
797 will match. If MAX-MATCHES is less than 1 one regular expression will
798 match all the names."
799 (let ((max-specpdl-size 2000)) ;; Prevent errors in `regexp-opt'
800 ;; when processing long string listes
803 (concat "\\<" (regexp-opt k t) "\\>")))
804 (jde-java-font-lock-api-split-list
805 (jde-java-font-lock-api-names
806 jde-java-font-lock-api-name-filter)
809 (defvar jde-java-font-lock-api-cache nil
810 "Cache of regular expressions matching names to fontify..")
812 (defun jde-java-font-lock-api-cache-file ()
813 "Return the filename of the regular expressions cache.
814 There is a different cache file for each major version of (X)Emacs
815 because of incompatible regular expressions returned by `regexp-opt'."
816 (and jde-java-font-lock-api-file
817 (format "%s.%semacs-%d.apicache"
818 jde-java-font-lock-api-file
819 (if (featurep 'xemacs) "x" "")
820 emacs-major-version)))
822 (defconst jde-java-font-lock-api-cache-file-header
823 ";;; Regular expressions matching names to fontify.
824 ;;; Automatically generated by `jde-java-font-lock' on %s.
826 "Header to be written into the cache file.")
828 (defun jde-java-font-lock-api-regexps (&optional rebuild)
829 "Return regular expressions matching names to fontify.
830 The list is cached in variable `jde-java-font-lock-api-cache'. If it
831 is nil try to initialize it from the cache file (see function
832 `jde-java-font-lock-api-cache-file'). If optional REBUILD flag is
833 non-nil or there is no cache file or the cache file is older than the
834 names file (see variable `jde-java-font-lock-api-file'), a new cache
836 (let ((cache (jde-java-font-lock-api-cache-file)))
839 ;; Inconditionnal rebuild
841 ;; Clear the cache to rebuild
842 (setq jde-java-font-lock-api-cache nil))
844 ;; No names file exists
846 ;; Clear the cache (no fontification)
847 (setq jde-java-font-lock-api-cache nil))
849 ;; A cache file exists
850 ((file-readable-p cache)
851 (if (file-newer-than-file-p jde-java-font-lock-api-file cache)
854 "jde-java-font-lock: names file %s newer than cache file %s"
855 jde-java-font-lock-api-file cache)
856 ;; The api file has been modified since the cache was
857 ;; created, so clear the cache to rebuild
858 (setq jde-java-font-lock-api-cache nil))
859 ;; Try to load the existing cache if needed
860 (or jde-java-font-lock-api-cache
863 ;; If load fails clear the cache to rebuild
865 (setq jde-java-font-lock-api-cache nil)))))))
867 (or jde-java-font-lock-api-cache
869 ;; Build a new cache if it is empty and available
871 (message "jde-java-font-lock: building names cache...")
872 (when (setq jde-java-font-lock-api-cache
873 (jde-java-font-lock-api-build-regexps
874 jde-java-font-lock-max-names-by-regexp))
875 ;; Save regexps in cache
876 (with-current-buffer (find-file-noselect cache)
879 (format jde-java-font-lock-api-cache-file-header
880 (current-time-string))
881 (format "(setq jde-java-font-lock-api-cache '%S)"
882 jde-java-font-lock-api-cache))
884 (kill-buffer (current-buffer))))
885 (message "jde-java-font-lock: building names cache...%s"
886 (if jde-java-font-lock-api-cache "done" "empty"))))
887 jde-java-font-lock-api-cache))
889 (defun jde-java-font-lock-api-keywords (&optional rebuild)
890 "Return a list of font lock keywords for user's defined names.
891 If optional REBUILD flag is non-nil create a new cache of regular
895 (cons k 'jde-java-font-lock-api-face)))
896 (jde-java-font-lock-api-regexps rebuild)))
899 ;;;; Font lock setup.
902 (defvar java-font-lock-keywords-4 nil
903 "Extra level fontification keywords for JDE mode.")
905 (defun jde-java-font-lock-refontify ()
906 "Re-fontify buffers in `java-mode' and `jde-mode'."
907 (dolist (b (buffer-list))
908 (when (buffer-live-p b)
909 (with-current-buffer b
910 (when (and font-lock-mode
911 (memq major-mode '(java-mode jde-mode)))
912 (message "JDEE refontify buffer %s..." b)
915 (message "JDEE refontify buffer %s...done" b))))))
917 (defun jde-java-font-lock-keywords (&optional rebuild)
918 "JDEE's extra level font lock keywords.
919 If optional REBUILD flag is non-nil create a new cache of regular
921 (if (featurep 'cc-fonts)
923 ;; Through cc-fonts support.
925 java-font-lock-keywords-3
926 ;; Fontify user's defined names
927 (mapcar #'(lambda (e)
929 (c-make-font-lock-search-function
931 (list 0 (cdr e) t))))
932 (jde-java-font-lock-api-keywords rebuild))
934 ;; Fontify modifiers.
935 `(,(c-make-font-lock-search-function
936 jde-java-font-lock-modifier-regexp
937 '(0 jde-java-font-lock-modifier-face t)))
938 `(,(c-make-font-lock-search-function
939 "\\<\\(false\\|null\\|true\\)\\>"
940 '(1 jde-java-font-lock-constant-face t)))
941 ;; Fontify default and assert as keywords
942 `(,(c-make-font-lock-search-function
943 "\\<\\(default\\|assert\\)\\>"
944 '(1 'font-lock-keyword-face t)))
945 ;; Fontify const and goto with warning face. These keywords are
946 ;; reserved, even though they are not currently used.
947 `(,(c-make-font-lock-search-function
948 "\\<\\(const\\|goto\\)\\>"
949 '(1 'font-lock-warning-face t)))
951 `(,(c-make-font-lock-search-function
952 jde-java-font-lock-number-regexp
953 '(0 jde-java-font-lock-number-face t)))
955 ;;; `(,(c-make-font-lock-search-function
956 ;;; jde-java-font-lock-operator-regexp
957 ;;; '(0 jde-java-font-lock-operator-face t)))
958 ;; Fontify capitalised identifiers as constant
959 `(,jde-java-font-lock-capital-id-regexp
960 1 jde-java-font-lock-constant-face)
961 ;; Fontify text between `' in comments
962 jde-java-font-lock-quote-keyword
963 ;; Fontify javadoc comments
965 (c-font-lock-doc-comments
967 jde-java-font-lock-doc-comments)))
971 ;; Through JDEE's own support
973 ;; Feature scoping: These must come first or the Special
974 ;; constants, Modifiers and Packages from keywords-1 will catch
977 (if (featurep 'xemacs)
980 ;; Special keywords and constants
981 '("\\<\\(this\\|super\\)\\>"
982 (1 font-lock-keyword-face))
983 '("\\<\\(false\\|null\\|true\\)\\>"
984 (1 jde-java-font-lock-constant-face))
988 ;; Fontify default as keyword
989 '("\\<\\(default\\)\\>" (1 font-lock-keyword-face))
990 ;; Fontify assert as keyword
991 '("\\<\\(assert\\)\\>" (1 font-lock-keyword-face))
992 ;; Fontify const and goto with warning face. These keywords are
993 ;; reserved, even though they are not currently used.
994 '("\\<\\(const\\|goto\\)\\>" (1 font-lock-warning-face))
995 ;; Fontify modifiers.
996 (cons jde-java-font-lock-modifier-regexp
997 'jde-java-font-lock-modifier-face)
998 ;; Fontify package directives
999 '("\\<\\(package\\)\\>\\s-+\\(\\sw+\\)"
1000 (1 font-lock-keyword-face)
1001 (2 jde-java-font-lock-package-face nil t)
1002 ("\\=\\.\\(\\sw+\\)" nil nil
1003 (1 jde-java-font-lock-package-face nil t)))
1004 ;; Fontify import directives
1005 '("\\<\\(import\\)\\>\\s-+\\(\\sw+\\)"
1006 (1 font-lock-keyword-face)
1007 (2 (if (equal (char-after (match-end 0)) ?\.)
1008 'jde-java-font-lock-package-face
1009 'font-lock-type-face))
1010 ("\\=\\.\\(\\*\\|\\sw+\\)" nil nil
1011 (1 (if (equal (char-after (match-end 0)) ?\.)
1012 'jde-java-font-lock-package-face
1013 (if (equal (char-before (match-end 0)) ?\*)
1014 'jde-java-font-lock-number-face
1015 'font-lock-type-face)))))
1016 ;; modifier protections
1017 '("\\<\\(private\\)\\>" (1 jde-java-font-lock-private-face))
1018 '("\\<\\(protected\\)\\>" (1 jde-java-font-lock-protected-face))
1019 '("\\<\\(public\\)\\>" (1 jde-java-font-lock-public-face))
1021 ;; Fontify user's defined names
1022 (jde-java-font-lock-api-keywords rebuild)
1025 (if (featurep 'xemacs)
1026 java-font-lock-keywords-2
1027 ;; Remove existing javadoc font lock keywords from GNU Emacs
1028 ;; `java-font-lock-keywords-3'
1029 (jde-java-font-lock-remove-javadoc-keywords
1030 java-font-lock-keywords-3))
1033 (unless (featurep 'xemacs)
1034 ;; GNU Emacs don't fontify capitalized types so do it
1037 (concat "\\<\\([" jde-java-font-lock-capital-letter "]\\sw*\\)\\>"
1038 "\\([ \t]*\\[[ \t]*\\]\\)*"
1040 '(font-lock-match-c-style-declaration-item-and-skip-to-next
1041 (goto-char (match-beginning 3))
1042 (goto-char (match-beginning 3))
1043 (1 (if (match-beginning 2)
1044 font-lock-function-name-face
1045 font-lock-variable-name-face))))
1047 (concat "\\<\\([" jde-java-font-lock-capital-letter "]\\sw*\\)\\>"
1048 "\\([ \t]*\\[[ \t]*\\]\\)*"
1050 '(1 font-lock-type-face))
1051 '("\\<\\(new\\|instanceof\\)\\>[ \t]+\\(\\sw+\\)"
1052 2 font-lock-type-face)))
1054 ;; Some extra fontification
1057 (cons jde-java-font-lock-number-regexp
1058 'jde-java-font-lock-number-face)
1059 ;; Fontify operators
1060 ;;; (cons jde-java-font-lock-operator-regexp
1061 ;;; 'jde-java-font-lock-operator-face)
1062 ;; Fontify capitalised identifiers as constant
1063 (cons jde-java-font-lock-capital-id-regexp
1064 '(1 jde-java-font-lock-constant-face))
1065 ;; Fontify text between `' in comments
1066 jde-java-font-lock-quote-keyword
1067 ;; Fontify javadoc tags (including non official ones)
1068 jde-java-font-lock-javadoc-tag-keyword
1069 ;; Fontify @param variable name
1070 jde-java-font-lock-javadoc-param-name-keyword
1071 ;; Fontify @exception or @throws exception type
1072 jde-java-font-lock-javadoc-exception-type-keyword
1074 jde-java-font-lock-javadoc-docroot-keyword
1076 jde-java-font-lock-javadoc-link-keyword
1077 ;; Fontify @see reference
1078 jde-java-font-lock-javadoc-see-ref-keyword
1079 ;; Fontify the text of a HREF anchor
1080 jde-java-font-lock-html-ahref-keyword
1082 ;; Fontify other HTML tags
1083 jde-java-font-lock-html-keywords
1088 (defun jde-java-font-lock-setup-keywords (&optional rebuild)
1089 "Setup font lock keywords in `java-font-lock-keywords-4'.
1090 If optional REBUILD flag is non-nil create a new cache of regular
1093 (and (interactive-p)
1094 (consp current-prefix-arg)
1097 ;; Setup the JDEE's extra font lock keywords.
1098 (setq java-font-lock-keywords-4 (jde-java-font-lock-keywords rebuild))
1100 ;; Update fontification of buffers in `java-mode' and `jde-mode'.
1101 (when (interactive-p)
1102 (jde-java-font-lock-refontify)))
1104 ;; Setup `java-font-lock-keywords-4'
1105 (jde-java-font-lock-setup-keywords)
1107 ;; Define new defaults for Font Lock mode
1108 (defconst jde-java-font-lock-defaults
1109 (let ((java-defaults
1110 (if (featurep 'xemacs)
1111 (get 'java-mode 'font-lock-defaults)
1112 ;;; To avoid compilation warning, replace obsolete variable,
1113 ;;; font-lock-defaults-alist, with its value for java-mode.
1114 ;;; (cdr (assq 'java-mode font-lock-defaults-alist)))))
1116 '((java-font-lock-keywords
1117 java-font-lock-keywords-1
1118 java-font-lock-keywords-2
1119 java-font-lock-keywords-3)
1120 nil nil ((?_ . "w") (?$ . "w")) nil
1121 (font-lock-mark-block-function . mark-defun)))))
1122 (cons (append (car java-defaults) '(java-font-lock-keywords-4))
1123 (cdr java-defaults)))
1124 "Defaults for coloring Java keywords in jde-mode. The defaults
1125 consist of the java-mode defaults plus `java-font-lock-keywords-4'.")
1128 ;;;; Mode hook to setup syntax coloring.
1131 (defun jde-setup-syntax-coloring ()
1132 "Mode hook to setup syntax coloring in `java-mode' and `jde-mode'.
1133 When `jde-use-font-lock' is non-nil syntax coloring is always turned
1134 on and uses `java-font-lock-keywords-4' extra level of fontification.
1135 If `jde-use-font-lock' is nil syntax coloring rules are those of
1136 standard `java-mode'."
1137 (when (or (featurep 'xemacs) ; XEmacs and Emacs 21 support
1138 (> emacs-major-version 20) ; colors on ordinary terminal.
1139 window-system) ; Others only on `window-system'.
1140 ;; If `jde-use-font-lock' is non-nil setup
1141 ;; `java-font-lock-keywords-4' extra level of fontification.
1142 (when jde-use-font-lock
1143 ;; Setup `font-lock-defaults'
1144 (set (make-local-variable 'font-lock-defaults)
1145 jde-java-font-lock-defaults)
1146 ;; Use the maximum decoration available
1147 (set (make-local-variable 'font-lock-maximum-decoration) t)
1149 (set (make-local-variable 'font-lock-multiline) t)
1151 ;; Turn on Font Lock Mode as needed (based on parent `java-mode'
1152 ;; if `jde-use-font-lock' is nil).
1153 (let ((major-mode (if jde-use-font-lock major-mode 'java-mode)))
1154 (if (featurep 'xemacs)
1155 ;; The following is intended to avoid a byte-compilation warning
1156 ;; when compiling this file under Emacs. The Emacs version of
1157 ;; font-lock-set-defaults accepts no arguments.
1158 (apply 'font-lock-set-defaults (list t))
1159 (if global-font-lock-mode
1160 (turn-on-font-lock-if-enabled))))
1161 ;; Always turn on font locking if `jde-use-font-lock' is non-nil.
1162 (if jde-use-font-lock
1163 (turn-on-font-lock))))
1165 ;; By default, enable extra fontification in `jde-mode'.
1166 (add-hook 'jde-mode-hook #'jde-setup-syntax-coloring)
1168 (provide 'jde-java-font-lock)
1173 ;; $Log: jde-java-font-lock.el,v $
1174 ;; Revision 1.24 2005/04/07 05:54:29 paulk
1175 ;; Defines faces for public, private, and protected keywords. Thanks to Paul Landes.
1177 ;; Revision 1.23 2004/07/07 04:35:20 paulk
1178 ;; Made changes to eliminate byte-compilation warnings.
1180 ;; Revision 1.22 2004/05/28 04:34:18 paulk
1181 ;; Remove DOS line endings.
1183 ;; Revision 1.21 2004/05/14 04:03:27 paulk
1184 ;; Update to support c-doc-face-name if defined. Thanks to David Ponce.
1186 ;; Revision 1.20 2004/03/03 03:14:28 paulk
1187 ;; Fix bug that causes a (wrong-type-argument integerp nil) error when entering an import statement in a new Java file. Thanks to David Ponce.
1189 ;; Revision 1.19 2003/07/15 11:58:45 paulk
1192 ;; Revision 1.18 2003/07/06 13:42:01 paulk
1193 ;; As of version 5.30, cc-mode provides its own set of font lock keywords and faces for
1194 ;; Java: cc-fonts. The JDEE now uses cc-fonts if defined. Thanks to David Ponce.
1196 ;; Revision 1.17 2003/06/07 05:07:42 paulk
1197 ;; Fix a small bug in the JDEE font lock on XEmacs 21.4.11. Thanks to Andrew Kensler.
1199 ;; Revision 1.16 2003/02/07 00:38:10 jslopez
1200 ;; Adds assert as a keyword to be fortified.
1201 ;; Ideally we want the assert keyword fortified only when the user
1202 ;; is using jdk 1.4 but I don't know of a good way of enabling/disabling
1203 ;; fortifying a keyword based on another parameter. Since fortifying does
1204 ;; not cause any harm, I rather have it fortified always. This might prevent
1205 ;; users from using the assert keyword and causing them problem if they
1206 ;; want to upgrade to 1.4 and use assertions.
1208 ;; Revision 1.15 2002/09/16 04:42:54 paulk
1209 ;; XEmacs compatibility fix: added require statement for regexp-opt package.
1211 ;; Revision 1.14 2002/09/16 04:06:14 paulk
1212 ;; XEmacs compatibility fixes. Thanks to Andy Piper.
1214 ;; Revision 1.13 2002/06/23 17:38:28 jslopez
1215 ;; Removes carriage returns.
1217 ;; Revision 1.12 2002/06/22 06:29:32 paulk
1218 ;; Improves highlighting of multiline HTML tags in javadoc comments. Thanks to David Ponce.
1220 ;; Revision 1.11 2001/09/18 15:03:52 jslopez
1221 ;; Adding david's fixed for the make error.
1223 ;; Revision 1.10 2001/09/18 14:58:02 jslopez
1224 ;; reverted to 1.8 code
1226 ;; Revision 1.8 2001/09/16 17:55:37 paulk
1227 ;; This new version should be a little bit faster when byte compiled and
1228 ;; fixes the `font-lock-add-keywords' problem reported by Klaus Berndl
1229 ;; <klaus.berndl@sdm.de>. Thanks to David Ponce.
1231 ;; Revision 1.7 2001/08/06 05:32:20 paulk
1232 ;; New implementation of `jde-setup-syntax-coloring' as a
1233 ;; `java-mode-hook'.
1235 ;; - If `jde-use-font-lock' is non-nil the JDE completely handles font
1236 ;; lock setup (it turns on font locking in `java-mode' if needed) and
1237 ;; installs the extra level of fontification in
1238 ;; `java-font-lock-keywords-4'.
1240 ;; - If `jde-use-font-lock' is nil the JDE does nothing by itself (it
1241 ;; does not turn on font locking in `java-mode') and just delegates
1242 ;; syntax coloring setup to standard `java-mode'.
1244 ;; Revision 1.6 2001/06/05 04:54:49 paulk
1247 ;; Revision 1.5 2001/04/14 05:28:11 paulk
1248 ;; - All extra fontification added by jde-java-font-lock have a specific
1249 ;; face. So there is less font-lock implementation dependencies,
1250 ;; greater flexibility to setup a color theme, and fontification can be
1251 ;; kept consistent accross Emacs flavors :-) Notice that this change
1252 ;; may require to redo some face customization :(
1255 ;; - For convenience all specific jde-java-font-lock faces are in the
1256 ;; customization group `jde-java-font-lock-faces' which is a sub group
1257 ;; of `font-lock-highlighting-faces' (Emacs) or `font-lock-faces'
1261 ;; - Better fontification of numbers and imported package names.
1264 ;; - When used interactively the command
1265 ;; `jde-java-font-lock-setup-keywords' automatically update
1266 ;; fontification of all Java buffers. This is very useful when you
1267 ;; change your API file for example!
1270 ;; - The `jde-setup-syntax-coloring' is greatly enhanced. On Emacs, it
1271 ;; takes care of the current `global-font-lock-mode' setting. Also, it
1272 ;; no more use `font-lock-defaults-alist' (which is an obsolete
1273 ;; variable on Emacs 21) but the preferred `font-lock-defaults' way to
1274 ;; setup fontification.
1276 ;; - Finally, jde-java-font-lock works in java-mode too and it can be
1277 ;; used standalone if needed.
1279 ;; Contributed by David Ponce.
1281 ;; Revision 1.4 2001/01/17 18:59:03 paulk
1282 ;; Font-locking improvements from David Ponce
1284 ;; - You can now fontify user-defined identifiers with the new
1285 ;; jde-java-font-lock-api-face. These identifiers are read in the
1286 ;; file specified by the `jde-java-font-lock-api-file' option.
1288 ;; The JDE provides a default file "jde-java-font-lock.api" to fontify class
1289 ;; names of the core 'java' and 'javax' packages (JDK 1.3) and servlet
1290 ;; API (JSDK 2.0). To enable this fontification just put this file on
1291 ;; your home directory, maybe modify it to suit your needs and execute
1294 ;; M-x jde-java-font-lock-setup-keywords (or restart Emacs).
1296 ;; To improve reloading a cache file of regular expressions matching
1297 ;; these names is created in the same directory (see the source for
1300 ;; - Because the 'const' and 'goto' keywords are reserved, but not
1301 ;; currently used they are now fontified with `font-lock-warning-face'.
1303 ;; - The 'default' keyword is now fontified with
1304 ;; `font-lock-keyword-face'. This was suggested by Stephane Nicolas
1305 ;; s.nicolas@videotron.ca>.
1307 ;; Revision 1.3 2000/12/18 05:22:45 paulk
1308 ;; *** empty log message ***
1310 ;; Revision 1.2 2000/10/10 06:41:47 paulk
1311 ;; Fixed some XEmacs compatibility problems.
1313 ;; Revision 1.1 2000/10/08 12:53:22 paulk
1314 ;; Initial revision.
1317 ;;; jde-java-font-lock.el ends here