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]

  • I forget which sdk it was announced with, but it’s documented:

    [https://developer.garmin.com/connect-iq/core-topics/resources/#strings]

    And yes, unlike the other resource qualifiers, it does work with older devices (since this is a compile-time only change).

    IIRC this unfortunately doesn’t work for strings that you want to use for FIT contributor resources (which are also not part of the runtime.) It should’ve been “nonruntime” instead of “settings”.

  • (:sdk6) typedef ResourceId as Symbol;
    ERROR: SyntaxError: source/sdk7.mc:3,9: Expected "class", "const", "enum", "function", "hidden", "module", "private", "protected", "public", "static", "var", or whitespace but "t" found.
  • (:sdk6) typedef ResourceId as Symbol;
    ERROR: SyntaxError: source/sdk7.mc:3,9: Expected "class", "const", "enum", "function", "hidden", "module", "private", "protected", "public", "static", "var", or whitespace but "t" found.

    It seems that typedef doesn’t create an actual symbol that can be used at runtime (it’s probably just a compile-time type alias), therefore it can’t be used with an annotation.

  • Perhaps you could create a wrapper class that returns a Symbol and use a similar annotation scheme, although that’s a lot of overhead and work (especially to change every piece of code that uses a resource ID.)

  • but it works without the prettier optimizer ;)

  • Oic, never mind then. (Wrong again!)

  • Maybe ResourceId is an undocumented reserved type in 6.4, when they were getting ready for 7? Have you tried using your own type? This works for me:

    typedef rezRef as Symbol;  // SDK 6
    //typedef rezRef as ResourceId;  // SDK 7+

  • I think he's saying that the prettier won't allow you to annotate a typedef, but the regular compiler does.

    It sounds like the syntax definitions for the prettier need to be updated.

  • I've implemented all the new bytecodes, and done some testing, but before I update the extension would you mind testing it out on your code?

    To do that you need to install the monkeyc-optimizer in your project directory

    npm install -D @markw65/monkeyc-optimizer

    Then make sure "Use Local Optimizer" is enabled in your project settings. Then when you build it will use the version you installed, rather than the version included with the extension.

    If that goes ok, let me know and I'll update the extension.

  • The 1st thing I tried failed: SDK 6.4.2, fr230. Let me know if you need the full stack trace.

    Using project-local @markw65/[email protected]
    ERROR: Internal: TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.
    TypeError: A dynamic import callback was not specified.

    I can't test with SDK 7.1.0 + fr230 because of a Garmin bug in the compiler.

    Same error with SDK 7.1.0, fr245, fr255.