|  | 
| 2 | 2 | 
 | 
| 3 | 3 | 	var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/; | 
| 4 | 4 | 
 | 
|  | 5 | +	// full package (optional) + parent classes (optional) | 
|  | 6 | +	var classNamePrefix = /(^|[^\w.])(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source; | 
|  | 7 | + | 
| 5 | 8 | 	// based on the java naming conventions | 
| 6 |  | -	var className = /\b[A-Z](?:\w*[a-z]\w*)?\b/; | 
|  | 9 | +	var className = { | 
|  | 10 | +		pattern: RegExp(classNamePrefix + /[A-Z](?:\w*[a-z]\w*)?\b/.source), | 
|  | 11 | +		lookbehind: true, | 
|  | 12 | +		inside: { | 
|  | 13 | +			'namespace': { | 
|  | 14 | +				pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/, | 
|  | 15 | +				inside: { | 
|  | 16 | +					'punctuation': /\./ | 
|  | 17 | +				} | 
|  | 18 | +			}, | 
|  | 19 | +			'punctuation': /\./ | 
|  | 20 | +		} | 
|  | 21 | +	}; | 
| 7 | 22 | 
 | 
| 8 | 23 | 	Prism.languages.java = Prism.languages.extend('clike', { | 
| 9 | 24 | 		'class-name': [ | 
| 10 | 25 | 			className, | 
| 11 |  | - | 
| 12 |  | -			// variables and parameters | 
| 13 |  | -			// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods) | 
| 14 |  | -			/\b[A-Z]\w*(?=\s+\w+\s*[;,=())])/ | 
|  | 26 | +			{ | 
|  | 27 | +				// variables and parameters | 
|  | 28 | +				// this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods) | 
|  | 29 | +				pattern: RegExp(classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=())])/.source), | 
|  | 30 | +				lookbehind: true, | 
|  | 31 | +				inside: className.inside | 
|  | 32 | +			} | 
| 15 | 33 | 		], | 
| 16 | 34 | 		'keyword': keywords, | 
| 17 | 35 | 		'function': [ | 
| 18 | 36 | 			Prism.languages.clike.function, | 
| 19 | 37 | 			{ | 
| 20 |  | -				pattern: /(\:\:)[a-z_]\w*/, | 
|  | 38 | +				pattern: /(\:\:\s*)[a-z_]\w*/, | 
| 21 | 39 | 				lookbehind: true | 
| 22 | 40 | 			} | 
| 23 | 41 | 		], | 
|  | 
| 39 | 57 | 
 | 
| 40 | 58 | 	Prism.languages.insertBefore('java', 'class-name', { | 
| 41 | 59 | 		'annotation': { | 
| 42 |  | -			alias: 'punctuation', | 
| 43 |  | -			pattern: /(^|[^.])@\w+/, | 
| 44 |  | -			lookbehind: true | 
| 45 |  | -		}, | 
| 46 |  | -		'namespace': { | 
| 47 |  | -			pattern: RegExp( | 
| 48 |  | -				/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/ | 
| 49 |  | -					.source.replace(/<keyword>/g, function () { return keywords.source; })), | 
|  | 60 | +			pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/, | 
| 50 | 61 | 			lookbehind: true, | 
| 51 |  | -			inside: { | 
| 52 |  | -				'punctuation': /\./, | 
| 53 |  | -			} | 
|  | 62 | +			alias: 'punctuation' | 
| 54 | 63 | 		}, | 
| 55 | 64 | 		'generics': { | 
| 56 | 65 | 			pattern: /<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<(?:[\w\s,.&?]|<[\w\s,.&?]*>)*>)*>)*>/, | 
|  | 
| 60 | 69 | 				'punctuation': /[<>(),.:]/, | 
| 61 | 70 | 				'operator': /[?&|]/ | 
| 62 | 71 | 			} | 
|  | 72 | +		}, | 
|  | 73 | +		'namespace': { | 
|  | 74 | +			pattern: RegExp( | 
|  | 75 | +				/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/ | 
|  | 76 | +					.source.replace(/<keyword>/g, function () { return keywords.source; })), | 
|  | 77 | +			lookbehind: true, | 
|  | 78 | +			inside: { | 
|  | 79 | +				'punctuation': /\./, | 
|  | 80 | +			} | 
| 63 | 81 | 		} | 
| 64 | 82 | 	}); | 
| 65 | 83 | }(Prism)); | 
0 commit comments