Monkey Code Keeper - Tool for developers

Hello, I am currently working on a couple of watchfaces, the last one I have created is My Day 24. And let's say, these tools for developers could be better :) Maybe I am too spoiled from C# and ReSharper plugin, but I wanted to have something better than the current Eclipse SDK.

Currently you can easily make a typo in a variable name, or copy paste some wrong code. The project still compiles and no errors are shown, but the app will crash on a real device in production. It is specially annoying if you have multiple files for each device (one file for Fenix 3, another for Vivoactive) and you change for example the number of parameters of a function, but just in one file. You will not see any crash on your device, but people will report you that it does not work.

So I have created a new tool, a desktop Windows app: http://bit.ly/codekeeper You can select your project folder with .mc files. You can leave this tool opened next to Eclipse, for example on a second monitor. And each time you save an .mc file, the tool will automatically refresh and show the warnings and errors. See screenshots attached.

What's implemented, errors:
- Variable is used, but it was not declared (or it is used before it was declared in the block)
- Function is called, but it was not declared in the same block (on in the global block)
- Function is called, but it has incorrect number of parameters
- Function is called on an instance of a class, but has incorrect number of parameters

Warnings:
- Variable was declared, but not used in the block
- Variable is declared more than once with the same name (for example in a global block and in the function)
- Function is declared more than once with the same number of parameters
- Variable was passed as a parameter of the function, but not used in the function
- Variable was initialized more than once by new keyword

Currently objects are not checked for null reference exception, it would require a better parser (with value propagation into functions and other blocks). I have also not tested yet the new 2.4.0 features like barells and jungle files. Also some weird constructs from the Monkey C language will most likely not work, but you can check it and see it. I have tested multiple Monkey C projects from Github, but there will always be some edge case where it will fail.

You can check the parsed tree (if the code was parsed correctly), or you can edit the list of system functions and variables that should be ignored. And if you are really interested, you will find a donate button on a Help / About screen :)

Download: http://bit.ly/codekeeper

Send me any feedback if you have. community.garmin.com/.../1296466.png community.garmin.com/.../1296467.png community.garmin.com/.../1296468.png community.garmin.com/.../1296469.png community.garmin.com/.../1296470.png
  • This tool still can find some issues in SDK examples (3.0.7):
    Error: Variable mProperties is not declared in function onStop source\BackgroundTimerApp.mc, line 31

    function onStop(state) {
    if( mTimerView ) {
    mTimerView.saveProperties();
    mTimerView.setBackgroundEvent();
    }
    Toybox.System.println(mProperties);
    }

  • Hello, thank you for your feedback :) Yes, it's still not ideal…

    We are currently working with Pavla Balikova on a new project - Visual Studio integration with Monkey C code colorization, brace matching and intellisense from the SDK. It should work bettter. But it is still in a very early stage… It will allow to run a simulator from the Visual Studio, deploy to the watch etc. We plan to publish it as a VSIX extension and on the Github, but it needs to work first.

  • I meant that it worth to check any project with your tool, it is useful still. No matter how the tool is old. Some new developers will see this topic and get involved. I'd like to see VS extension too, thanks for your time and passion!

    In that particular case the mProperties variable is not documented and probably serves for some internal purposes.
  • Besides not supporting current sdk features such as debugger and run no evil, to me it seems also like a lot of work that is hard to maintain and keep up to date with new sdk developments. Without active maintenance I see this get broken pretty soon...

    Wouldn't it be better to create an extra eclipse plugin with the features you're missing?

  • Yes, it will be always unofficial and incomplete. And it will be a lot of work.

    But are you going to live with the Eclipse forever? :) It's not usable for any real development. Even simple brace matching, code formatting, keyboard shortcuts between the windows etc., it's not there. There is practically no code completion when you press the '.' character. Before the SDK 3.0.0 it did not even check whether the property was declared.

    The IDE can do so much, check the method parameters, propose the correct format of parameters, show the documentation…
  • Yes, it will be always unofficial and incomplete. And it will be a lot of work.

    But are you going to live with the Eclipse forever? :) It's not usable for any real development. Even simple brace matching, code formatting, keyboard shortcuts between the windows etc., it's not there. There is practically no code completion when you press the '.' character. Before the SDK 3.0.0 it did not even check whether the property was declared.

    The IDE can do so much, check the method parameters, propose the correct format of parameters, show the documentation…


    I agree there are many issues/limitations with the CIQ Eclipse plugin. Just last year you couldn't have the same file open in two views without corrupting data.

    But I think Peter is arguing the merits of an Eclipse plugin vs a Windows-only desktop app. Eclipse itself is pretty usable IMO for real development, despite being pretty bloated. I think it would be nice to have a cross-platform solution....

    Thanks for this tho. It looks really nice, although I haven't had a chance to try it out.
  • If the code is there and it's opensource, everyone can rewrite it, for example for Visual Studio Code... I don't feel like I would like to write an extension in JavaScript / TypeScript, I am comfortable with C#.

    But just after a few days of work, I think it's already useful.community.garmin.com/.../1438150.png
  • The intellisense is working pretty well :)

  • The intellisense is working pretty well :)


    Sweet!

  • Just want to say thanks again, good tool. Up!