;;; Java highlighting package

;; Colors suit a black background with white letters.

;; Notice that the first pattern to match overrides the last.

(hilit-set-mode-patterns
   'java-mode
    '(
      ;; red flags
      ("\\<\\(XXX\\|xxx\\|TODO\\)\\>" nil red) 

      ;; @param tag followed by something that shouldn't be a variable
("\\@param[ \t]+\\([A-Z]\\|the\\|a \\|true\\|false\\)" 
       nil red)
      ;; javadoc tags (with args)
("\\@\\(link\\|since\\|see\\|param\\|exception\\|throws\\)[ \t]+[^ \t]+\\>" 
       nil cyan)
      ;; javadoc tags and annotations (without args)
("\\@\\(serial[a-zA-Z]*\\|version\\|code\\|inheritDoc\\|author\\|return\\|[dD]eprecated\\|Override\\|SuppressWarnings\\)\\>" 
       nil cyan)
      ;; bogus tag
      ("\\@[a-zA-Z0-9]*\\>" 
       nil red)

      ;; comments - do the javadoc ones differently
      ("/\\*\\*" "\\*/" lightgreen)
      ("/\\*" "\\*/" orange)
      ("//.*$" nil orange)

      ;; forgot type in declaration
("^[ \t]*\\(\\(static\\|final\\)[ \t]+\\)?\\(public\\|private\\|protected\\)[ \t]+[^A-Z \t][^ \t]+[ \t]*("
       nil red)

      ;; The toplevel stuff
      ("^\\(import\\|package\\|{\\|}\\).*$" 
       nil green)
      ;; three words at beginning of line, starting with "public"
      ;; four words if second word is "static"
   ("^[ \t]*public[ \t]+\\(static[ \t]+\\)?[^ \t(]*[ \t]+[^ \t(]*" nil green)
      ;; ctor
   ("^[ \t]*public[ \t]+\\(static[ \t]+\\)?[^ \t(]*" nil green)

      ;; strings
      (hilit-string-find ?' moccasin)

      ;; toplevel stuff at a lower level place
      ("[^_]\\<\\(import\\|package\\)\\>[^_]" 
       nil red)

      ;; wrong order
      ("\\(static\\|final\\|volatile\\)[ \t]+\\(public\\|private\\|protected\\)"
       nil red)

      ;; member variables
      ("[^a-zA-Z0-9_]\\([scfmk]?_[a-z][a-zA-Z_0-9]*\\)\\>"
       nil gray80)

      ;; keywords should not be followed immediately by parenthesis or brace
      ("\\<\\(abstract\\|assert\\|boolean\\|break\\|byte\\|case\\|catch\\|char\\|class\\|const\\|continue\\|default\\|do\\|double\\|else\\|enum\\|extends\\|final\\|finally\\|float\\|for\\|goto\\|if\\|implements\\|import\\|instanceof\\|int\\|interface\\|long\\|native\\|new\\|package\\|private\\|protected\\|public\\|return\\|short\\|static\\|strictfp\\|super\\|switch\\|synchronized\\|this\\|throw\\|throws\\|transient\\|try\\|void\\|volatile\\|while\\)[({]"
       0 red)

       ;; don't follow closing parenthesis by opening brace without a space
      ("[)][{]" nil red)

      ;; key words
      ("\\<\\(abstract\\|assert\\|boolean\\|break\\|byte\\|case\\|catch\\|char\\|class\\|const\\|continue\\|default\\|do\\|double\\|else\\|enum\\|extends\\|final\\|finally\\|float\\|for\\|goto\\|if\\|implements\\|import\\|instanceof\\|int\\|interface\\|long\\|native\\|new\\|package\\|private\\|protected\\|public\\|return\\|short\\|static\\|strictfp\\|super\\|switch\\|synchronized\\|this\\|throw\\|throws\\|transient\\|try\\|void\\|volatile\\|while\\)\\>"
       0 cyan)

      ;; standard data values - null, true, false and any ASCII char
      ("[ \n\t(),=.{]\\('..'\\|'.'\\)[ \n\t):;,!=.]" 
       nil gray80)
      ("\\<\\(null\\|true\\|false\\)\\>" 
       nil gray80)

      ;; primitive types 
      ("[^_]\\<\\(float\\|double\\|void\\|boolean\\|char\\|byte\\|short\\|int\\|long\\)\\>[^_]" 
       nil yellow)

      ;; Objects/Class names
      ("\\<\\([A-Z][a-zA-Z0-9]+\\.?\\)+\\>" 
       nil yellow)

    )
)

;;
