This repository was archived by the owner on Aug 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
08. Data Loader
matthew snoddy edited this page Jul 21, 2020
·
1 revision
A simple Node.JS script has been added to the repo to allow injecting calls to load unit values from rules for units/structures etc. in the source code.
See: data-editor\data-editor.js
This contains a very complex regex pattern that others may find useful:
static ${typeName} const ([\\S\\s\\r]+?^\\s+)(".+?")(.+\\/\\/ ${iniNameTag}[\\S\\s\\r]+?^\\s+)${ruleVaueCapture}(,.+\\/\\/\\s+?${ruleNameTag}[\\S\\s\\r]+?\\);[\\n\\r])This will find a declartion in code of type ${typeName} and get the INI name using the ${iniNameTag} as a marker to the comment after the INI name constructor parameter. ${ruleVaueCapture} will capture the current hard-coded default and ${ruleNameTag} identifies the comment that is after the rule value.
This extracts 5 unique captures that can be used to build a new declaration:
- Name of the class type
- INI name in double quotes
- First half of the constructor call
- The current default rule value being passed in
- The remainder of the constructor call
This can then be used to form your own rewrite of the constructor call:
static ${typeName} const $1$2$3${ruleFunction}($2, $4)$5