External API for VSCode extension developers

External API for VSCode extension developers

AL Studio has a public API that is available for other VSCode extension developers. This API is provided even in the Free version and can be re-used by free/opensource extensions free of charge, without purchasing license.

API Interface:

Complete type definitions are available on GitHub: https://github.com/dynasist/ALStudio/blob/master/extension.d.ts

export interface IExternalAPIService { isWorkspaceScanned: boolean; onWorkspaceScanned: Function | undefined; getObjects(): Array<CollectorItemExternal>; getNextId(type: ALObjectType, projectNameOrFilePath: string): Promise<number>; getSymbolUri(type: ALObjectType, name: string, standardFormat: boolean): Uri | null; getALLanguageApiService(): IALLanguageApiService; }


isWorkspaceScanned (Property)

Indicates whether the initial workspace scanning is finished.


isWorkspaceScanned: boolean;

onWorkspaceScanned (Property)

Event fired when the initial workspace scanning is finished. You can subscribe to this event by assigning a simple function to it.


alStudioAPI.onWorkspaceScanned = () => { console.log('Workspace has been scanned!'); }


onWorkspaceScanned: Function | undefined;


getObjects (Method)

Gets the complete set of objects collected from files and symbol packages. It containes Objects, EventPublishers and EventSubscribers as well. This list is automatically maintained by AL Studio, calling getObjects() will always return the latest, updated set.


getObjects(): Array<CollectorItemExternal>;

getALLanguageApiService (Method)

Gets a simplified API reference for AL Language Extension itself.


getALLanguageApiService(): IALLanguageApiService;

getSymbolUri (Method)

Gets generated preview URI for symbol objects. This can be used to manually show source code preview window of specific symbols.


getSymbolUri(type: ALObjectType, name: string, standardFormat: boolean = false): Uri | null;

getNextId (Method)

Gets the next available object ID for the given object type in the specified Application name or file path. projectNameOrFilePath can be an:

  1. App name exactly how it is defined in app.json, e.g. Base Application
  2. Absolute filepath of any object within an app folder
  3. Absolute filepath of the app folder
  4. Absolute filepath of the app.json file

In latter case, the proper app.json will be implicitly search for.


getNextId(type: ALObjectType, projectNameOrFilePath: string): Promise<number>;

Getting an AL Studio API reference in another VSCode extension:

See below example how to get our API reference in your extension. This sample is placed in the extension loading process, e.g. activate function in extension.ts. However, you may get a reference later on demand as well.

// extension.ts import { extensions } from 'vscode'; export async function activate(context: ExtensionContext) { // you code... let alStudioAPI = await getAlStudioAPI(); } async function getAlStudioAPI() { let alStudio: Extension<any> = extensions.getExtension('dynasist.al-studio')!; if (alStudio) { if (!alStudio.isActive) { await alStudio.activate(); } return alStudio.exports; } }

See Also

Visual Studio Code - Extension API

Visual Studio Code - Extension Get Started

    • Related Articles

    • Get Started

      AL Studio is a set of visual tools for editing, navigating or documenting AL Objects without complex running environments. It is built with a holistic approach that aims to provide users with better understanding of their whole workspace. Product ...
    • Installation

      AL Studio is a Visual Studio Code extension published on Visual Studio Marketplace. Install from Marketplace You can get the extension by searching for dynasist.al-studio on the Marketplace website or directly in VSCode / Extensions tab. Direct link: ...
    • Generate Documentation Overview

      This module allows you to create a complete, markdown-based API documentation for a project or workspace. Markdown is a human-readable format that can be converted to HMTL or many other formats using external tools. Generated files are internally ...
    • PopOut Mode

      Pop-out mode allows you to use AL Studio features in Visual Studio Code and external browser windows at the same time. This provides a real multi-window experience for users having multiple monitors. Setup Settings are located under Visual Studio ...
    • Licensing

      AL Studio is a premium extension with a free, community edition. Editions are licensed under the same End-User License Agreement ("Agreement"). Community version This edition and its functionality is available for free for everyone. Installation or ...