aspectj.js 4.5 KB

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