Big update to prettier-extension-monkeyc

I've posted about prettier-extension-monkeyc before, but I've added a bunch of new features that developers will probably like (well, I've been missing them, so maybe you have too).

The new features it implements for VSCode include:

  • Goto Definition. Point at a symbol, Ctrl/Cmd click, and it will take you to the definition. Or F12
  • Goto References. Right click on a symbol and select "Goto References". It will show you all the references. Or Shift-F12
  • Peek Definition/Peek References. Same as above, but in a popup window so you don't lose your place in the original document.
  • Rename Symbol. Right click on a local, function, class or module name, and select "Rename Symbol". It will rename all the references. It doesn't yet work for class members/methods.
  • Goto Symbol. Type Ctrl/Cmd-Shift-O and pick a symbol from the drop down (which has a hierarchical view of all symbols in the current file). This also appears as an outline across the top of the file.
  • Open Symbol By Name. Type Ctrl/Cmd-T, then start typing letters from a symbol name. A drop down will be populated with all matching symbols from anywhere in your project.

Older features include a prettier based formatter for monkeyc, and a monkeyc optimizer that will build/run/export an optimized version of your project.

[edit: My last couple of replies seem to have just disappeared, and the whole conversation seems to be in a jumbled order, so tldr: there's a new test-release at https://github.com/markw65/prettier-extension-monkeyc/releases/tag/v2.0.9 which seems to work for me on linux. I'll do more verification tomorrow, and push a proper update to the vscode store once I'm sure everything is working]

  • OK, what you found is Ant+HRM :) I released the last version a few days ago, before 2.0.59

    The numbers I sent are from Ant+HRV, that is based on Ant+HRM DF but also adds HRV and I only have it as beta yet, so don't worry. If you are interested then I can send you the prg, debug (or whatever files you need) to debug it.

  • OK, what you found is Ant+HRM

    Ah - ok. But it still had what is probably the same bug. I've found the cause, and am testing now. But if you *could* send me the prg for Ant+HRV, I could verify that its the same issue.

    For Ant+HRM, the bug was giving you an extra 180 bytes of code size reduction, but it still get 337 after the fix - but it looks like you didn't use removeArgc for that release, so its 108 bytes from removeArgc, and 229 from the new optimizations.

  • I've just published the fix. v2.0.60. Let me know how it affects the sizes. If there's no change, thats a problem :-)

  • 2.0.60 post PRE+, Minimize Locals-:
    > Sizes for optimized-AntHRV.original-fenix6: code: 12672 data: 2984 <
    > Sizes for optimized-AntHRV-fenix6: code: 11949 data: 2984 <

  • v2.0.61 is out.

    This version mainly addresses features added in recent compilers.

    • "project.typecheck" and "project.optimization" are now passed through to the optimized jungle
    • "personality" paths are passed through to the optimized jungle. Previously, non-standard paths would simply not get passed through, and the optimized code wouldn't use the correct personality.
    • All the relevant ".mss" files are now included in the build, so references to things like "Rez.Styles.myStyle.foo" won't be reported as undefined symbols.
    • All references between resource, personality and monkeyc files are tracked, so that "Goto Definition" and "Goto References" will find them (including the device-specific, built in personality libraries).

    Bug fixes

    • Fixes a bug in the post build optimizer where it could insert the definition of a PRE variable after an expression that might throw, even though the variable was referenced in the catch block (this was unlikely - it didn't happen in any of the open source projects I build/test, but did happen in a test case I wrote to demonstrate a bug in Garmin's "finally" handling)
    • Fixes a bug that could cause references from resources to .mc files to go missing from "Goto Definition" and "Goto References".
  • v2.0.62 is out.

    For the extension, this is a very minor update. It just fixes a bug in the extension's type checker that could incorrectly report errors for an assignment to a local if there was also a global (or in scope member variable) with the same name.

    The optimizer now includes a command line tool to analyze .cft files. Documention is here

  • v2.0.63 is out. This fixes a couple of fairly unlikely bugs, and extends constant folding to work around the bug reported here.

  • v2.0.64 is out. It makes hover, completion, and documentation links a little more accurate, and fixes the bug described here.

  • I'm having a bit of trouble exporting my optimized build with this error in 2.0.64:

    ERROR: Internal: TypeError: Cannot read properties of undefined (reading '0')
    TypeError: Cannot read properties of undefined (reading '0')
        at collectClassInfo (/Users/lances/.vscode/extensions/markw65.prettier-extension-monkeyc-2.0.64/node_modules/@markw65/monkeyc-optimizer/build/chunk-PUYLJGKM.cjs:17413:51)
        at analyze (/Users/lances/.vscode/extensions/markw65.prettier-extension-monkeyc-2.0.64/node_modules/@markw65/monkeyc-optimizer/build/chunk-PUYLJGKM.cjs:17583:3)
        at async optimizeMonkeyC (/Users/lances/.vscode/extensions/markw65.prettier-extension-monkeyc-2.0.64/node_modules/@markw65/monkeyc-optimizer/build/chunk-PUYLJGKM.cjs:17744:17)
        at async MessagePort.<anonymous> (/Users/lances/.vscode/extensions/markw65.prettier-extension-monkeyc-2.0.64/node_modules/@markw65/monkeyc-optimizer/build/worker-thread.cjs:34:66)

    However, the 'Build and Run Optimized Project' seems to run fine. This bug seems to have cropped up around version 2.0.50.

    The error is only for one of my projects. On my other one, the optimizer works great. (I couldn't believe that one went from code+data = 66897 to 59203). Thank you so much for working on this project!

  • I'm having a bit of trouble exporting my optimized build with this error in 2.0.64

    Unfortunately, the error just tells me that something went wrong earlier. I think it's related to the project's resources, but it's hard to tell. I think there might be a clue in the developer tools console.

    Go to "Help - Toggle Developer Tools" in VSCode and make sure the console tab is selected at the top (I think thats the default). There are probably quite a few messages there already, so hit the "Clear console" icon in the top left (a circle with a diagonal line through it), and then try to export your project. Hopefully an error message will appear in the console, and that might tell me what's going wrong.

    If that doesn't work, I can send you a version with more logging enabled, and hopefully pin things down.