33 lines
2.7 KiB
JavaScript
33 lines
2.7 KiB
JavaScript
hljs.registerLanguage("java",function(){"use strict";function e(e){
|
|
return e?"string"==typeof e?e:e.source:null}function n(e){return a("(",e,")?")}
|
|
function a(...n){return n.map((n=>e(n))).join("")}function s(...n){
|
|
return"("+n.map((n=>e(n))).join("|")+")"}return function(e){
|
|
var r="false synchronized int abstract float private char boolean var static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports do",i={
|
|
className:"meta",begin:"@[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*",
|
|
contains:[{begin:/\(/,end:/\)/,contains:["self"]}]
|
|
},t=e=>a("[",e,"]+([",e,"_]*[",e,"]+)?"),c={className:"number",variants:[{
|
|
begin:`\\b(0[bB]${t("01")})[lL]?`},{begin:`\\b(0${t("0-7")})[dDfFlL]?`},{
|
|
begin:a(/\b0[xX]/,s(a(t("a-fA-F0-9"),/\./,t("a-fA-F0-9")),a(t("a-fA-F0-9"),/\.?/),a(/\./,t("a-fA-F0-9"))),/([pP][+-]?(\d+))?/,/[fFdDlL]?/)
|
|
},{begin:a(/\b/,s(a(/\d*\./,t("\\d")),t("\\d")),/[eE][+-]?[\d]+[dDfF]?/)},{
|
|
begin:a(/\b/,t(/\d/),n(/\.?/),n(t(/\d/)),/[dDfFlL]?/)}],relevance:0};return{
|
|
name:"Java",aliases:["jsp"],keywords:r,illegal:/<\/|#/,
|
|
contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,
|
|
relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]
|
|
}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{
|
|
className:"class",beginKeywords:"class interface enum",end:/[{;=]/,
|
|
excludeEnd:!0,keywords:"class interface enum",illegal:/[:"\[\]]/,contains:[{
|
|
beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{
|
|
beginKeywords:"new throw return else",relevance:0},{className:"class",
|
|
begin:"record\\s+"+e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,excludeEnd:!0,
|
|
end:/[{;=]/,keywords:r,contains:[{beginKeywords:"record"},{
|
|
begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,
|
|
contains:[e.UNDERSCORE_TITLE_MODE]},{className:"params",begin:/\(/,end:/\)/,
|
|
keywords:r,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE]
|
|
},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"function",
|
|
begin:"([\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*(<[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*(\\s*,\\s*[\xc0-\u02b8a-zA-Z_$][\xc0-\u02b8a-zA-Z_$0-9]*)*>)?\\s+)+"+e.UNDERSCORE_IDENT_RE+"\\s*\\(",
|
|
returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:r,contains:[{
|
|
begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,
|
|
contains:[e.UNDERSCORE_TITLE_MODE]},{className:"params",begin:/\(/,end:/\)/,
|
|
keywords:r,relevance:0,
|
|
contains:[i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE]
|
|
},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},c,i]}}}()); |