@@ -28,6 +28,7 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
28
28
const className = file . name . split ( "." ) . slice ( 0 , - 1 ) . join ( "." ) ;
29
29
30
30
const { debugThisMethod, copyToClipboard } = config ( "debug" ) ;
31
+ const pattern = / (?: ^ C l a s s M e t h o d \s ) ( [ ^ ( ] + ) \( ( (?: [ ^ ( ) ] | \( [ ^ ( ) ] * \) | { [ ^ { } ] * } ) * ) \) / i;
31
32
let inComment = false ;
32
33
for ( let i = 0 ; i < document . lineCount ; i ++ ) {
33
34
const line = document . lineAt ( i ) ;
@@ -44,12 +45,18 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
44
45
continue ;
45
46
}
46
47
47
- const methodMatch = text . match ( / (?< = ^ C l a s s M e t h o d \s ) ( [ ^ ( ] + ) ( \( . ) / i ) ;
48
+ const methodMatch = text . match ( pattern ) ;
48
49
if ( methodMatch ) {
49
- const [ , name , parens ] = methodMatch ;
50
-
51
- debugThisMethod && result . push ( this . addDebugThisMethod ( i , [ `##class(${ className } ).${ name } ` , parens !== "()" ] ) ) ;
52
- copyToClipboard && result . push ( this . addCopyToClipboard ( i , [ `##class(${ className } ).${ name } ()` ] ) ) ;
50
+ const [ , name , paramsRaw ] = methodMatch ;
51
+ let params = paramsRaw ;
52
+ params = params . replace ( / " [ ^ " ] * " / g, '""' ) ;
53
+ params = params . replace ( / { [ ^ { } ] * } | { [ ^ { } ] * { [ ^ { } ] * } [ ^ { } ] * } / g, '""' ) ;
54
+ params = params . replace ( / \( [ ^ ( ) ] * \) / g, "" ) ;
55
+ const paramsCount = params . length ? params . split ( "," ) . length : 0 ;
56
+
57
+ debugThisMethod && result . push ( this . addDebugThisMethod ( i , [ `##class(${ className } ).${ name } ` , paramsCount > 0 ] ) ) ;
58
+ copyToClipboard &&
59
+ result . push ( this . addCopyToClipboard ( i , [ `##class(${ className } ).${ name } (${ Array ( paramsCount ) . join ( "," ) } )` ] ) ) ;
53
60
}
54
61
}
55
62
return result ;
@@ -99,15 +106,15 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
99
106
100
107
private addDebugThisMethod ( line : number , args : any [ ] ) {
101
108
return new vscode . CodeLens ( new vscode . Range ( line , 0 , line , 80 ) , {
102
- title : `Debug this method ` ,
109
+ title : `Debug this Method ` ,
103
110
command : "vscode-objectscript.debug" ,
104
111
arguments : args ,
105
112
} ) ;
106
113
}
107
114
108
115
private addCopyToClipboard ( line : number , args : any [ ] ) {
109
116
return new vscode . CodeLens ( new vscode . Range ( line , 0 , line , 80 ) , {
110
- title : `Copy Invocation to Clipboard ` ,
117
+ title : `Copy Invocation` ,
111
118
command : "vscode-objectscript.copyToClipboard" ,
112
119
arguments : args ,
113
120
} ) ;
0 commit comments