Skip to main content

Edit Code Directly on an InterSystems Server

This page describes how to configure a Visual Studio Code (VS Code) workspace for editing code directly on an InterSystems® server. It assumes that you have already defined a connection profile for your server using the InterSystems Server Manager extension for VS Code and that you have set up a workspace for server-side editing.

To access code directly on an InterSystems server, you must add a virtual folder to a workspace which corresponds to a set of code documents on that server. Add a Virtual Folder to Your Workspace describes the convenient interfaces that the InterSystems ObjectScript extension for VS Code provides for adding a virtual folder for the full non-system contents of a server’s namespace or for a filtered subset of those contents. You can configure a virtual folder to allow its contents to be edited, or (when desired) to allow read-only access.

Editing the Workspace File describes how to further configure a server-side workspace’s virtual folders (as well as other settings) by editing the workspace settings file directly..

In situations where it is necessary to define settings for specific server-side folders independently, Configure an InterSystems Server to Maintain Folder-Specific Settings outlines the additional server-side configuration required to support this.

Once you have configured a virtual folder for your workspace, any edits you make to code within the virtual folder are saved and compiled directly on the server, For instructions on how to test and debug your code using the InterSystems ObjectScript Extension Pack for VS Code, refer to the Develop ObjectScript Unit Tests page and the Run and Debug Your ObjectScript Code page, respectively.

Add a Virtual Folder to Your Workspace

To quickly create a virtual folder in your current workspace which accesses all the user-created classes and routines within a single namespace on your server, perform the following steps:

  1. Navigate to the InterSystems view container by selecting the InterSystems button generated description: objectscript button in the Activity Bar.

  2. In the InterSystems Servers view, expand the server you want to connect to. If necessary, sign into the server.

  3. Expand your target server’s Namespaces directory.

    • To view or edit source code across an entire namespace:

      1. Hover over the target namespace to reveal its command buttons, as illustrated in the following image:

        Tree view of server namespaces

    • To view or edit source code for a single project only:

      1. Expand the directory for the namespace which contains the target project.

      2. Expand the Projects directory for that namespace.

      3. Hover over the target project to reveal its command buttons, as illustrated in the following image:

        Tree view of projects within namespace

      For more information about projects, see Work with Projects.

  4. Select the appropriate command button for your use case:

    • Select the edit (pencil) button to add a virtual isfs:// folder to your workspace. The isfs protocol allows you to make direct edits to the code on the server.

    • Select the view (eye) button to add a virtual isfs-readonly:// folder to your workspace. The isfs-readonly protocol allows you to view code on the server, but prevents you from making any changes to it.

    • Hold the Alt or Option key while selecting the edit or view button to add a folder that also gives you access to server-side web application files (such as .csp files).

    For an entire namespace, the virtual folder has a URI with the form isfs://server:namespace/ or isfs-readonly://server:namespace. For a virtual project folder, the URI has the form isfs://server:namespace/?project=projectName or isfs-readonly://server:namespace/?project=projectName.

    Note:

    The string isfs which appears in the URI for folders configured for server-side editing stands for InterSystems File Service. It is a simple protocol which was created by InterSystems to implement the VS Code FileSystemProvider APIOpens in a new tab. This API allows a remote location to be represented as a local one. It works well for making artefacts in an InterSystems IRIS namespace look like local files.

If you require more granular control over the contents of your virtual folder, see Configure a Custom Virtual Folder.

Once you have added a virtual folder, VS Code opens the Explorer view showing the added namespace. In the following image, the workspace includes the Sample and User packages in the src folder on the client, and the Sample and User packages in the USER namespace on the server, with read-only access:

Sample workspace with server-side content

When you add a virtual folder to an empty or unsaved workspace, VS Code stores configuration settings for this virtual folder within a temporary file. You can save these workspace settings for later access in an arbitrarily-named file with a .code-workspace extension. You can also configure workspace settings by modifying this .code-workspace file directly, as described in Editing the Workspace File.

Important:

If you are editing your code on the client-side (for example, to use Git for source control), InterSystems strongly recommends that you avoid using isfs:// to perform server-side editing within the same workspace. Where it is necessary to access server-side code within a workspace which is configured for client-side editing, use isfs-readonly (as in the preceding example) to avoid introducing conflicts between server-side and client-side code.

