aspectj.js 4.6 KB

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