Fix Molang parser treating namespaced identifiers as expressions#149
Conversation
Modified the molang detection regex to use negative lookbehind (?<!:) to prevent matching patterns like 'minecraft:geometry.full_block' which are resource identifiers, not molang expressions. Added comprehensive test cases to prevent regression. Co-authored-by: DaanV2 <2393905+DaanV2@users.noreply.github.com>
|
@copilot check that diagnoser doesn't look through the molang and tries to find out what is used / defined, we need to ensure that this doesn't skip out check of resources made |
Resource tracking is not affected by the regex fix. The system has two independent code paths: Path 1: Molang harvesting ( Path 2: Resource tracking ( Example from entity/process.ts: molang: harvestMolang(content, description), // Path 1
// ...
getUsingResources(out.molang, description, doc); // Path 2The |
The Molang diagnoser was throwing errors on valid resource identifiers like
minecraft:geometry.full_blockbecause the regex matchedgeometry.anywhere in the string, treating namespaced identifiers as Molang expressions.Changes
Modified regex pattern in
packages/molang/src/molang/functions.ts(?<!:)to prevent matching after colonsminecraft:geometry.full_block(identifier) fromgeometry.custom(Molang)Added test coverage in
packages/molang/test/data/dataset-lookslike.tsnamespace:geometry.*,namespace:texture.*,namespace:material.*patternsExample
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.