Configure a Custom Virtual Folder

If you want more granular control over how your server-side workspace is organized, you can configure a virtual folder which accesses a subset of documents within a server’s namespace, filtered by various criteria. You can add a filtered virtual folder by performing the following steps:

  1. From any view container, invoke the ObjectScript: Add Server Namespace to Workspace command from the Command Palette.

    Alternatively, if you do not currently have a workspace open, you can navigate to the Explorer generated description: explorer button view and select the Choose Server and Namespace button, as shown in the following image:

    Explorer view with Choose Server and NS button

  2. Pick the name of an existing server connection profile from the list, or click the + (plus) button to add a new server connection profile.

    Drop-down list of available servers

  3. If necessary, sign into the server.

  4. Choose a namespace from the list retrieved from the target server.

    Drop-down list of namespaces

  5. Choose an access mode—editable (isfs://) or read-only (isfs-readonly://) from the list.

    Drop-down access mode selector

  6. Choose the category of files to display (code files, web application files, or contents of a server-side project).

    Drop-down file type selector

    • If you choose to show web application files, you have the option to specify which web application you want to display files for:

      Drop-down web app selector

    • If you choose to show the contents of a project, select the project (see Work with Projects for more information about working with projects):

      Drop-down list of project names

    • If you choose to create your own filter of files to display, select the filter options:

      generated description: queryparams

VS Code adds the virtual folder which you have configured to your current workspace.

Editing the Workspace File

When you use the ObjectScript extension to add a server-side virtual folder to an empty or unsaved VS Code workspace, the extension stores the configuration details in a temporary file. If you want to save a workspace configuration for later access, you can do so in an arbitrarily-named file with the .code-workspace extension.

The .code-workspace file is a JSON file which you can edit directly. What follows is a simple example:

{
  "folders": [
    {
      "name": "iris184:USER",
      "uri": "isfs://iris184:user"
    }
  ],
  "settings": {}
}

  • The "name" property provides a name for this server-side folder.

  • The "uri" property indicates the location of documents on the server. The supplied value has three components:

    • The first component can be either isfs or isfs-readonly. These values specify that the folder is on an InterSystems IRIS server. isfs-readonly specified read-only access.

    • The value following the / (forward slash) specifies the name of the server.

    • The value following the : (colon) specifies the namespace in lowercase characters.

  • The "settings" object can contain any other settings you wish to configure for your workspace.

To add more root folders to your workspace, giving you access to code in a different namespace, or on a different server, use the context menu on your existing root folder to invoke the Add Server Namespace to Workspace... command. This command is also available in the Command Palette.

The example which follows describes a two-folder workspace in which the second folder gives read-only access to the %SYS namespace:

{
  "folders": [
    {
      "name": "iris184:USER",
      "uri": "isfs://iris184:user"
    },
    {
      "name": "iris184:%SYS (read-only)",
      "uri": "isfs-readonly://iris184:%sys"
    }
  ],
  "settings": {}
}

Root folders can be re-sequenced using drag/drop in the Explorer view, or by editing the order their definition objects appear within the "folders" array in the JSON.

Advanced Workspace Configurations

The following is a more complex example of a .code-workspace file:

{
  "folders": [
    {
      "name": "myapp",
      "path": ".",
    },
    {
      "uri": "isfs://myapp",
      "name": "server",
    },
    {
      "uri": "isfs://myapp:user",
      "name": "user",
    },
    {
      "uri": "isfs://myapp:%sys",
      "name": "system",
    },
    {
      "uri": "isfs://user@hostname:port?ns=%SYS",
      "name": "system (alternative syntax)",
    }
  ],
  "settings": {
    "files.exclude": {},
    "objectscript.conn": {
      "active": true,
      "username": "_system",
      "password": "SYS",
      "ns": "MYAPP",
      "port": 52773,
    }
  }
}

This example defines a workspace with the following features:

  • The workspace contains multiple virtual folders, corresponding to multiple namespaces on the same InterSystems IRIS server.

  • The connection settings for the server are defined at the workspace level in the "settings" section. Any other workspace-level settings would be defined in this section.

  • The workspace includes a local folder with "myapp" defined as the root display name (the "name" property). This matches the "myapp" query in the isfs:// URI for one of the virtual folders. This correspondence allows you to maintain specialized “folder-level” settings for the virtual folder in a /.vscode/settings.json file in the local folder. See Configure an InterSystems Server to Maintain Folder-Specific Settings for more information.

Important:

Although technically possible, InterSystems strongly discourages users from combining server-side virtual folders and client-side local folders within the same workspace.

Web Application (CSP) Files

To edit web application files (also known as CSP files) on a server, configure the URI as follows:

isfs://server:namespace{csp_application}?csp

For example, the following URI gives you access to the server-side files of the /csp/user application. The csp query parameter is mandatory and the suffix on the server name must specify the correct namespace for the web application. For example:

"uri": "isfs://myserver:user/csp/user?csp"

Changes you make to files opened from this root folder of your VS Code workspace will be saved onto the server.

Filters and Display Options

The query string of the "uri" property accepts several parameters that control filtering and display of the server-side entities. The examples below access the USER namespace on the server whose definition is named ‘myserver’.

  • isfs://myserver:user/?generated=1 shows generated files as well as not generated files

  • isfs://myserver:user/?project=prjname shows only files in project prjname. Cannot be combined with any other parameter.

  • isfs://myserver:user/?mapped=0 hides files that are mapped from a non-default database

  • isfs://myserver:user/?filter=%Z*.mac,%z*.mac — a comma-delimited list of search options, ignoring type. The default is *.cls, *.inc, *.mac, *.int. To see all files, use *.

  • isfs://myserver:user/Utils?filter=*.cls shows only .cls files within the Utils package (or packages with names which begin with the string Utils).

    Note:

    As suggested by the preceding example, the wildcard character (*) cannot be used in a medial position within a filter string (for example, to filter by both an initial package name string and a file type). In other words, isfs://myserver:user/?filter=Utils*.cls would filter for files with the literal name Utils*.cls.

The options generated and mapped can be combined with each other, and with filter.

To modify the query parameters or name of an existing workspace folder, run the Modify Server-Side Workspace Folder... command from the Command Palette or the Explorer context menu.

Configure an InterSystems Server to Maintain Folder-Specific Settings

Within a VS Code workspace, settings which apply to a single root folder are defined in a settings.json file, placed in a /.vscode/ subfolder. These settings take precedence over settings defined .code-workspace for actions within that folder.

If you want to configure folder-specific settings for a server-side virtual folder (including code snippets and debugging configurations), you must configure the InterSystems server to serve a /.vscode/settings.json file.

Use the Management Portal for your target InterSystems IRIS server to create a web applicationOpens in a new tab named _vscode by performing the following steps:

  1. Navigate to the Create New Web Application page (illustrated in the image below) from the Management Portal home page by selecting System Administration > Security > Applications > Web Applications, then Create New Web Application.

    Settings for a vscode web application

  2. Enter the following values:

    • Name: —enter /_vscode

    • Description — a brief description

    • Namespace — select %SYS

    • Enable Application — select

    • Enable — select CSP/ZEN

    • Allowed Authentication Methods — select Password

    • CSP File Settings: Physical Path — enter a physical path appropriate for your platform and your installation folder

    • CSP File Settings: Web Settings — clear the Auto Compile option

  3. Save the configuration.

If you have an isfs-type workspace root folder that connects to a namespace on this server as a user with the %DB_IRISSYS:READ privilege, you can now write and read folder-specific settings. The image below illustrates the location of folder-specific settings in the VS Code Settings Editor:

Folder specific settings tab

To create a folder-specific snippets file by selecting the Preferences: Configure User Snippets command:

Configure user snippets in drop-down list

To edit the server-side namespace-specific files for all namespaces directly through VS Code, add an isfs-type root folder with the following URI:

isfs://servername:%sys/_vscode?csp

For a single namespace (for example, USER) the URI would be as follows:

isfs://servername:%sys/_vscode/USER?csp
FeedbackOpens in a new tab