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]

  • sdk 6.4.2, prettier: 2.0.74 I get strange warnings (red underline i the editor) from pmc-analysis:

    <menus>
        <menu2 id="SettingsMainMenu" title="@Strings.settingsTitle">
            <menu-item id="menuFoo" label="@Strings.settingsFooTitle" subLabel="@Strings.fooSub"/>
            <menu-item id="menuBar" label="@Strings.settingsBarTitle" subLabel="@Strings.barSub"/>
        </menu2>
        <menu2 id="SettingsFieldMenu" title="@Strings.settingsFieldTitle">
            <menu-item id="fieldHehe" label="@Strings.fieldHehe"/>
            <menu-item id="fieldHihi" label="@Strings.fieldHihi"/>
        </menu2>
    
    </menus>
    
    class MySettingsMenu extends Rez.Menus.SettingsMainMenu {
    
        function initialize() {
            Rez.Menus.SettingsMainMenu.initialize(); // pmc-analysis: $.Toybox.WatchUi.Menu2.initialize expects 1 arguments, but got 0
        }
    }
    
    class Moo {
        hidden var settingsFieldMenu as Menu2?;
        function initialize() {
            settingsFieldMenu = new $.Rez.Menus.SettingsFieldMenu(); // pc-analysis: $.Toybox.WatchUi.Menu2.initialize expects 1 arguments, but got 0
        }
    }

  • sdk 6.4.2, prettier: 2.0.74 I get strange warnings (red underline i the editor) from pmc-analysis:

    Yes, I can repro. You can safely ignore it, but I should have a fix shortly.

  • v2.0.75 is out. It fixes this issue, and also adds proper support for tuple types (as introduced in sdk-7.x).

  • Feature-request: add API Level where available.

    What I mean is that currently when I stop the mouse over something then it displays the hint. For example I'm over: 

    System.getDeviceSettings().systemLanguage;
    On the DeviceSettings I see the API Level. But on systemLanguage, even though it correctly links to https://developer.garmin.com/connect-iq/api-docs/Toybox/System/DeviceSettings.html#systemLanguage-var, where I can see that this field is only from API Level 3.1.0, the hint doesn't include the API Level.
  • The reason you currently see a lot more info for system functions and methods is because they're all documented explicitly in <sdk>/bin/api.debug.xml. If you look, you'll find that every <functionEntry> has a corresponding <documentation> sub-entry.

    There's no corresponding documentation for anything else. Or rather, it is there, but it's in the <sdk>/doc/... files which are just html, rather than machine readable xml like api.debug.xml. So at the moment, all I display is the name, type info, and a link to the docs.

    But I guess I already have a path and fragment (for the link), so finding the right HTMLElement(s) shouldn't be too hard. Then I would need to convert it to markdown; but I already do that for the function documentation, and this would probably be quite similar.

    So... maybe?

  • This is probably a Garmin bug in SDK 7.0.2-beta:
    ERROR> fenix6: MyDataField.mc:16:30: Argument 1 to $.Toybox.WatchUi.loadResource expected to be Toybox.Lang.ResourceId but got Symbol

    class MyDataField extends WatchUi.SimpleDataField {
        function initialize() {
            SimpleDataField.initialize();
            label = loadResource(Rez.Strings.simpledatafield) as String; // in this line
        }
    }

  • No, that's my bug. I'd not noticed that particular problem because of things like this issue, which seems to come up a lot in my code.

    I think there's a simple fix for this one though.

  • But in my case there are no explicit types involved in my code.

  • I managed to reproduce another bug. Sent you the POC as zip in email.