Skip to content

Commit e6a88b6

Browse files
authored
Merge pull request intersystems-community#1198 from intersystems-community/copy-query
2 parents a0dac60 + 748dcec commit e6a88b6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/providers/ObjectScriptCodeLensProvider.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
2828
return result;
2929
}
3030

31-
const pattern = /(?:^ClassMethod\s)([^(]+)\((.*)/i;
31+
const pattern = /(?:^(ClassMethod|Query)\s)([^(]+)\((.*)/i;
3232
let inComment = false;
3333
for (let i = 0; i < document.lineCount; i++) {
3434
const line = document.lineAt(i);
@@ -47,17 +47,23 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
4747

4848
const methodMatch = text.match(pattern);
4949
if (methodMatch) {
50-
const [, name, paramsRaw] = methodMatch;
50+
const [, kind, name, paramsRaw] = methodMatch;
5151
let params = paramsRaw;
5252
params = params.replace(/"[^"]*"/g, '""');
5353
params = params.replace(/{[^{}]*}|{[^{}]*{[^{}]*}[^{}]*}/g, '""');
5454
params = params.replace(/\([^()]*\)/g, "");
5555
const args = params.split(")")[0];
5656
const paramsCount = args.length ? args.split(",").length : params.includes(")") ? 0 : 1; // Need a positive paramsCount when objectscript.multilineMethodArgs is true
5757

58-
debugThisMethod && result.push(this.addDebugThisMethod(i, [`##class(${className}).${name}`, paramsCount > 0]));
58+
const methodName = name + (kind == "Query" ? "Func" : "");
59+
60+
debugThisMethod &&
61+
kind == "ClassMethod" &&
62+
result.push(this.addDebugThisMethod(i, [`##class(${className}).${methodName}`, paramsCount > 0]));
5963
copyToClipboard &&
60-
result.push(this.addCopyToClipboard(i, [`##class(${className}).${name}(${Array(paramsCount).join(",")})`]));
64+
result.push(
65+
this.addCopyToClipboard(i, [`##class(${className}).${methodName}(${Array(paramsCount).join(",")})`])
66+
);
6167
}
6268
}
6369
return result;

0 commit comments

Comments
 (0)