source: node_modules/highlight.js/lib/languages/aspectj.js@ e48199a

main
Last change on this file since e48199a was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/**
2 * @param {string} value
3 * @returns {RegExp}
4 * */
5
6/**
7 * @param {RegExp | string } re
8 * @returns {string}
9 */
10function source(re) {
11 if (!re) return null;
12 if (typeof re === "string") return re;
13
14 return re.source;
15}
16
17/**
18 * @param {...(RegExp | string) } args
19 * @returns {string}
20 */
21function concat(...args) {
22 const joined = args.map((x) => source(x)).join("");
23 return joined;
24}
25
26/*
27Language: AspectJ
28Author: Hakan Ozler <ozler.hakan@gmail.com>
29Website: https://www.eclipse.org/aspectj/
30Description: Syntax Highlighting for the AspectJ Language which is a general-purpose aspect-oriented extension to the Java programming language.
31Audit: 2020
32*/
33
34/** @type LanguageFn */
35function aspectj(hljs) {
36 const KEYWORDS =
37 'false synchronized int abstract float private char boolean static null if const ' +
38 'for true while long throw strictfp finally protected import native final return void ' +
39 'enum else extends implements break transient new catch instanceof byte super volatile case ' +
40 'assert short package default double public try this switch continue throws privileged ' +
41 'aspectOf adviceexecution proceed cflowbelow cflow initialization preinitialization ' +
42 'staticinitialization withincode target within execution getWithinTypeName handler ' +
43 'thisJoinPoint thisJoinPointStaticPart thisEnclosingJoinPointStaticPart declare parents ' +
44 'warning error soft precedence thisAspectInstance';
45 const SHORTKEYS = 'get set args call';
46
47 return {
48 name: 'AspectJ',
49 keywords: KEYWORDS,
50 illegal: /<\/|#/,
51 contains: [
52 hljs.COMMENT(
53 /\/\*\*/,
54 /\*\//,
55 {
56 relevance: 0,
57 contains: [
58 {
59 // eat up @'s in emails to prevent them to be recognized as doctags
60 begin: /\w+@/,
61 relevance: 0
62 },
63 {
64 className: 'doctag',
65 begin: /@[A-Za-z]+/
66 }
67 ]
68 }
69 ),
70 hljs.C_LINE_COMMENT_MODE,
71 hljs.C_BLOCK_COMMENT_MODE,
72 hljs.APOS_STRING_MODE,
73 hljs.QUOTE_STRING_MODE,
74 {
75 className: 'class',
76 beginKeywords: 'aspect',
77 end: /[{;=]/,
78 excludeEnd: true,
79 illegal: /[:;"\[\]]/,
80 contains: [
81 {
82 beginKeywords: 'extends implements pertypewithin perthis pertarget percflowbelow percflow issingleton'
83 },
84 hljs.UNDERSCORE_TITLE_MODE,
85 {
86 begin: /\([^\)]*/,
87 end: /[)]+/,
88 keywords: KEYWORDS + ' ' + SHORTKEYS,
89 excludeEnd: false
90 }
91 ]
92 },
93 {
94 className: 'class',
95 beginKeywords: 'class interface',
96 end: /[{;=]/,
97 excludeEnd: true,
98 relevance: 0,
99 keywords: 'class interface',
100 illegal: /[:"\[\]]/,
101 contains: [
102 {
103 beginKeywords: 'extends implements'
104 },
105 hljs.UNDERSCORE_TITLE_MODE
106 ]
107 },
108 {
109 // AspectJ Constructs
110 beginKeywords: 'pointcut after before around throwing returning',
111 end: /[)]/,
112 excludeEnd: false,
113 illegal: /["\[\]]/,
114 contains: [
115 {
116 begin: concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/),
117 returnBegin: true,
118 contains: [ hljs.UNDERSCORE_TITLE_MODE ]
119 }
120 ]
121 },
122 {
123 begin: /[:]/,
124 returnBegin: true,
125 end: /[{;]/,
126 relevance: 0,
127 excludeEnd: false,
128 keywords: KEYWORDS,
129 illegal: /["\[\]]/,
130 contains: [
131 {
132 begin: concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/),
133 keywords: KEYWORDS + ' ' + SHORTKEYS,
134 relevance: 0
135 },
136 hljs.QUOTE_STRING_MODE
137 ]
138 },
139 {
140 // this prevents 'new Name(...), or throw ...' from being recognized as a function definition
141 beginKeywords: 'new throw',
142 relevance: 0
143 },
144 {
145 // the function class is a bit different for AspectJ compared to the Java language
146 className: 'function',
147 begin: /\w+ +\w+(\.\w+)?\s*\([^\)]*\)\s*((throws)[\w\s,]+)?[\{;]/,
148 returnBegin: true,
149 end: /[{;=]/,
150 keywords: KEYWORDS,
151 excludeEnd: true,
152 contains: [
153 {
154 begin: concat(hljs.UNDERSCORE_IDENT_RE, /\s*\(/),
155 returnBegin: true,
156 relevance: 0,
157 contains: [ hljs.UNDERSCORE_TITLE_MODE ]
158 },
159 {
160 className: 'params',
161 begin: /\(/,
162 end: /\)/,
163 relevance: 0,
164 keywords: KEYWORDS,
165 contains: [
166 hljs.APOS_STRING_MODE,
167 hljs.QUOTE_STRING_MODE,
168 hljs.C_NUMBER_MODE,
169 hljs.C_BLOCK_COMMENT_MODE
170 ]
171 },
172 hljs.C_LINE_COMMENT_MODE,
173 hljs.C_BLOCK_COMMENT_MODE
174 ]
175 },
176 hljs.C_NUMBER_MODE,
177 {
178 // annotation is also used in this language
179 className: 'meta',
180 begin: /@[A-Za-z]+/
181 }
182 ]
183 };
184}
185
186module.exports = aspectj;
Note: See TracBrowser for help on using the repository browser.