source: node_modules/refractor/lang/javastacktrace.js

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

Initial commit

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