@@ -12,7 +12,8 @@ const poundImportRegex = /^\s*#import\s+(.+)$/i;
12
12
const poundIncludeRegex = / ^ \s * # i n c l u d e \s + ( \S + ) \s * $ / i;
13
13
const sqlSelectRegex = / ^ \s * # s q l c o m p i l e \s + s e l e c t \s * = \s * ( \S + ) \s * $ / i;
14
14
const commentRegex = / (?: ^ | (?: [ ^ " ] * " [ ^ " ] * " ) * ) ( \/ \/ | ; | \/ \* ) / ;
15
- const rtnProcedureRegex = / ^ \( ( [ ^ ) ] * ) \) \s * (?: \[ [ ^ \] ] * \] ) ? \s * p u b l i c / i;
15
+ const rtnIsDebuggableRegex = / ^ \( ( [ ^ ) ] * ) \) (?: (?: (?: \[ [ ^ \] ] * \] ) ? p u b l i c { ) | (? ! p r i v a t e | m e t h o d i m p l | { | \[ ] ) ) / i;
16
+ const whitespaceAndCCommentsRegex = / \/ \* [ \s \S ] * ?\* \/ | \s + / g;
16
17
17
18
/**
18
19
* Extract the text of the Embedded SQL query starting at `[startLine,StartChar]`.
@@ -335,13 +336,6 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
335
336
}
336
337
337
338
const displayName = quoteClassMemberName ( symbol . name ) ;
338
- if (
339
- ! isPrivate &&
340
- copyToClipboard &&
341
- ( type == "classmethod" || ( type == "query" && displayName [ 0 ] != '"' ) )
342
- ) {
343
- result . push ( this . addCopyToClipboard ( symbolLine , [ `##class(${ className } ).${ displayName } ()` ] ) ) ;
344
- }
345
339
if (
346
340
! isPrivate &&
347
341
debugThisMethod &&
@@ -356,6 +350,13 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
356
350
] )
357
351
) ;
358
352
}
353
+ if (
354
+ ! isPrivate &&
355
+ copyToClipboard &&
356
+ ( type == "classmethod" || ( type == "query" && displayName [ 0 ] != '"' ) )
357
+ ) {
358
+ result . push ( this . addCopyToClipboard ( symbolLine , [ `##class(${ className } ).${ displayName } ()` ] ) ) ;
359
+ }
359
360
}
360
361
}
361
362
} ) ;
@@ -366,24 +367,27 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
366
367
if ( symbols && ( debugThisMethod || copyToClipboard ) ) {
367
368
symbols . forEach ( ( symbol ) => {
368
369
const line = symbol . selectionRange . start . line ;
369
- const restOfLine = document . lineAt ( line ) . text . slice ( symbol . name . length ) ;
370
+ const restOfSymbol = document . getText ( symbol . range ) . slice ( symbol . name . length ) ;
370
371
let hasArgs = false ,
371
- isProc = false ;
372
- if ( restOfLine [ 0 ] == "(" ) {
373
- // Make sure this is a public procedure, and extract the argument list
374
- const procMatch = restOfLine . match ( rtnProcedureRegex ) ;
375
- if ( procMatch ) {
376
- isProc = true ;
377
- hasArgs = procMatch [ 1 ] . length > 0 ;
372
+ hasArgList = false ;
373
+ if ( restOfSymbol [ 0 ] == "(" ) {
374
+ const rtnDebuggableMatch = restOfSymbol
375
+ // Replace all whitespace and C-Style comments
376
+ . replace ( whitespaceAndCCommentsRegex , "" )
377
+ . match ( rtnIsDebuggableRegex ) ;
378
+ // Extract the argument list
379
+ if ( rtnDebuggableMatch ) {
380
+ hasArgList = true ;
381
+ hasArgs = rtnDebuggableMatch [ 1 ] . length > 0 ;
378
382
} else {
379
- // This is not a syntactically valid public procedure
383
+ // This is not a syntactically valid public procedure or subroutine
380
384
return ;
381
385
}
382
386
}
383
387
if ( line == 1 ) labeledLine1 = true ;
384
388
if ( debugThisMethod ) result . push ( this . addDebugThisMethod ( line , [ `${ symbol . name } ^${ routineName } ` , hasArgs ] ) ) ;
385
389
if ( copyToClipboard ) {
386
- result . push ( this . addCopyToClipboard ( line , [ `${ symbol . name } ^${ routineName } ${ isProc ? "()" : "" } ` ] ) ) ;
390
+ result . push ( this . addCopyToClipboard ( line , [ `${ symbol . name } ^${ routineName } ${ hasArgList ? "()" : "" } ` ] ) ) ;
387
391
}
388
392
} ) ;
389
393
}
0 commit comments