Skip to content

Commit 0cc8987

Browse files
committed
add option for override macro
1 parent 183796e commit 0cc8987

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,11 @@
270270
"type": "boolean",
271271
"default": true,
272272
"description": "Whether to automatically remove `cocos2d::` from included code"
273+
},
274+
"geode.modifyClassSuggestions.addOverrideMacro": {
275+
"type": "boolean",
276+
"default": false,
277+
"description": "Add $override to the beginning of the included code"
273278
}
274279
}
275280
},

src/project/suggest.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@ export class ModifyClassMethodCompletion implements CompletionItemProvider {
6565
const stripCocos = getExtConfig().get<boolean>(
6666
"modifyClassSuggestions.stripCocosNamespace",
6767
);
68+
const addOverrideMacro = getExtConfig().get<boolean>(
69+
"modifyClassSuggestions.addOverrideMacro",
70+
);
6871

6972
let suggestions = [];
7073
for (let func of classInfo.functions) {
7174
const shortFuncDecl = `${func.name}(${func.args.map((a) => `${a.type} ${a.name}`).join(", ")})`;
72-
const fullFuncDecl = `${func.static ? "static " : ""}${func.return} ${shortFuncDecl}`.trimStart();
75+
const fullFuncDecl =
76+
`${func.static ? "static " : ""}${func.return} ${shortFuncDecl}`.trimStart();
7377
const origCall = `${currentClass}::${func.name}(${func.args.map((a) => a.name).join(", ")})`;
7478

7579
let origStatement;
@@ -92,6 +96,9 @@ export class ModifyClassMethodCompletion implements CompletionItemProvider {
9296
if (func.kind === "ctor" || func.kind === "dtor") {
9397
item.insertText = `void ${func.kind === "ctor" ? "constructor" : "destructor"}() {\n\t${origStatement}\n}`;
9498
}
99+
if (addOverrideMacro) {
100+
item.insertText = `\\$override\n${item.insertText}`;
101+
}
95102
if (stripCocos) {
96103
item.insertText = item.insertText.replace(/cocos2d::/g, "");
97104
}

0 commit comments

Comments
 (0)