Question
Evgeny Shvarov · Aug 27, 2019

How to Export ObjectScript From IRIS Server With VSCode?

Hi Developers!

A question to those who use VSCode to code InterSystems ObjectScript.

Suppose you have the ObjectScript code on IRIS server and you want to export it into the desired folder.

And you have VSCode connected to the server.

What is the way to tell VSCode that I want to export classes into some particular folder in /package/class.cls way?

E.g. into:

/project_folder/src/cls/Package/class.cls

and project_folder is opened in VSCode as the folder of the project.

10
3 0 8 377
Log in or sign up to continue

There is an option in the settings: "objectscript.export.addCategory",  when it's set to true, it will add categories for different file types.

In uppercase CLS for files "cls",  and RTN for "int", "mac", "inc".

The next coming version will support the way to have more control over it, where the left side for extension of a file, and the right part for a category name

"objectscript.export.addCategory": {
  "cls": "_cls",
  "mac": "_mac",
  "int": "_int",
  "inc": "_inc"
}

Perfect!

So, what is the setting of this parameter to export classes into:

/src/cls

folder?

There is one more option, is the root of sources, so, the final settings are

"objectscript.export.folder": "src",

"objectscript.export.addCategory": true

But it will be /src/CLS, not /src/cls, yet, until the next version.

Have there been any updates on this? I am involved in a project which uses VSCode, and we want all unit test (Start with UnitTest.) classes to end up in another folder so they can be kept out of production easily.

Hi Marcel, yes, something was implemented, which may help you with it. There is a new item map in objectscript.export. For instance this

   "objectscript.export": {
    "folder": "",
    "addCategory": false,
    "map": {
      "%(.*)\\.([^.]*)": "src/$2/_$1.$2",
      "(Test\\.PM\\.Integration\\..*)": "tests/integration_tests/$1",
      "(Test\\.PM\\.Unit\\..*)": "tests/unit_tests/$1",
    },
  }

I have on the same level src and tests folders, so, I set folder to an empty string, to operate on a root level. My Unit Test classes, just placed in the desired folder without adding the folder by type (e.g. cls, inc). But, any other sources have to be stored by type in a separate folder, and my classes are a percent classes, and I have to replace % to _.

On the left side, I have the regular expression to match any main classes %(.*)\\.([^.]*) it should match the filename completely, and on the right side replacement. Same you can see for two different types of UnitTests.

Excellent, thanks @Dmitry Maslennikov

Mine is simpler at this moment

"objectscript.export": {

 "folder": "MyFolder",

"addCategory": false,

"map": {

"(UnitTest\\..*)": "internal/$1",

"(..*)": "src/$1"

}

}

This does the trick for now.

@Dmitry Maslennikov  Are there any special characters to watch with static .csp and .js files? I would expect the last map item to catch all, but it does not match with /csp/mynamespace/myfile.js (ends up in /MyFolder/csp/mynamespace/.... and I would expect /MyFolder/src/csp/mynamespace/...