chore: add arguments logging to deprecated MacrosParser method warnings (#5429) Extends the #logDeprecated helper to accept and log the arguments passed to deprecated methods, providing better debugging context for migration. Updates all deprecated method calls (get, has, registerMacro, unregisterMacro) to forward their arguments to the deprecation logger.
Signed| @@ -58,10 +58,11 @@ export class MacrosParser { | ||
| 58 | 58 | * |
| 59 | 59 | * @param {string} method |
| 60 | 60 | * @param {string} replacement |
| 61 | + * @param {IArguments} [methodArgs=null] | |
| 61 | 62 | * @returns {void} |
| 62 | 63 | */ |
| 63 | 64 | static #logDeprecated(method, replacement, methodArgs = null) { |
| 64 | 65 | console.warn(`[DEPRECATED] MacrosParser.${method} is deprecated and will be removed in a future version. Use ${replacement} instead. Arguments:`, (methodArgs ?? 'none')); |
| 65 | 66 | } |
| 66 | 67 | |
| 67 | 68 | /** |
| @@ -155,7 +156,7 @@ export class MacrosParser { | ||
| 155 | 156 | * @returns {string|MacroFunction|undefined} The macro value |
| 156 | 157 | */ |
| 157 | 158 | static get(key) { |
| 158 | 159 | MacrosParser.#logDeprecated('get', 'macros.registry.getMacro (from scripts/macros/macro-system.js)', arguments); |
| 159 | 160 | return MacrosParser.#macros.get(key); |
| 160 | 161 | } |
| 161 | 162 | |
| @@ -165,7 +166,7 @@ export class MacrosParser { | ||
| 165 | 166 | * @returns {boolean} True if the macro is registered, false otherwise |
| 166 | 167 | */ |
| 167 | 168 | static has(key) { |
| 168 | 169 | MacrosParser.#logDeprecated('has', 'macros.registry.hasMacro (from scripts/macros/macro-system.js)', arguments); |
| 169 | 170 | if (power_user.experimental_macro_engine) { |
| 170 | 171 | return macroSystem.registry.hasMacro(key); |
| 171 | 172 | } |
| @@ -180,7 +181,7 @@ export class MacrosParser { | ||
| 180 | 181 | * @param {string} [description] Optional description of the macro |
| 181 | 182 | */ |
| 182 | 183 | static registerMacro(key, value, description = '') { |
| 183 | 184 | MacrosParser.#logDeprecated('registerMacro', 'macros.registry.registerMacro (from scripts/macros/macro-system.js) or substituteParams({ dynamicMacros })', arguments); |
| 184 | 185 | if (typeof key !== 'string') { |
| 185 | 186 | throw new Error('Macro key must be a string'); |
| 186 | 187 | } |
| @@ -223,7 +224,7 @@ export class MacrosParser { | ||
| 223 | 224 | * @param {string} key Macro name (key) |
| 224 | 225 | */ |
| 225 | 226 | static unregisterMacro(key) { |
| 226 | 227 | MacrosParser.#logDeprecated('unregisterMacro', 'macros.registry.unregisterMacro (from scripts/macros/macro-system.js)', arguments); |
| 227 | 228 | if (typeof key !== 'string') { |
| 228 | 229 | throw new Error('Macro key must be a string'); |
| 229 | 230 | } |