Article
· Mar 10 6m read

InterSystems VSCode ObjectScript Extension Pack in glance

Introduction

Visual Studio Code (VS Code) is a free source code editor made by Microsoft for Windows, Linux, and macOS. It provides built-in support for JavaScript, TypeScript, and Node.js. You can add extensions to provide support for numerous other languages including ObjectScript.

The InterSystems extensions enable you to use VS Code to connect to an InterSystems IRIS server and develop code in ObjectScript. The Visual Studio Code Documentation is an excellent resource on VS Code, so it is a good idea to be familiar with it.

Development in ObjectScript involves both your local client machine and an InterSystems IRIS server. Because both resources are required, workflow is different from that typical for many languages. Source code files are edited on the client, and saved to the local disk where they can be managed with a Version Control System. In addition, source files are exported to an InterSystems IRIS server, where they can be compiled, run, and debugged.

Below is the list of VSCode extensions:

1 - InterSystems Server Manager Extension

InterSystems Server Manager is a Visual Studio Code extension for defining connections to InterSystems servers. These definitions can used by other VS Code extensions when they make connections.


Installation

Open VSCode and click on Extensions Icon
Extensions button.

Type intersystems in the search field to find these extensions in the Marketplace, as illustrated in the following screenshot:


Click on Install, Once installed InterSystems   Icon will appear in the sidebar. Click on it

1.1 Define Connections to IS Server

Click on Add Server (+ icon)

Enter the name of the server e.g "Local Instance", description (Optional), Hostname or IP address, Port of Web server, and Username.





The first time you expand a server in the tree VS Code displays a modal dialog asking for your permission:


1.2 View Server Tree

Server Manager displays connection definitions as a tree on an InterSystems Tools view:

In this tree, you can:

  • Launch the InterSystems Management Portal, either in a VS Code tab or in your default browser.
  • List namespaces.
  • Add namespaces to your VS Code workspace for viewing or editing source code on the server, including web application (formerly CSP) files, with the ObjectScript extension.
  • Tag favorite servers.
  • Set icon colors.
  • Focus on recently used connections.
  • Add new servers, and edit existing ones.


1.3 Launching Management Portal

When you hover over a server entry in the tree two command buttons let you launch InterSystems Management Portal.

The first button uses VS Code's Simple Browser feature, which creates a tab alongside any documents you may have open. The second button opens Portal in your workstation's default web browser.

1.4 Amending and Removing Servers

From a server's context menu, or from Server Manager's top-right '...' menu, choose Edit Settings. This opens VS Code's Settings Editor and filters its contents.

Click on Edit in settings.json link

The Server can be added, modified, or deleted by modifying the settings

2 - InterSystems ObjectScript Extension

This extension provides language support for Visual Studio Code. Before installing this extension you must install InterSystems Server Manager Extension as it has a dependency on it.
Just click on the Install button to install the Extension.

    2.1 View/Edit code

    Once installed, Follow below steps to view/edit code in Namespace
      

    Now we can Add/Modify code from the VSCode editor. Click on the Add New file icon to add a new class
     


    2.2 Save and Compile Code

    While saving, the system will compile and save the code to the server

     

    2.3 Code completion

    Upon writing code, this extension will provide a code completion option
     
     

    2.4 Intellisense Support

    This extension provides Intellisense support for commands, system functions, and class members
     
     

    2.5 Code highlighting

    Select any text from the code and the system will highlight all the related appearances
         

    2.6 Debug code

    Click beside the code line number to add a breakpoint, and click Debug on the top of the method signature

     

       

     

    2.7 Direct Access

    This extension provides Direct access to edit or view server code in the VS Code Explorer via isfs and isfs-readonly FileSystemProviders. Server-side source control is respected.

    2.8 Go to definition support

    Go to definition for ObjectScript classes, class members, macros, routines, routine labels, and embedded SQL tables, fields and class methods and queries invoked as SQL procedures.
     

     

    3 - InterSystems Language Server Extension

    Language Server is meant to provide the language-specific smarts and communicate with development tools over a protocol that enables inter-process communication.
    Before installing this extension you must install InterSystems Server Manager and InterSystems Objectscript Extension as this Extension has a dependencies on it.
     

    3.1 Semantic token-based coloring

    Semantic token-based coloring for InterSystems ObjectScript classes, routines and CSP files, with support for embedded languages like SQL, Python, HTML, XML, Java, JavaScript and CSS.
     

    3.2 Embedded Language Support

    Provide support for embedded languages like SQL, Python, HTML, XML, Java, JavaScript and CSS.

    3.3 Hover information for ObjectScript commands

    Hover information for ObjectScript commands, system functions, system variables, classes, class members, macros, preprocessor directives, UDL keywords, Parameter types, Storage definition keywords, and embedded SQL tables, fields and class methods and queries invoked as SQL procedures.
     

    3.4 Override Class Members

    To override inherited class members, Right click and select the Override Class members option.

     
    Select the class member type for override from the list. e.g select class member type "Method"

    Search/select %OnNew method


    Enter desired code


    3.5 Code Completion (ObjectScript/XML)

    Code completion for ObjectScript classes, class members, system functions, system variables, macros, include files, package imports, preprocessor directives, UDL keywords, UDL keyword values, UDL Parameter types and UDL Storage definition keywords. Code completion for properties referenced using instance variable syntax (i%PropertyName) must be triggered manually using Ctrl-Space with the cursor immediately after the i%
       


    3.6 Method Signature Help

    Signature help for ObjectScript methods and macros that accept arguments.

    3.7 Code Linting

    Code linting for ObjectScript and UDL that checks for the following:

    • Syntax errors, including for embedded languages.
    • References to local variables that are undefined.
    • Classes and routines that don't exist in the database.
    • Invalid UDL Parameter types.
    • Mismatches between declared UDL Parameter types and the assigned value.
    • Classes, Methods, Parameters and Properties that are Deprecated.
    • $ZUTIL functions that are deprecated or have been superseded.

      

    3.8 Folding Ranges

    The extension supports Folder Ranges for the following:

    • ObjectScript code blocks (If/ElseIf/Else, Try/Catch, For, While, etc.)
    • UDL class members
    • ObjectScript routine labels
    • UDL descriptions
    • ObjectScript documentation comments (/// in first column)
    • XML tags in XData blocks
    • Storage XML tags
    • JSON in XData blocks
    • %DynamicObject and %DynamicArray
    • ObjectScript preprocessor code blocks
    • Multi-line macro definitions
    • Dotted Do blocks
    • Embedded code blocks (SQL, HTML, JavaScript)

       

    3.9 Code refactoring

    Wrapping a block of ObjectScript code in a Try/Catch block.
     
     
       
    In the same way, we can Extract a block of ObjectScript code from an existing method to a new method

    3.10 Type Hierarchy Provider

    for ObjectScript classes to show subclasses and superclasses in a hierarchical tree view:
     
     
    NOTE : The best way to install and use these extensions is by installing the "InterSystems ObjectScript Extension Pack" which installs a set of the above extensions.

    Click on install from the extensions to install a set of 3 extension packs.



    Thanks

    Discussion (5)3
    Log in or sign up to continue

    Hi Muhammad, great article! 

    Do you know by chance how to switch from an instance to another through the ObjectScript extension? 

    I have a local folder where I'm setting up a Docker instance, but the folder is linked to my IRIS local instance and it is not possible to unlink them even by doing Toggle connection or Refresh connection. Of course, I would like to connect to my containerized instance instead. 

    Thanks :)