Commit 9480ca5
fix: correct math.pi constant rewriting and code action range in Molang optimizations
- In `string.ts`: Don't append `()` for zero-argument FunctionCall nodes (e.g. `math.pi`)
so that constants are serialized correctly without parentheses.
- In `nodes.ts`: Fix infinite loop in `getLastEndPosition` for FunctionCall with 0 args
by returning early with the correct identifier length.
- In `nodes.ts`: Add `ExpressionNode.getStartPosition()` helper that finds the minimum
(leftmost) source offset among all descendants of an expression node.
- In `registry.ts`: Use `OffsetWord` with the full expression range (from `getStartPosition`
to `getLastEndPosition`) when adding optimization diagnostics, so code actions replace
the correct text instead of just the operator and adjacent identifier.
- In `optimizations.test.ts`: Add regression test asserting that `5*3*math.pi`
produces a replacement containing `math.pi` and not `math.pi()`.
Agent-Logs-Url: https://github.com/Blockception/minecraft-bedrock-language-server/sessions/c46da7a3-c138-4dfb-a355-ca41b9f597bc
Co-authored-by: DaanV2 <2393905+DaanV2@users.noreply.github.com>1 parent 320dd69 commit 9480ca5
7 files changed
Lines changed: 61 additions & 4 deletions
File tree
- ide/vscode/src
- packages
- bedrock-diagnoser
- src/diagnostics/molang/optimizations
- test/lib/diagnostics/molang
- molang
- src/molang/syntax
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13549 | 13549 | | |
13550 | 13550 | | |
13551 | 13551 | | |
13552 | | - | |
| 13552 | + | |
| 13553 | + | |
13553 | 13554 | | |
13554 | 13555 | | |
13555 | 13556 | | |
| |||
13558 | 13559 | | |
13559 | 13560 | | |
13560 | 13561 | | |
| 13562 | + | |
| 13563 | + | |
| 13564 | + | |
| 13565 | + | |
| 13566 | + | |
| 13567 | + | |
| 13568 | + | |
| 13569 | + | |
| 13570 | + | |
| 13571 | + | |
| 13572 | + | |
| 13573 | + | |
| 13574 | + | |
| 13575 | + | |
| 13576 | + | |
| 13577 | + | |
| 13578 | + | |
13561 | 13579 | | |
13562 | 13580 | | |
13563 | 13581 | | |
| |||
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
69 | | - | |
| 77 | + | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
495 | 507 | | |
496 | 508 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
300 | 303 | | |
301 | 304 | | |
302 | 305 | | |
| |||
316 | 319 | | |
317 | 320 | | |
318 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
319 | 336 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
0 commit comments