@@ -12,7 +12,8 @@ const poundImportRegex = /^\s*#import\s+(.+)$/i;
1212const poundIncludeRegex = / ^ \s * # i n c l u d e \s + ( \S + ) \s * $ / i;
1313const sqlSelectRegex = / ^ \s * # s q l c o m p i l e \s + s e l e c t \s * = \s * ( \S + ) \s * $ / i;
1414const 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;
1617
1718/**
1819 * Extract the text of the Embedded SQL query starting at `[startLine,StartChar]`.
@@ -335,13 +336,6 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
335336 }
336337
337338 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- }
345339 if (
346340 ! isPrivate &&
347341 debugThisMethod &&
@@ -356,6 +350,13 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
356350 ] )
357351 ) ;
358352 }
353+ if (
354+ ! isPrivate &&
355+ copyToClipboard &&
356+ ( type == "classmethod" || ( type == "query" && displayName [ 0 ] != '"' ) )
357+ ) {
358+ result . push ( this . addCopyToClipboard ( symbolLine , [ `##class(${ className } ).${ displayName } ()` ] ) ) ;
359+ }
359360 }
360361 }
361362 } ) ;
@@ -366,24 +367,27 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
366367 if ( symbols && ( debugThisMethod || copyToClipboard ) ) {
367368 symbols . forEach ( ( symbol ) => {
368369 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 ) ;
370371 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 ;
378382 } else {
379- // This is not a syntactically valid public procedure
383+ // This is not a syntactically valid public procedure or subroutine
380384 return ;
381385 }
382386 }
383387 if ( line == 1 ) labeledLine1 = true ;
384388 if ( debugThisMethod ) result . push ( this . addDebugThisMethod ( line , [ `${ symbol . name } ^${ routineName } ` , hasArgs ] ) ) ;
385389 if ( copyToClipboard ) {
386- result . push ( this . addCopyToClipboard ( line , [ `${ symbol . name } ^${ routineName } ${ isProc ? "()" : "" } ` ] ) ) ;
390+ result . push ( this . addCopyToClipboard ( line , [ `${ symbol . name } ^${ routineName } ${ hasArgList ? "()" : "" } ` ] ) ) ;
387391 }
388392 } ) ;
389393 }
0 commit comments