vscode-intersystems-iris

Downloads29
Subscribe
1
Bookmark
4
Details
Releases
Reviews
Issues
Provider

What's new in this version

  • Windows x64 and macOS versions available
  • Example of code on Rust

VSCode extension for advanced Management of InterSystems IRIS

Key Features

This extension uses LanguageServer to communicate directly with InterSystems IRIS over SuperPort (1972). LanguageServer is written on Rust and utilizes Rust irisnative library. The extension does not use Atelier API.

Installation

  • Download the latest version of vsix file from releases for your platform
  • Install the file with drag-n-drop to Extensions view in VSCode, or by command Install from VSIX...

Configuration

The extension does not reequire VSCode-ObjectScript extension, but uses some of the settings it provides. In addition to objectscript.conn settings, the extension requires setting objectscript.conn.superPort to be set. Example of desired settings.

{
  "objectscript.conn": {
    "active": true,
    "host": "localhost",
    "port": 52773,
    "ns": "USER",
    "username": "_SYSTEM",
    "password": "SYS"
  },
  "objectscript.conn.superPort": 1972,
}

Extension in action

example

The extension adds two more views:

  • Interoperability, access to Productions and their statuses with all the items.
  • System Explorer, with the list of globals in the namespace.

Rust IRIS Native driver

Works directly over super server port (1972). Supports work with globals and simple SQL queries.

Example of code.

use irisnative;
use irisnative::{connection::*, global, global::Sub, Global};

fn main() {
let host = "127.0.0.1";
let port = 1972;
let namespace = "USER";
let username = "_SYSTEM";
let password = "SYS";
match irisnative::connect(host, port, namespace, username, password) {
Ok(mut connection) => {
println!("Connection established");

  <span class="pl-c1">println!</span>(<span class="pl-s">"Server: {}"</span>, connection.<span class="pl-en">server_version</span>());

  connection.<span class="pl-en">kill</span>(<span class="pl-k">&amp;</span><span class="pl-en">global!</span>(A));
  connection.<span class="pl-en">set</span>(<span class="pl-k">&amp;</span><span class="pl-en">global!</span>(<span class="pl-en">A</span>(<span class="pl-c1">1</span>)), <span class="pl-s">"1"</span>);
  connection.<span class="pl-en">set</span>(<span class="pl-k">&amp;</span><span class="pl-en">global!</span>(<span class="pl-en">A</span>(<span class="pl-c1">1</span>, <span class="pl-c1">2</span>)), <span class="pl-s">"test"</span>);
  connection.<span class="pl-en">set</span>(<span class="pl-k">&amp;</span><span class="pl-en">global!</span>(<span class="pl-en">A</span>(<span class="pl-c1">1</span>, <span class="pl-s">"2"</span>, <span class="pl-c1">3</span>)), <span class="pl-s">"123"</span>);
  connection.<span class="pl-en">set</span>(<span class="pl-k">&amp;</span><span class="pl-en">global!</span>(<span class="pl-en">A</span>(<span class="pl-c1">2</span>, <span class="pl-c1">1</span>)), <span class="pl-s">"21test"</span>);
  connection.<span class="pl-en">set</span>(<span class="pl-k">&amp;</span><span class="pl-en">global!</span>(<span class="pl-en">A</span>(<span class="pl-c1">3</span>, <span class="pl-c1">1</span>)), <span class="pl-s">"test31"</span>);

  <span class="pl-k">let</span> <span class="pl-k">mut</span> global <span class="pl-k">=</span> <span class="pl-en">global!</span>(<span class="pl-en">A</span>(<span class="pl-s">""</span>));
  <span class="pl-k">while</span> <span class="pl-k">let</span> <span class="pl-c1">Some</span>(key) <span class="pl-k">=</span> connection.<span class="pl-en">next</span>(<span class="pl-k">&amp;</span><span class="pl-k">mut</span> global) {
    <span class="pl-c1">println!</span>(<span class="pl-s">"^A({:?}) = {:?}"</span>, key, {
      <span class="pl-k">if</span> connection.<span class="pl-en">is_defined</span>(<span class="pl-k">&amp;</span>global).<span class="pl-c1">0</span> {
        <span class="pl-k">let</span> value: <span class="pl-k">String</span> <span class="pl-k">=</span> connection.<span class="pl-en">get</span>(<span class="pl-k">&amp;</span>global).<span class="pl-en">unwrap</span>();
        value
      } <span class="pl-k">else</span> {
        <span class="pl-k">String</span><span class="pl-k">::</span><span class="pl-en">from</span>(<span class="pl-s">"&lt;UNDEFINED&gt;"</span>)
      }
    });
    <span class="pl-k">let</span> <span class="pl-k">mut</span> global1 <span class="pl-k">=</span> <span class="pl-en">global!</span>(<span class="pl-en">A</span>(key, <span class="pl-s">""</span>));
    <span class="pl-k">while</span> <span class="pl-k">let</span> <span class="pl-c1">Some</span>(key1) <span class="pl-k">=</span> connection.<span class="pl-en">next</span>(<span class="pl-k">&amp;</span><span class="pl-k">mut</span> global1) {
      <span class="pl-k">let</span> value: <span class="pl-k">String</span>;
      <span class="pl-k">if</span> connection.<span class="pl-en">is_defined</span>(<span class="pl-k">&amp;</span>global1).<span class="pl-c1">0</span> {
        value <span class="pl-k">=</span> connection.<span class="pl-en">get</span>(<span class="pl-k">&amp;</span>global1).<span class="pl-en">unwrap</span>();
      } <span class="pl-k">else</span> {
        value <span class="pl-k">=</span> <span class="pl-k">String</span><span class="pl-k">::</span><span class="pl-en">from</span>(<span class="pl-s">"&lt;UNDEFINED&gt;"</span>);
      }
      <span class="pl-c1">println!</span>(<span class="pl-s">"^A({:?}, {:?}) = {:?}"</span>, key, key1, value);
    }
  }

  <span class="pl-k">let</span> <span class="pl-k">mut</span> rs <span class="pl-k">=</span> connection.<span class="pl-en">query</span>(<span class="pl-k">String</span><span class="pl-k">::</span><span class="pl-en">from</span>(
    <span class="pl-s">"SELECT Name from %Dictionary.ClassDefinition WHERE Super = 'Ens.Production' and Abstract&lt;&gt;1"</span>));
  <span class="pl-k">while</span> rs.<span class="pl-en">next</span>() {        
    <span class="pl-k">let</span> name: <span class="pl-k">String</span> <span class="pl-k">=</span> rs.<span class="pl-en">get</span>(<span class="pl-c1">0</span>).<span class="pl-en">unwrap</span>();
    <span class="pl-c1">println!</span>(<span class="pl-s">"{}"</span>, name);
  }
}
<span class="pl-c1">Err</span>(err) <span class="pl-k">=&gt;</span> {
  <span class="pl-c1">println!</span>(<span class="pl-s">"Error: {}"</span>, err.message);
}

}
}

Rating
0 (0)
Category
Developer Environment
Works with
InterSystems IRISInterSystems IRIS for Health
Tags
Info
Publisher
CaretDev
Version
0.1.1
Last updated
2021-03-03
Repository
Open
Documentation
Open
License
Link
Rewards