Skip to content

Commit

Permalink
Add more example code in annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed May 13, 2024
1 parent a5f158e commit ba92e48
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
18 changes: 17 additions & 1 deletion __tests__/write.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,27 @@ describe('annotations', () => {
title: 'Reference violation: SYMBOL2',
message:
'The symbol "SYMBOL2" might not exist ("Unknown identifier").\nReference only symbols that are declared in the patch or safely search for other symbols by their name.',
raw_details: `if (MEM_FindParserSymbol("SYMBOL2") != -1) {
raw_details: `// If SYMBOL2 is a variable/constant
if (MEM_FindParserSymbol("SYMBOL2") != -1) {
var zCPar_Symbol symb; symb = _^(MEM_GetSymbol("SYMBOL2"));
// Access content with symb.content
} else {
// Fallback to a default if the symbol does not exist
};
// -----
// OR: If SYMBOL2 is a function
if (MEM_FindParserSymbol("SYMBOL2") != -1) {
// Push any necessary arguments onto the stack in the order of the function's parameters
//MEM_PushIntParam(1);
//MEM_PushInstParam(hero);
//MEM_PushStringParam("Hello world!");
// Call the function in a safe way
MEM_CallByString("SYMBOL2");
} else {
// Optionally provide a fallback if the function does not exist
};`,
},
{
Expand Down
18 changes: 17 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion src/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,27 @@ prototype ${prefix[0]}_${v.name}( /* class name */ ) {
} else {
// Give general advice on how to handle unknown identifiers
suggestion = 'Reference only symbols that are declared in the patch or safely search for other symbols by their name.'
raw_details = `if (MEM_FindParserSymbol("${v.name}") != -1) {
raw_details = `// If ${v.name} is a variable/constant
if (MEM_FindParserSymbol("${v.name}") != -1) {
var zCPar_Symbol symb; symb = _^(MEM_GetSymbol("${v.name}"));
// Access content with symb.content
} else {
// Fallback to a default if the symbol does not exist
};
// -----
// OR: If ${v.name} is a function
if (MEM_FindParserSymbol("${v.name}") != -1) {
// Push any necessary arguments onto the stack in the order of the function's parameters
//MEM_PushIntParam(1);
//MEM_PushInstParam(hero);
//MEM_PushStringParam("Hello world!");
// Call the function in a safe way
MEM_CallByString("${v.name}");
} else {
// Optionally provide a fallback if the function does not exist
};`
}

Expand Down

0 comments on commit ba92e48

Please sign in to comment.