@@ -282,9 +282,9 @@ export default class JavascriptEventWorker extends EventWorker {
282282 * @param path
283283 */
284284 ClassDeclaration ( path ) {
285- console . log ( `class declaration: loc: ${ path . node . loc } , line: ${ line } , node.start.line: ${ path . node . loc . start . line } , node.end.line: ${ path . node . loc . end . line } ` ) ;
286-
287285 if ( path . node . loc && path . node . loc . start . line <= line && path . node . loc . end . line >= line ) {
286+ console . log ( `class declaration: loc: ${ path . node . loc } , line: ${ line } , node.start.line: ${ path . node . loc . start . line } , node.end.line: ${ path . node . loc . end . line } ` ) ;
287+
288288 className = path . node . id . name || null ;
289289 }
290290 } ,
@@ -295,9 +295,9 @@ export default class JavascriptEventWorker extends EventWorker {
295295 * @param path
296296 */
297297 ClassMethod ( path ) {
298- console . log ( `class declaration: loc: ${ path . node . loc } , line: ${ line } , node.start.line: ${ path . node . loc . start . line } , node.end.line: ${ path . node . loc . end . line } ` ) ;
299-
300298 if ( path . node . loc && path . node . loc . start . line <= line && path . node . loc . end . line >= line ) {
299+ console . log ( `class declaration: loc: ${ path . node . loc } , line: ${ line } , node.start.line: ${ path . node . loc . start . line } , node.end.line: ${ path . node . loc . end . line } ` ) ;
300+
301301 // Handle different key types
302302 if ( path . node . key . type === 'Identifier' ) {
303303 functionName = path . node . key . name ;
@@ -311,9 +311,9 @@ export default class JavascriptEventWorker extends EventWorker {
311311 * @param path
312312 */
313313 FunctionDeclaration ( path ) {
314- console . log ( `function declaration: loc: ${ path . node . loc } , line: ${ line } , node.start.line: ${ path . node . loc . start . line } , node.end.line: ${ path . node . loc . end . line } ` ) ;
315-
316314 if ( path . node . loc && path . node . loc . start . line <= line && path . node . loc . end . line >= line ) {
315+ console . log ( `function declaration: loc: ${ path . node . loc } , line: ${ line } , node.start.line: ${ path . node . loc . start . line } , node.end.line: ${ path . node . loc . end . line } ` ) ;
316+
317317 functionName = path . node . id . name || null ;
318318 isAsync = path . node . async ;
319319 }
@@ -324,15 +324,15 @@ export default class JavascriptEventWorker extends EventWorker {
324324 * @param path
325325 */
326326 VariableDeclarator ( path ) {
327- console . log ( `variable declaration: node.type: ${ path . node . init . type } , line: ${ line } , ` ) ;
328-
329327 if (
330328 path . node . init &&
331329 ( path . node . init . type === 'FunctionExpression' || path . node . init . type === 'ArrowFunctionExpression' ) &&
332330 path . node . loc &&
333331 path . node . loc . start . line <= line &&
334332 path . node . loc . end . line >= line
335333 ) {
334+ console . log ( `variable declaration: node.type: ${ path . node . init . type } , line: ${ line } , ` ) ;
335+
336336 // Handle different id types
337337 if ( path . node . id . type === 'Identifier' ) {
338338 functionName = path . node . id . name ;
@@ -341,8 +341,11 @@ export default class JavascriptEventWorker extends EventWorker {
341341 }
342342 } ,
343343 } ) ;
344- } catch ( e ) {
345- console . error ( `Failed to parse source code: ${ e . message } ` ) ;
344+ } catch ( traverseError ) {
345+ console . error ( `Failed to parse source code:` ) ;
346+ console . error ( traverseError ) ;
347+
348+ HawkCatcher . send ( traverseError ) ;
346349 }
347350
348351 return functionName ? `${ isAsync ? 'async ' : '' } ${ className ? `${ className } .` : '' } ${ functionName } ` : null ;
0 commit comments