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]

  • Fixed in v2.0.108.

  •     markw65 said:
        Oops. Should be fairly easy to fix. I'll take a look.

    Works now. Thanks.

  • Is there a way to ignore this warning?

    WatchFaceDelegate will only be found when compiled with compiler2 at -O1 or above[pmc-analysis]

  • You can set prettierMonkeyC.checkCompilerLookupRules to Off. Go to Settings, type checkCompiler into the search box, and set it at whatever level (ie user, or workspace) you prefer.

    I had started to think I should get rid of that option, since the last "compiler 1" was released a couple of years ago. But I recently wanted to test a data field that used a GenericANT channel, and had to go back to 4.0.10, because apparently it's been broken since then. This option really helped find all the issues...

  • That's interesting. What is broken in GenericChannel? I use it in my datafield, used by 200k users. I do have some (<100) strange errors but nothing that seems to be broken totally.

  • Sorry, I was just referring to the simulator. I needed to debug the ANT communications. Anything after 4.0.10 doesn’t work for me (or various others, based on a number of threads on the subject). But on a real device, everything works perfectly regardless of sdk. 

  • It looks like there's a problem in the analysis engine.

    PMC doesn't show any errors and doesn't do live code analysis for my project, if I have a code similar to this:

    class BaseClass {
        function doThings() as Void {}
    }
    class ParentClass extends BaseClass {
        function doThings() as Void {}
    }
    class ChildClass1 extends ParentClass {
        function doThings() as Void {
            ParentClass.doThings();
        }
    }
    class ChildClass2 extends ParentClass {
        function doThings() as Void {
            ParentClass.doThings();
        }
    }
    
    class Test {
        function test(object as BaseClass) as Void {
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
            object.doThings();
        }
    }
    

    If I run

    node test/test.js --analyze-only --jungle ...

    I see

    FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

    With a little modifications, like removing one of doThings() calls or removing ChildClass2, CLI analysis is OK, except for unexpectedly long processing time for such simple code.

  • And there's a new one with enums:

    import Toybox.Lang;
    
    enum Enum1 {
        VALUE1,
    }
    enum Enum2 {
        VALUE2,
    }
    
    function test(flag as Boolean) as { :x as Number } {
        // Expected $.test to return { :x as Number } but got { :x as Enum }
        return { :x => flag ? VALUE1 : VALUE2 };
    }
    

  • v2.0.109 is out, and fixes both this enum issue and the out of memory issue reported above

  • The analysis is now working again, thanks.

    But I still see the same error message for the enums example code. Plugin version is 2.0.109, and VS Code restart doesn't help.