-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Java Stack Trace highlight support.
Highlights Java stack traces.
- Loading branch information
Showing
4 changed files
with
351 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
(function() { | ||
|
||
// from MIN-MAX_CODE_POINT, Character.isJavaIdentifierStart(x) && !Character.isAlphabetic(x) | ||
var JAVA_IDENTIFIERS = '$_¢£¤¥৲৳৻૱௹฿៛‿⁀⁔₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵₶₷₸₹꠸﷼︳︴﹍﹎﹏﹩$_¢£¥₩؋'; | ||
var IDENTIFIER_CLS = '[' + JAVA_IDENTIFIERS + 'A-Za-z0-9]'; | ||
|
||
// $com _foo bar | ||
var PKG_NAME_PATTERN = '(' + IDENTIFIER_CLS + '+)'; | ||
// com.foo.bar.baz | ||
var PKG_PATH_PATTERN = '(\\b' + PKG_NAME_PATTERN + '(\\.' + PKG_NAME_PATTERN + ')+)'; | ||
// $Foo $9 _FOO Foo Bar9 | ||
var CLS_NAME_PATTERN = '(([' + JAVA_IDENTIFIERS + 'A-Z0-9])+' + IDENTIFIER_CLS + '*)'; | ||
// get getFoo get9Foos | ||
var FN_NAME_PATTERN = '(_?[a-z]' + IDENTIFIER_CLS + '*|<(cl)?init>|-wrap\\d+)'; | ||
// com.foo.Bar$Baz | ||
var PKG_CLS_PATTERN = '(' + PKG_PATH_PATTERN + ')?([.$]' + CLS_NAME_PATTERN + ')+'; | ||
// com.foo.Bar.baz(Bar.java:312) | ||
var FN_CALL_PATTERN = IDENTIFIER_CLS + '+([.]' + IDENTIFIER_CLS +'+)*[.][-<]?' + IDENTIFIER_CLS + '+>?[(].*?[)]'; | ||
|
||
var createMethodCallDef = function() { | ||
return { | ||
'pattern': new RegExp(FN_CALL_PATTERN), | ||
'inside': { | ||
'class-method-args': { | ||
'pattern': new RegExp('([. ]?)'+IDENTIFIER_CLS+'+[.][-<]?'+IDENTIFIER_CLS+'+>?[(].*?[)]$'), | ||
'lookbehind': true, | ||
'inside': { | ||
'class-name': { | ||
'pattern': new RegExp('^' + IDENTIFIER_CLS + '+\\b'), | ||
'alias': 'entity', | ||
}, | ||
'function': [ | ||
{ | ||
'pattern': new RegExp('([.])' + IDENTIFIER_CLS + '+\\b'), | ||
'lookbehind': true, | ||
}, | ||
/<(cl)?init>/, | ||
/-wrap\d+/, | ||
], | ||
'punctuation': [/[.()]/], | ||
}, | ||
}, | ||
'package': new RegExp(PKG_NAME_PATTERN), | ||
'punctuation': /[.]/, | ||
}, | ||
}; | ||
}; | ||
|
||
var METHOD_CALL = createMethodCallDef(); | ||
var METHOD_CALL_FRAME = (function() { | ||
var def = createMethodCallDef(); | ||
var fnCall = def.inside['class-method-args']; | ||
fnCall.inside = { | ||
'class-name': fnCall.inside['class-name'], | ||
'source': [ | ||
{ | ||
'pattern': /(\().*\.java(:\d+)?/, | ||
'lookbehind': true, | ||
'alias': 'entity', | ||
'inside': { | ||
'file': new RegExp('^' + IDENTIFIER_CLS + '+\\.java'), | ||
'lineno': { | ||
'pattern': /\d+/, | ||
'alias': 'number', | ||
}, | ||
'punctuation': /[:]/, | ||
}, | ||
}, | ||
/Native Method/i, | ||
/Unknown Source/i, | ||
{ | ||
'pattern': new RegExp('(\\(:)' + PKG_PATH_PATTERN), | ||
'lookbehind': true, | ||
}, | ||
], | ||
'function': fnCall.inside['function'], | ||
'punctuation': /[:.()]/, | ||
}; | ||
return def; | ||
}()); | ||
|
||
var JAVA_CLASS = { | ||
'pattern': new RegExp('\\b' + PKG_PATH_PATTERN + '\\b'), | ||
'inside': { | ||
'class-name': { | ||
'pattern': new RegExp('([.])' + IDENTIFIER_CLS + '+$'), | ||
'lookbehind': true, | ||
'alias': 'entity', | ||
}, | ||
'package': { | ||
'pattern': new RegExp(PKG_NAME_PATTERN + '\\b'), | ||
}, | ||
'punctuation': /[.]/, | ||
}, | ||
}; | ||
|
||
var PLAIN_PUNCTUATION = /[;:'"]/; | ||
|
||
Prism.languages.stackjava = { | ||
'cause': { | ||
'pattern': /(\n)Caused by:.*/, | ||
'lookbehind': true, | ||
'inside': { | ||
'method-call': METHOD_CALL, | ||
'java-class': JAVA_CLASS, | ||
'keyword': /^(Caused by)/i, | ||
'punctuation': PLAIN_PUNCTUATION, | ||
}, | ||
}, | ||
'summary': { | ||
'pattern': new RegExp('(^|\n)' + PKG_PATH_PATTERN + '.*'), | ||
'lookbehind': true, | ||
'inside': { | ||
'method-call': METHOD_CALL, | ||
'java-class': JAVA_CLASS, | ||
'punctuation': PLAIN_PUNCTUATION, | ||
}, | ||
}, | ||
'stack-frame': { | ||
'pattern': new RegExp('(\\n\\s+)at ' + FN_CALL_PATTERN), | ||
'lookbehind': true, | ||
'inside': { | ||
'keyword': /\b(at)\b/, | ||
'method-call': METHOD_CALL_FRAME, | ||
}, | ||
}, | ||
'stack-truncation': { | ||
'pattern': /(\n\s+)\.\.\..*more/, | ||
'lookbehind': true, | ||
'inside': { | ||
'keyword': /\b(more)\b/, | ||
'punctuation': /\.\.\./, | ||
'count': { | ||
'pattern': /\d+/, | ||
'alias': 'number', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
java.lang.Exception: com.android.camera.async.ResourceUnavailableException: android.hardware.camera2.CameraAccessException: Operation timed out in camera service | ||
at java.lang.reflect.Method.invoke$100(Native Method) | ||
at com.android.camera.module.video2.Video2OpenedCamcorderDevice$3.onFailure(Video2OpenedCamcorderDevice.java:307) | ||
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) | ||
at com.waze.OfflineNativeManager.<init>(OfflineNativeManager.java:100) | ||
at android.app.ActivityThread.-wrap14(ActivityThread.java) | ||
at com.android.ex.camera2.portability.CameraAgent$CameraOpenCallbackForward$3.run(CameraAgent.java:134) | ||
at com.android.camera.CaptureModule$17.onFailure(:com.google.android.gms:333) | ||
Caused by: com.android.camera.async.ResourceUnavailableException: android.hardware.camera2.CameraAccessException: Operation timed out in camera service | ||
at $Proxy1.waitUntilIdle(Unknown Source) | ||
... 6 more | ||
com.android.location.e.f: 'java.io.File android.content.Context.getFilesDir()' | ||
at com.jni.indexeddb.mainJNI.SwigDirector_EventListener_handleEvent(mainJNI.java:329) | ||
at org.holoeverywhere.LayoutInflater._createView(LayoutInflater.java:305) | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["summary", | ||
[ ["java-class", | ||
[ ["package", "java"], ["punctuation", "."], | ||
["package", "lang"], ["punctuation", "."], | ||
["class-name", "Exception"]]], | ||
["punctuation", ":"], | ||
["java-class", | ||
[ ["package", "com"], ["punctuation", "."], | ||
["package", "android"], ["punctuation", "."], | ||
["package", "camera"], ["punctuation", "."], | ||
["package", "async"], ["punctuation", "."], | ||
["class-name", "ResourceUnavailableException"]]], | ||
["punctuation", ":"], | ||
["java-class", | ||
[ ["package", "android"], ["punctuation", "."], | ||
["package", "hardware"], ["punctuation", "."], | ||
["package", "camera2"], ["punctuation", "."], | ||
["class-name", "CameraAccessException"]]], | ||
["punctuation", ":"], " Operation timed out in camera service"]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["package", "java"], ["punctuation", "."], | ||
["package", "lang"], ["punctuation", "."], | ||
["package", "reflect"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "Method"], ["punctuation", "."], | ||
["function", "invoke$100"], | ||
["punctuation", "("], ["source", "Native Method"], ["punctuation", ")"]]]]]]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["package", "com"], ["punctuation", "."], | ||
["package", "android"], ["punctuation", "."], | ||
["package", "camera"], ["punctuation", "."], | ||
["package", "module"], ["punctuation", "."], | ||
["package", "video2"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "Video2OpenedCamcorderDevice$3"], ["punctuation", "."], | ||
["function", "onFailure"], | ||
["punctuation", "("], | ||
["source", | ||
[ ["file", "Video2OpenedCamcorderDevice.java"], ["punctuation", ":"], ["lineno", "307"]]], | ||
["punctuation", ")"]]]]]]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["package", "com"], ["punctuation", "."], | ||
["package", "android"], ["punctuation", "."], | ||
["package", "internal"], ["punctuation", "."], | ||
["package", "os"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "ZygoteInit$MethodAndArgsCaller"], ["punctuation", "."], | ||
["function", "run"], | ||
["punctuation", "("], | ||
["source", | ||
[ ["file", "ZygoteInit.java"], ["punctuation", ":"], ["lineno", "726"]]], | ||
["punctuation", ")"]]]]]]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["package", "com"], ["punctuation", "."], | ||
["package", "waze"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "OfflineNativeManager"], ["punctuation", "."], | ||
["function", "<init>"], | ||
["punctuation", "("], | ||
["source", | ||
[ ["file", "OfflineNativeManager.java"], ["punctuation", ":"], ["lineno", "100"]]], | ||
["punctuation", ")"]]]]]]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["package", "android"], ["punctuation", "."], | ||
["package", "app"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "ActivityThread"], ["punctuation", "."], | ||
["function", "-wrap14"], | ||
["punctuation", "("], | ||
["source", | ||
[ ["file", "ActivityThread.java"]]], | ||
["punctuation", ")"]]]]]]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["package", "com"], ["punctuation", "."], | ||
["package", "android"], ["punctuation", "."], | ||
["package", "ex"], ["punctuation", "."], | ||
["package", "camera2"], ["punctuation", "."], | ||
["package", "portability"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "CameraAgent$CameraOpenCallbackForward$3"], ["punctuation", "."], | ||
["function", "run"], | ||
["punctuation", "("], | ||
["source", | ||
[ ["file", "CameraAgent.java"], ["punctuation", ":"], ["lineno", "134"]]], | ||
["punctuation", ")"]]]]]]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["package", "com"], ["punctuation", "."], | ||
["package", "android"], ["punctuation", "."], | ||
["package", "camera"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "CaptureModule$17"], ["punctuation", "."], | ||
["function", "onFailure"], | ||
["punctuation", "("], | ||
["punctuation", ":"], ["source", "com.google.android.gms"], ["punctuation", ":"], "333", | ||
["punctuation", ")"]]]]]]], | ||
["cause", | ||
[ ["keyword", "Caused by"], ["punctuation", ":"], | ||
["java-class", | ||
[ ["package", "com"], ["punctuation", "."], | ||
["package", "android"], ["punctuation", "."], | ||
["package", "camera"], ["punctuation", "."], | ||
["package", "async"], ["punctuation", "."], | ||
["class-name", "ResourceUnavailableException"]]], ["punctuation", ":"], | ||
["java-class", | ||
[ ["package", "android"], ["punctuation", "."], | ||
["package", "hardware"], ["punctuation", "."], | ||
["package", "camera2"], ["punctuation", "."], | ||
["class-name", "CameraAccessException"]]], ["punctuation", ":"], | ||
" Operation timed out in camera service"]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["class-method-args", | ||
[ ["class-name", "$Proxy1"], ["punctuation", "."], | ||
["function", "waitUntilIdle"], | ||
["punctuation", "("], | ||
["source", "Unknown Source"], | ||
["punctuation", ")"]]]]]]], | ||
["stack-truncation", | ||
[ ["punctuation", "..."], ["count", "6"], ["keyword", "more"]]], | ||
["summary", | ||
[ ["java-class", | ||
[ ["package", "com"], ["punctuation", "."], | ||
["package", "android"], ["punctuation", "."], | ||
["package", "location"], ["punctuation", "."], | ||
["package", "e"], ["punctuation", "."], | ||
["class-name", "f"]]], | ||
["punctuation", ":"], | ||
["punctuation", "'"], | ||
["java-class", | ||
[ ["package", "java"], ["punctuation", "."], | ||
["package", "io"], ["punctuation", "."], | ||
["class-name", "File"]]], | ||
["method-call", | ||
[ ["package", "android"], ["punctuation", "."], | ||
["package", "content"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "Context"], ["punctuation", "."], | ||
["function", "getFilesDir"], | ||
["punctuation", "("], | ||
["punctuation", ")"]]]]], | ||
["punctuation", "'"]]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["package", "com"], ["punctuation", "."], | ||
["package", "jni"], ["punctuation", "."], | ||
["package", "indexeddb"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "mainJNI"], ["punctuation", "."], | ||
["function", "SwigDirector_EventListener_handleEvent"], | ||
["punctuation", "("], | ||
["source", | ||
[ ["file", "mainJNI.java"], ["punctuation", ":"], ["lineno", "329"]]], | ||
["punctuation", ")"]]]]]]], | ||
["stack-frame", | ||
[ ["keyword", "at"], | ||
["method-call", | ||
[ ["package", "org"], ["punctuation", "."], | ||
["package", "holoeverywhere"], ["punctuation", "."], | ||
["class-method-args", | ||
[ ["class-name", "LayoutInflater"], ["punctuation", "."], | ||
["function", "_createView"], | ||
["punctuation", "("], | ||
["source", | ||
[ ["file", "LayoutInflater.java"], ["punctuation", ":"], ["lineno", "305"]]], | ||
["punctuation", ")"]]]]]]] | ||
] | ||
|
||
|
||
---------------------------------------------------- | ||
|
||
Checks Android Java Stack Trace. |