diff options
author | Alan Mackenzie <acm@muc.de> | 2010-07-31 20:01:08 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2010-07-31 20:01:08 +0000 |
commit | 452ea85502011e18e4b290fbcb4fe461ab6aace9 (patch) | |
tree | 128bd2eda1152cb4b0dbba1b241c266f453e4ba9 /lisp/progmodes/cc-langs.el | |
parent | 3776670694ae5034dd68cce55b75f927768d4911 (diff) | |
download | emacs-452ea85502011e18e4b290fbcb4fe461ab6aace9.tar.gz |
Enhance Java Mode to handle Java 5.0 (Tiger) and Java 6 (Mustang).
Contributed by Nathaniel Flath.
Diffstat (limited to 'lisp/progmodes/cc-langs.el')
-rw-r--r-- | lisp/progmodes/cc-langs.el | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index d3669f259de..ae0ed1b928a 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el @@ -359,7 +359,7 @@ The syntax tables aren't stored directly since they're quite large." (let ((table (make-syntax-table))) (c-populate-syntax-table table) ;; Mode specific syntaxes. - ,(cond ((c-major-mode-is 'objc-mode) + ,(cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode)) ;; Let '@' be part of symbols in ObjC to cope with ;; its compiler directives as single keyword tokens. ;; This is then necessary since it's assumed that @@ -382,7 +382,7 @@ The syntax tables aren't stored directly since they're quite large." ;; '<' and '>' characters. Therefore this syntax table might go ;; away when CC Mode handles templates correctly everywhere. t nil - c++ `(lambda () + (java c++) `(lambda () (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table)))) (modify-syntax-entry ?< "(>" table) (modify-syntax-entry ?> ")<" table) @@ -425,7 +425,7 @@ the new syntax, as accepted by `modify-syntax-entry'." ;; it as an indentifier character since it's often used in various ;; machine generated identifiers. t '((?_ . "w") (?$ . "w")) - objc (append '((?@ . "w")) + (objc java) (append '((?@ . "w")) (c-lang-const c-identifier-syntax-modifications)) awk '((?_ . "w"))) (c-lang-defvar c-identifier-syntax-modifications @@ -502,9 +502,10 @@ parameters \(point-min), \(point-max) and <buffer size>." (c-lang-defconst c-symbol-start "Regexp that matches the start of a symbol, i.e. any identifier or -keyword. It's unspecified how far it matches. Does not contain a \\| +keyword. It's unspecified how far it matches. Does not contain a \\| operator at the top level." t (concat "[" c-alpha "_]") + java (concat "[" c-alpha "_@]") objc (concat "[" c-alpha "@]") pike (concat "[" c-alpha "_`]")) (c-lang-defvar c-symbol-start (c-lang-const c-symbol-start)) @@ -859,7 +860,7 @@ since CC Mode treats every identifier as an expression." ;; Primary. ,@(c-lang-const c-identifier-ops) - ,@(cond ((c-major-mode-is 'c++-mode) + ,@(cond ((or (c-major-mode-is 'c++-mode) (c-major-mode-is 'java-mode)) `((postfix-if-paren "<" ">"))) ; Templates. ((c-major-mode-is 'pike-mode) `((prefix "global" "predef"))) @@ -1118,6 +1119,7 @@ operators." t "\\`<." (lambda (op) (substring op 1))))) + (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp)) (c-lang-defconst c->-op-cont-regexp @@ -1127,7 +1129,13 @@ operators." (c-filter-ops (c-lang-const c-all-op-syntax-tokens) t "\\`>." - (lambda (op) (substring op 1))))) + (lambda (op) (substring op 1)))) + java (c-make-keywords-re nil + (c-filter-ops (c-lang-const c-all-op-syntax-tokens) + t + "\\`>[^>]\\|\\`>>[^>]" + (lambda (op) (substring op 1))))) + (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp)) (c-lang-defconst c-stmt-delim-chars @@ -1628,7 +1636,7 @@ following identifier as a type; the keyword must also be present on c++ '("class" "struct" "union") objc '("struct" "union" "@interface" "@implementation" "@protocol") - java '("class" "interface") + java '("class" "@interface" "interface") idl '("component" "eventtype" "exception" "home" "interface" "struct" "union" "valuetype" ;; In CORBA PSDL: @@ -1651,7 +1659,7 @@ If any of these also are on `c-type-list-kwds', `c-ref-list-kwds', `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses will be handled." t '("enum") - (java awk) nil) + (awk) nil) (c-lang-defconst c-brace-list-key ;; Regexp matching the start of declarations where the following @@ -1772,7 +1780,7 @@ will be handled." "bindsTo" "delegatesTo" "implements" "proxy" "storedOn") ;; Note: "const" is not used in Java, but it's still a reserved keyword. java '("abstract" "const" "final" "native" "private" "protected" "public" - "static" "strictfp" "synchronized" "transient" "volatile") + "static" "strictfp" "synchronized" "transient" "volatile" "@[A-Za-z0-9]+") pike '("final" "inline" "local" "nomask" "optional" "private" "protected" "public" "static" "variant")) @@ -1858,7 +1866,11 @@ one of `c-type-list-kwds', `c-ref-list-kwds', (c-lang-defconst c-prefix-spec-kwds-re ;; Adorned regexp of `c-prefix-spec-kwds'. - t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds))) + t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds)) + java (replace-regexp-in-string + "\\\\\\[" "[" + (replace-regexp-in-string "\\\\\\+" "+" (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds))))) + (c-lang-defvar c-prefix-spec-kwds-re (c-lang-const c-prefix-spec-kwds-re)) (c-lang-defconst c-specifier-key @@ -1950,7 +1962,7 @@ or variable identifier (that's being defined)." t nil c++ '("operator") objc '("@class") - java '("import" "new" "extends" "implements" "throws") + java '("import" "new" "extends" "super" "implements" "throws") idl '("manages" "native" "primarykey" "supports" ;; In CORBA PSDL: "as" "implements" "of" "scope") @@ -2499,7 +2511,7 @@ more info." ;; in all languages except Java for when a cpp macro definition ;; begins with a declaration. t "\\([\{\}\(\);,]+\\)" - java "\\([\{\}\(;,]+\\)" + java "\\([\{\}\(;,<]+\\)" ;; Match "<" in C++ to get the first argument in a template arglist. ;; In that case there's an additional check in `c-find-decl-spots' ;; that it got open paren syntax. @@ -2759,7 +2771,7 @@ It's undefined whether identifier syntax (see `c-identifier-syntax-table') is in effect or not." t nil (c c++ objc pike) "\\(\\.\\.\\.\\)" - java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\)")) + java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\|\\.\\.\\.\\)")) (c-lang-defvar c-opt-type-suffix-key (c-lang-const c-opt-type-suffix-key)) (c-lang-defvar c-known-type-key |