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