Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsstacktrace: add language #2418

Merged
merged 23 commits into from Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e85126a
jsstacktrace: add language
sbrl Jun 9, 2020
cf6008e
jsstacktrace: apply suggestions
sbrl Jun 11, 2020
5c0c5f3
jsstacktrace: fox typo in examples filename
sbrl Jun 15, 2020
0d18d35
jsstacktrace: only use \s in inside patterns
sbrl Jun 15, 2020
f8ef8e9
jsstacktrace: remove $ from the end of multiline regexes
sbrl Jun 15, 2020
474f1cf
jsstacktrace: fix matching of function names
sbrl Jun 15, 2020
f066717
jsstacktrace: add inside regex to make dots in function names be puct…
sbrl Jun 15, 2020
87caf37
jsstacktrace: match brackets () as punctuation
sbrl Jun 15, 2020
6b0d387
jsstacktrace: update alias pattern matching
sbrl Jun 15, 2020
91cd2b4
jsstacktrace: update filename matching
sbrl Jun 15, 2020
7ec5cc2
jsstacktrace: also match <> in function names because of foo.<anonymous>
sbrl Jun 15, 2020
69d99a9
jsstacktrace: fix tests
sbrl Jun 15, 2020
f598280
jsstacktrace: remove typo i flag
sbrl Jun 15, 2020
75e2ed7
jsstacktrace: move not-my-code into stack-trace & fix windows support…
sbrl Jun 15, 2020
4420432
jsstacktrace: update build
sbrl Jun 15, 2020
afcf9f9
Update components/prism-jsstacktrace.js
sbrl Jun 16, 2020
d0ba10a
Update components/prism-jsstacktrace.js
sbrl Jun 16, 2020
d75fa62
jsstacktrace: remove commented code
sbrl Jun 16, 2020
e4748b7
Merge branch 'feature/language-jsstacktrace' of github.com:sbrl/prism…
sbrl Jun 16, 2020
a415f9c
jsstacktrace: fix components.json
sbrl Jun 16, 2020
babb7f3
jsstacktrace: fix tests
sbrl Jun 16, 2020
08758d7
jsstacktrace: really fix tests..... again
sbrl Jun 16, 2020
52cef33
jsstacktrace: rebuild
sbrl Jun 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Expand Up @@ -548,6 +548,10 @@
],
"owner": "RunDevelopment"
},
"jsstacktrace": {
"title": "JS stack trace",
"owner": "sbrl"
},
"js-templates": {
"title": "JS Templates",
"require": "javascript",
Expand Down
48 changes: 48 additions & 0 deletions components/prism-jsstacktrace.js
@@ -0,0 +1,48 @@
Prism.languages.jsstacktrace = {
'error-message': {
pattern: /^\S.*/m,
alias: 'string'
},

'stack-frame': {
pattern: /^[ \t]+at[ \t]+.*/m,
inside: {
'not-my-code': {
pattern: /[ \t]+at[ \t]+(?:node\.js|\<unknown\>|.*(?:node_modules|\(\<anonymous\>\)|\(\<unknown\>|\<anonymous\>$|\(internal\/|\(node\.js)).*/m,
alias: 'comment'
},

'filename': {
pattern: /(\bat\s+|\()(?:[a-zA-Z]:)?[^():]+(?=:)/,
lookbehind: true,
alias: 'url'
},

'function': {
pattern: /(at\s+(?:new\s+)?)[_$a-zA-Z\xA0-\uFFFF<][.$\w\xA0-\uFFFF<>]*/,
lookbehind: true,
inside: {
'punctuation': /\./
}
},

'punctuation': /[()]/,

'keyword': /\b(?:at|new)\b/,

'alias': {
pattern: /\[(?:as\s+)?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\]/,
alias: 'variable'
},

'line-number': {
pattern: /:[0-9]+(?::[0-9]+)?\b/,
alias: 'number',
inside: {
'punctuation': /:/
}
},

}
}
}
1 change: 1 addition & 0 deletions components/prism-jsstacktrace.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 99 additions & 0 deletions examples/prism-jsstacktrace.html
@@ -0,0 +1,99 @@
<h2>Full example</h2>
<pre><code>(node:40780) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.
at Buffer (buffer.js:79:13)
at repl:1:1
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:96:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:313:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.onLine (repl.js:513:10)
at emitOne (events.js:101:20)

Error: custom error
at Server.&lt;anonymous&gt; (/trace/showcases/http.js:4:9)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)
at new &lt;anonymous&gt; (_http_common.js:159:16)
at exports.FreeList.alloc (internal/freelist.js:14:46)
at Server.connectionListener (_http_server.js:316:24)
at emitOne (events.js:96:13)
at Server.emit (events.js:188:7)
at TCP.onconnection (net.js:1460:8)
at createServerHandle (net.js:1181:14)
at Server._listen2 (net.js:1225:14)
at listen (net.js:1290:10)
at Server.listen (net.js:1386:5)
at Object.&lt;anonymous&gt; (/trace/showcases/http.js:5:4)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (bootstrap_node.js:340:7)
at startup (bootstrap_node.js:132:9)
at bootstrap_node.js:455:3


Error: custom error
at /trace/showcases/basic.js:7:13
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
at InternalFieldObject.ondone (/trace/showcases/basic.js:6:13)
at /trace/showcases/basic.js:5:10
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)
at ReadFileContext.close (fs.js:358:11)
at FSReqWrap.readFileAfterRead [as oncomplete] (fs.js:414:15)
at ReadFileContext.read (fs.js:342:11)
at FSReqWrap.readFileAfterStat [as oncomplete] (fs.js:398:11)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:374:11)
at Object.fs.readFile (fs.js:303:11)
at Object.&lt;anonymous&gt; (/trace/showcases/basic.js:4:4)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (bootstrap_node.js:340:7)
at startup (bootstrap_node.js:132:9)
at bootstrap_node.js:455:3


BulkWriteError: E11000 duplicate key error collection: test.test index: _id_ dup key: { : 1 }
at OrderedBulkOperation.handleWriteError (/workspace/node_modules/mongodb/lib/bulk/common.js:1048:11)
at resultHandler (/workspace/node_modules/mongodb/lib/bulk/ordered.js:159:23)
at /workspace/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:532:18
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)

Error
at Collection.(anonymous function) [as insertMany] (/workspace/node_modules/monogram/lib/collection.js:80:21)
at insert (/workspace/test.js:14:31)
at run (/workspace/test.js:9:9)
at &lt;anonymous&gt;
at process._tickCallback (internal/process/next_tick.js:188:7)

Error
at Collection.(anonymous function) [as insertMany] (/workspace/node_modules/monogram/lib/collection.js:80:21)
at insert (/workspace/test.js:15:31)
at processTicksAndRejections (internal/process/next_tick.js:81:5)


Deno:

Error: Some error
at throwsA (&lt;unknown&gt;:1:23)
at &lt;unknown&gt;:1:13
at evaluate ($deno$/repl.ts:64:34)
at Object.replLoop ($deno$/repl.ts:153:13)

Uncaught NotFound: No such file or directory (os error 2)
at DenoError (deno/js/errors.ts:22:5)
at maybeError (deno/js/errors.ts:41:12)
at handleAsyncMsgFromRust (deno/js/dispatch.ts:27:17)
</code></pre>
1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -93,6 +93,7 @@
"webmanifest": "Web App Manifest",
"jsonp": "JSONP",
"json5": "JSON5",
"jsstacktrace": "Javascript stack trace",
"latex": "LaTeX",
"tex": "TeX",
"context": "ConTeXt",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/languages/jsstacktrace/errormessage-nodejs_feature.test
@@ -0,0 +1,11 @@
(node:16843) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'tick' of undefined

----------------------------------------------------

[
["error-message", "(node:16843) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'tick' of undefined"]
]

----------------------------------------------------

Checks basic a basic error message.
11 changes: 11 additions & 0 deletions tests/languages/jsstacktrace/errormessage_feature.test
@@ -0,0 +1,11 @@
Some text

----------------------------------------------------

[
["error-message", "Some text"]
]

----------------------------------------------------

Checks basic a basic error message.
30 changes: 30 additions & 0 deletions tests/languages/jsstacktrace/filename_feature.test
@@ -0,0 +1,30 @@
Some text
at (foo/bar.baz:123:98)

----------------------------------------------------

[
["error-message", "Some text"],
[
"stack-frame",
[
["keyword", "at"],
["punctuation", "("],
["filename", "foo/bar.baz"],
[
"line-number",
[
["punctuation", ":"],
"123",
["punctuation", ":"],
"98"
]
],
["punctuation", ")"]
]
]
]

----------------------------------------------------

Checks basic a basic error message.
28 changes: 28 additions & 0 deletions tests/languages/jsstacktrace/filenamedirect_feature.test
@@ -0,0 +1,28 @@
Some text
at /foo/bar.baz:123:98

----------------------------------------------------

[
["error-message", "Some text"],
[
"stack-frame",
[
["keyword", "at"],
["filename", "/foo/bar.baz"],
[
"line-number",
[
["punctuation", ":"],
"123",
["punctuation", ":"],
"98"
]
]
]
]
]

----------------------------------------------------

Checks basic a basic error message.
28 changes: 28 additions & 0 deletions tests/languages/jsstacktrace/filenamedirectwindows_feature.test
@@ -0,0 +1,28 @@
Some text
at C:\foo\bar.baz:123:98

----------------------------------------------------

[
["error-message", "Some text"],
[
"stack-frame",
[
["keyword", "at"],
["filename", "C:\\foo\\bar.baz"],
[
"line-number",
[
["punctuation", ":"],
"123",
["punctuation", ":"],
"98"
]
]
]
]
]

----------------------------------------------------

Checks basic a basic error message.
26 changes: 26 additions & 0 deletions tests/languages/jsstacktrace/function_feature.test
@@ -0,0 +1,26 @@
Some text
at foo.bar

----------------------------------------------------

[
["error-message", "Some text"],
[
"stack-frame",
[
["keyword", "at"],
[
"function",
[
"foo",
[ "punctuation", "." ],
"bar"
]
]
]
]
]

----------------------------------------------------

Checks basic a basic error message.
29 changes: 29 additions & 0 deletions tests/languages/jsstacktrace/linenumber_feature.test
@@ -0,0 +1,29 @@
Some text
at :98:32

----------------------------------------------------

[
["error-message", "Some text"],
[
"stack-frame", [
[
"keyword",
"at"
],
[
"line-number",
[
["punctuation", ":"],
"98",
["punctuation", ":"],
"32"
]
]
]
]
]

----------------------------------------------------

Checks basic a basic error message.
18 changes: 18 additions & 0 deletions tests/languages/jsstacktrace/notmycode_feature.test
@@ -0,0 +1,18 @@
Some text
at processTicksAndRejections (internal/process/task_queues.js:98:32)

----------------------------------------------------

[
["error-message", "Some text"],
[
"stack-frame",
[
["not-my-code", "\tat processTicksAndRejections (internal/process/task_queues.js:98:32)"]
]
]
]

----------------------------------------------------

Checks greying out internal / library code stack trace frames