Question
· Nov 3, 2021

Reformatting ObjectScript in VSCode

Hey everyone.

I was wondering if anyone had come across a way of reformatting ObjectScript within VSCode.

I have the various Intersystems Extensions installed (InterSystems Language Pack,  InterSystems ObjectScript,  InterSystems ObjectScript Extension Pack,  InterSystems Server Manager) but a formatter does not seem to be something included within this variety of extensions.

Discussion (20)6
Log in or sign up to continue

Hey Ben.

Specifically looking to be able reformat the code layout. For example, if I was working with javascript or json, I can use the keyboard command Shift+Alt+F and it will reformat the code:

However, when I attempt this with the language set to ObjectScript or ObjectScript-Class, pressing that same keyboard shortcut gives a popup stating no formatter is installed and it directs me to the Extension Marketplace

@Julian Matthews The Language Server extension includes an ObjectScript formatter with the following features:

  • Normalize the case of ObjectScript commands, system functions and system variables.
  • Normalize the usage of short or long versions of ObjectScript commands, system functions and system variables.

You can invoke it like any other formatter in VS Code. This VS Code doc page has more information on formatting in VS Code. The Language Server README has more info on its features and configuration settings.

Yes, that's expected behavior. The vscode-objectscript extension defines the languages based on file extensions:

      {
        "id": "objectscript",
        "aliases": [
          "ObjectScript"
        ],
        "extensions": [
          ".mac",
          ".int"
        ]
      },
      {
        "id": "objectscript-class",
        "aliases": [
          "ObjectScript Class"
        ],
        "extensions": [
          ".cls"
        ]
      },
      {
        "id": "objectscript-macros",
        "aliases": [
          "ObjectScript Include"
        ],
        "extensions": [
          ".inc"
        ]
      },
      {
        "id": "objectscript-csp",
        "aliases": [
          "ObjectScript CSP"
        ],
        "extensions": [
          ".csp",
          ".csr"
        ]
      },

Hey Ben.

I use a program called ScreenToGif.

Since moving to remote working it has become invaluable for demonstrating functionality for apps via email or IM. However it gets the most use when I'm reporting bugs to a supplier, or in this case how I'm incorrectly using VSCode extensions smiley

I'm pretty sure it's a Windows-only app, so you may need to find an alt if you're on another OS and wish to try it out.

*edit*

As a tip, try to keep any gifs you do make for bug reporting fairly short. No one wants to be waiting 2 minutes for a gif to loop because they missed the important part!

Has there been headway in formatting longer lines of ObjectScript? Example:

Relationship PhoneNumbers As isc.sample.rest.phonebook.model.PhoneNumber(%JSONFIELDNAME = "phones", %JSONINCLUDE = "outputonly", %JSONREFERENCE = "object") [ Cardinality = children, Inverse = Person ];

I prefer lists of parameters to be visible in one view rather than having to scroll across the screen. I think it would be better if this were added to the existing functionality rather than me writing my own script to format ObjectScript code in this manner.