Strange VSC editor behaviour with SDK 8.2.1

Due to the fact that soon only SDK 8.x.x apps can be loaded into the store, I have now switched from 7.4.3 to 8.2.1.

I have to get used to the changed editor behavior, but what I really miss is:

A)
With 7.4.3 a text completion for variables and API was suggested. If I type “dc.fill”, for example, a context menu appears with all possible completions.
With 8.2.1 I have no suggestions.

Can I set this somewhere?

B)
After typing a line of code, it often remains underlined in red (i.e. typed incorrectly) although there is no error in the line of the code.

EDIT:
Meanwhile I found out that A) and B) works fine on code for small IQ apps.
But for datafields with a couple of thousand code lines it does not work.
(worked fine with 7.4.3)

  • It works out of the box, if the code doesn't have "issues". Once there are things that bother it (like errors) then some of the basic things don't work. Now what are those "issues" might depend not only on your code but also on the type checker level.

  • TL;DR

    - the new autocompletion in SDK 8.0+ is smart (context-sensitive), the old autocompletion in pre-SDK 8.0 was dumb (big list of all keywords)

    - there are many new language features in SDK 8.0, along with the new autocompletion

    - to use these features:

    - type checking has to be enabled

    - your project must have been successfully built once

    - (for most features) your project must not have any errors (including "real-time" errors which are detected after you make a change, but before you build)

    Details

    With 7.4.3 a text completion for variables and API was suggested. If I type “dc.fill”, for example, a context menu appears with all possible completions.
    With 8.2.1 I have no suggestions.

    Prior to SDK 8.0 (beta), Monkey C autocompletion was just a dumb list with all known keywords, as opposed to only the keywords which are valid in the current context.

    This is because older SDKs didn't support a "language server", where VS Code actually understands the structure of your code, to support features such autocompletion. SDK 8.0 was the first SDK to support a language server in Monkey C, which provides features described here:

    https://forums.garmin.com/developer/connect-iq/b/news-announcements/posts/system-8-beta-now-available

    This Monkey C extension offers several features, including:

    • Real-Time Errors and Warnings – These will display when editing Monkey C, Jungle, Settings, MSS and Resource XML files. Any reported errors or warnings will display in the Problems tab.
    • Autocompletion – When editing Monkey C, Jungle and MSS files, autocompletion suggestions will be based on the detected scope. In the Monkey C editor, you can autocomplete functions with argument and type information by autocompleting the function keyword in a class or module.
    • References – You can find all references of a variable, symbol, function, class or module by right-clicking on it and selecting “Find all References” from the context menu. You can also search for a symbol in the document by summoning the command palette and typing @symbol name or search the entire workspace by summoning the command palette and typing #symbol name.
    • Hovering – See type information about a variable, function name, class or module by hovering the mouse over the symbol in question.
    • Go to Definition – You can jump to the definition of any variable, symbol, resource ID, function, class or module by selecting “Go to Definition” from the context menu.
    • Folding Ranges – Comments, imports and regions of code can now be folded.

    To use these features, your project needs to have a type check level of gradual or higher.

    Now when VS Code shows autocompletion suggestions for Monkey C, they are supposed to be relevant to the current context, based on the IDE's understanding of your code and the CIQ API.

    Having said that:

    - type checking has to be enabled (as mentioned above)

    - you have to successfully build at least once for the language server to work (i.e. explicitly, using the Monkey C: Build Project command or implicitly, using the Run command)

    - every time you make a change to your project source, the language server will compile your code in the background, in order to support language features. (Note that this background build does not affect any of the outputs in the bin/ folder - to build your code in a way that can be run in the simulator or sideloaded to the device, you still have the build the usual way.) If the background build fails (due to a syntax error or non-syntax error), then most language features will become unavailable (except for real-time errors and warnings).

  • Thank you,  !

    I will have a closer look based on your statements.

  • I have done now many tests with editing my datafields with SDK 8.2.1.
    Here are my findings:


    1) "small" datafields with about some hundrets of code lines:

    Everything works as promised.

    -Real-Time Errors and Warnings: work immediately

    -Autocompletion: check

    2) "large" datafields with about some thousends of code lines - which are at the edge of "stack overflow" or "out of memory" for elder (no Graphics Pool) devices:

    Nothing works as promised.

    -Real-Time Errors and Warnings: 
    appear immediately but do not clear for minutes! See an attached screenshot: There is a line marked as error - which is no error since typing was completed, but stays as error even after the project has built sucessfully. The red error line disappears after some minutes! 

    -Autocompletion: does not work. You have to wait a long time for appearing. That's of no help while typing.

    As stated in opening post:
    Autocompletion works fine and immediately with SDK 7.4.3!

    every time you make a change to your project source, the language server will compile your code in the background

    That seems to be the problem for large coded datafields (and maybe weak laptops...?).

  • Autocompletion works fine and immediately with SDK 7.4.3!

    But as stated in my reply, that's not the same kind of autocompletion.

    "dumb" autocompletion (pre-SDK 8.0): displays a list of all known CIQ keywords, regardless of context

    context-sensitive autocompletion (SDK 8.0 and higher): displays only keywords which are relevant in the current context (this requires the background compilation task to complete very quickly, as the IDE / Monkey C extension can't "understand" your code without compiling it)

    That seems to be the problem for large coded datafields (and maybe weak laptops...?).

    Yeah :/. If errors take minutes to go away, it seems like the background compilation task is stalling (even if the foreground compilation task completes relatively quickly).

    Maybe you should file a bug report and provide some sample code (and describe your laptop specs).

    I do think it's a shame that the extension doesn't remember the last known "good state" of the program in the case when errors are detected, so that some of these features could hypothetically continue to work. (Yeah, I can see problems with that approach, like if someone pastes in a huge amount of text which has an error in it. If this text drastically changes an existing file, it could mean that most memorized line numbers for that file would be wrong.)

    It also seems like the syntax analysis of the source code (which seems to be done with antlr) cannot be separated from the "real" compilation step, which mean that even if your program is syntactically correct but contains some semantic error, most of the language features will fail.

    Also, if your code has a syntax error, then the language features will fail. (Contrast with support in VS Code for languages like js and python, where syntax errors aren't showstoppers.)

  • But as stated in my reply, that's not the same kind of autocompletion.

    "dumb" autocompletion (pre-SDK 8.0): displays a list of all known CIQ keywords, regardless of context

    Yes, I know!
    But "dumb autocompletion" is better as a not working autocompletion!

  • But "dumb autocompletion" is better as a not working autocompletion!

    Yeah, I get it. I also get why Garmin wouldn't want to "fall back" to dumb autocompletion.

    From their POV all the language features are just supposed to work (and should therefore supersede any older, inferior workarounds).

    All the more reason to file a bug report.

    Someone else recently posted that Monkey C builds were taking minutes (I think this includes "foreground" builds).

  • Someone else recently posted that Monkey C builds were taking minutes (I think this includes "foreground" builds).

    To build datafields - even with a lot of code - does not take much longer than 7.4.3 on my laptop. Maybe some of 10 seconds more.

    Another problem for me is (a little off topic here):
    I cannot connect to any ANT+ device via ANT+ stick with 8.xx simulator anymore (WIN 10 system).
    In the window no device appears - and I have waited a looong time...)

    Works fine with SDK 7.4.3!

    I'm wondering that nobody else reports this issue...

  • To build datafields - even with a lot of code - does not take much longer than 7.4.3 on my laptop. Maybe some of 10 seconds more.

    Then whatever is happening with the "background build" (in the language server) might be a bug, and it's def worth reporting.

  • How do they expect language server to provide autocompletion features for code that is not complete and can't be built by definition?