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 | * @param {string} method | 59 | * @param {string} method |
| 60 | * @param {string} replacement | 60 | * @param {string} replacement |
| 61 | * @param {IArguments} [methodArgs=null] | ||
| 61 | * @returns {void} | 62 | * @returns {void} |
| 62 | */ | 63 | */ |
| 63 | static #logDeprecated(method, replacement) { | 64 | static #logDeprecated(method, replacement, methodArgs = null) { |
| 64 | console.warn(`[DEPRECATED] MacrosParser.${method} is deprecated and will be removed in a future version. Use ${replacement} instead.`); | 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 | * @returns {string|MacroFunction|undefined} The macro value | 156 | * @returns {string|MacroFunction|undefined} The macro value |
| 156 | */ | 157 | */ |
| 157 | static get(key) { | 158 | static get(key) { |
| 158 | MacrosParser.#logDeprecated('get', 'macros.registry.getMacro (from scripts/macros/macro-system.js)'); | 159 | MacrosParser.#logDeprecated('get', 'macros.registry.getMacro (from scripts/macros/macro-system.js)', arguments); |
| 159 | return MacrosParser.#macros.get(key); | 160 | return MacrosParser.#macros.get(key); |
| 160 | } | 161 | } |
| 161 | 162 | ||
| @@ -165,7 +166,7 @@ export class MacrosParser { | |||
| 165 | * @returns {boolean} True if the macro is registered, false otherwise | 166 | * @returns {boolean} True if the macro is registered, false otherwise |
| 166 | */ | 167 | */ |
| 167 | static has(key) { | 168 | static has(key) { |
| 168 | MacrosParser.#logDeprecated('has', 'macros.registry.hasMacro (from scripts/macros/macro-system.js)'); | 169 | MacrosParser.#logDeprecated('has', 'macros.registry.hasMacro (from scripts/macros/macro-system.js)', arguments); |
| 169 | if (power_user.experimental_macro_engine) { | 170 | if (power_user.experimental_macro_engine) { |
| 170 | return macroSystem.registry.hasMacro(key); | 171 | return macroSystem.registry.hasMacro(key); |
| 171 | } | 172 | } |
| @@ -180,7 +181,7 @@ export class MacrosParser { | |||
| 180 | * @param {string} [description] Optional description of the macro | 181 | * @param {string} [description] Optional description of the macro |
| 181 | */ | 182 | */ |
| 182 | static registerMacro(key, value, description = '') { | 183 | static registerMacro(key, value, description = '') { |
| 183 | MacrosParser.#logDeprecated('registerMacro', 'macros.registry.registerMacro (from scripts/macros/macro-system.js) or substituteParams({ dynamicMacros })'); | 184 | MacrosParser.#logDeprecated('registerMacro', 'macros.registry.registerMacro (from scripts/macros/macro-system.js) or substituteParams({ dynamicMacros })', arguments); |
| 184 | if (typeof key !== 'string') { | 185 | if (typeof key !== 'string') { |
| 185 | throw new Error('Macro key must be a string'); | 186 | throw new Error('Macro key must be a string'); |
| 186 | } | 187 | } |
| @@ -223,7 +224,7 @@ export class MacrosParser { | |||
| 223 | * @param {string} key Macro name (key) | 224 | * @param {string} key Macro name (key) |
| 224 | */ | 225 | */ |
| 225 | static unregisterMacro(key) { | 226 | static unregisterMacro(key) { |
| 226 | MacrosParser.#logDeprecated('unregisterMacro', 'macros.registry.unregisterMacro (from scripts/macros/macro-system.js)'); | 227 | MacrosParser.#logDeprecated('unregisterMacro', 'macros.registry.unregisterMacro (from scripts/macros/macro-system.js)', arguments); |
| 227 | if (typeof key !== 'string') { | 228 | if (typeof key !== 'string') { |
| 228 | throw new Error('Macro key must be a string'); | 229 | throw new Error('Macro key must be a string'); |
| 229 | } | 230 | } |