prism-javastacktrace.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // Specification:
  2. // https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/Throwable.html#printStackTrace()
  3. Prism.languages.javastacktrace = {
  4. // java.sql.SQLException: Violation of unique constraint MY_ENTITY_UK_1: duplicate value(s) for column(s) MY_COLUMN in statement [...]
  5. // Caused by: java.sql.SQLException: Violation of unique constraint MY_ENTITY_UK_1: duplicate value(s) for column(s) MY_COLUMN in statement [...]
  6. // Caused by: com.example.myproject.MyProjectServletException
  7. // Caused by: MidLevelException: LowLevelException
  8. // Suppressed: Resource$CloseFailException: Resource ID = 0
  9. 'summary': {
  10. pattern: /^([\t ]*)(?:(?:Caused by:|Suppressed:|Exception in thread "[^"]*")[\t ]+)?[\w$.]+(?::.*)?$/m,
  11. lookbehind: true,
  12. inside: {
  13. 'keyword': {
  14. pattern: /^([\t ]*)(?:(?:Caused by|Suppressed)(?=:)|Exception in thread)/m,
  15. lookbehind: true
  16. },
  17. // the current thread if the summary starts with 'Exception in thread'
  18. 'string': {
  19. pattern: /^(\s*)"[^"]*"/,
  20. lookbehind: true
  21. },
  22. 'exceptions': {
  23. pattern: /^(:?\s*)[\w$.]+(?=:|$)/,
  24. lookbehind: true,
  25. inside: {
  26. 'class-name': /[\w$]+$/,
  27. 'namespace': /\b[a-z]\w*\b/,
  28. 'punctuation': /\./
  29. }
  30. },
  31. 'message': {
  32. pattern: /(:\s*)\S.*/,
  33. lookbehind: true,
  34. alias: 'string'
  35. },
  36. 'punctuation': /:/
  37. }
  38. },
  39. // at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
  40. // at org.hsqldb.jdbc.Util.throwError(Unknown Source) here could be some notes
  41. // at java.base/java.lang.Class.forName0(Native Method)
  42. // at Util.<init>(Unknown Source)
  43. // at com.foo.loader/foo@9.0/com.foo.Main.run(Main.java:101)
  44. // at com.foo.loader//com.foo.bar.App.run(App.java:12)
  45. // at acme@2.1/org.acme.Lib.test(Lib.java:80)
  46. // at MyClass.mash(MyClass.java:9)
  47. //
  48. // More information:
  49. // https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/StackTraceElement.html#toString()
  50. //
  51. // A valid Java module name is defined as:
  52. // "A module name consists of one or more Java identifiers (§3.8) separated by "." tokens."
  53. // https://docs.oracle.com/javase/specs/jls/se9/html/jls-6.html#jls-ModuleName
  54. //
  55. // A Java module version is defined by this class:
  56. // https://docs.oracle.com/javase/9/docs/api/java/lang/module/ModuleDescriptor.Version.html
  57. // This is the implementation of the `parse` method in JDK13:
  58. // https://github.com/matcdac/jdk/blob/2305df71d1b7710266ae0956d73927a225132c0f/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java#L1108
  59. // However, to keep this simple, a version will be matched by the pattern /@[\w$.+-]*/.
  60. 'stack-frame': {
  61. pattern: /^([\t ]*)at (?:[\w$./]|@[\w$.+-]*\/)+(?:<init>)?\([^()]*\)/m,
  62. lookbehind: true,
  63. inside: {
  64. 'keyword': {
  65. pattern: /^(\s*)at(?= )/,
  66. lookbehind: true
  67. },
  68. 'source': [
  69. // (Main.java:15)
  70. // (Main.scala:15)
  71. {
  72. pattern: /(\()\w+\.\w+:\d+(?=\))/,
  73. lookbehind: true,
  74. inside: {
  75. 'file': /^\w+\.\w+/,
  76. 'punctuation': /:/,
  77. 'line-number': {
  78. pattern: /\b\d+\b/,
  79. alias: 'number'
  80. }
  81. }
  82. },
  83. // (Unknown Source)
  84. // (Native Method)
  85. // (...something...)
  86. {
  87. pattern: /(\()[^()]*(?=\))/,
  88. lookbehind: true,
  89. inside: {
  90. 'keyword': /^(?:Native Method|Unknown Source)$/
  91. }
  92. }
  93. ],
  94. 'class-name': /[\w$]+(?=\.(?:<init>|[\w$]+)\()/,
  95. 'function': /(?:<init>|[\w$]+)(?=\()/,
  96. 'class-loader': {
  97. pattern: /(\s)[a-z]\w*(?:\.[a-z]\w*)*(?=\/[\w@$.]*\/)/,
  98. lookbehind: true,
  99. alias: 'namespace',
  100. inside: {
  101. 'punctuation': /\./
  102. }
  103. },
  104. 'module': {
  105. pattern: /([\s/])[a-z]\w*(?:\.[a-z]\w*)*(?:@[\w$.+-]*)?(?=\/)/,
  106. lookbehind: true,
  107. inside: {
  108. 'version': {
  109. pattern: /(@)[\s\S]+/,
  110. lookbehind: true,
  111. alias: 'number'
  112. },
  113. 'punctuation': /[@.]/
  114. }
  115. },
  116. 'namespace': {
  117. pattern: /(?:\b[a-z]\w*\.)+/,
  118. inside: {
  119. 'punctuation': /\./
  120. }
  121. },
  122. 'punctuation': /[()/.]/
  123. }
  124. },
  125. // ... 32 more
  126. // ... 32 common frames omitted
  127. 'more': {
  128. pattern: /^([\t ]*)\.{3} \d+ [a-z]+(?: [a-z]+)*/m,
  129. lookbehind: true,
  130. inside: {
  131. 'punctuation': /\.{3}/,
  132. 'number': /\d+/,
  133. 'keyword': /\b[a-z]+(?: [a-z]+)*\b/
  134. }
  135. }
  136. };