Commit 983d671
Fix Molang parser treating namespaced identifiers as expressions (#149)
The Molang diagnoser was throwing errors on valid resource identifiers
like `minecraft:geometry.full_block` because the regex matched
`geometry.` anywhere in the string, treating namespaced identifiers as
Molang expressions.
## Changes
- **Modified regex pattern** in
`packages/molang/src/molang/functions.ts`
- Added negative lookbehind `(?<!:)` to prevent matching after colons
- Pattern now correctly distinguishes `minecraft:geometry.full_block`
(identifier) from `geometry.custom` (Molang)
- **Added test coverage** in
`packages/molang/test/data/dataset-lookslike.ts`
- Tests for `namespace:geometry.*`, `namespace:texture.*`,
`namespace:material.*` patterns
## Example
```typescript
// Before: Both matched as Molang
isMolang('minecraft:geometry.full_block') // true ❌
isMolang('geometry.custom') // true
// After: Only valid Molang matches
isMolang('minecraft:geometry.full_block') // false ✓
isMolang('geometry.custom') // true ✓
```
<!-- START COPILOT CODING AGENT SUFFIX -->
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
> There are errors being thrown by the diagnoser because of invalid
molang:
>
> minecraft:geometry.full_block
>
> However this is valid, but probally shouldn't tried to parsed or add
the to list of resources used
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/Blockception/minecraft-bedrock-language-server/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: DaanV2 <2393905+DaanV2@users.noreply.github.com>1 parent e372a98 commit 983d671
4 files changed
Lines changed: 253 additions & 45 deletions
File tree
- ide/vscode/src
- packages/molang
- src/molang
- test/data
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
0 commit comments