LSP Magic — Mainframe Language Support in Modern IDEs

Azat Satklyčov
Modern Mainframe
Published in
5 min readJun 18, 2020

--

Developers each have their favorite IDE, an experience they are familiar with. The challenge is, how to get the advanced capabilities they want with every language into every IDE simply.

Language Server Protocol (LSP)

In 2016 Microsoft introduced LSP[1] taking an important step in the way of editor agnosticism (separation of editor and language tool). This facilitates decoupling development tools from client-server architecture where the client can connect to any number of language servers [see Figure-1]. Before LSP was introduced, every dev-tool vendor provided their own solution (plugins) for syntax-checking, code completion or go-to-definition like services to each programming language separately, and generally, these plugins could not be re-used by other tools. Now, using the LSP approach, any vendor can publish their solutions into the marketplace of tools that support LSP as an extension, and others can use this extension in their dev-tools. E.g. Installing the COBOL Language Support extension onto your VS Code editor, enables you to write COBOL programs there, and your editor will not be even aware of anything about the semantics of the language.

Figure-1: Using LSP, M x N programming language support problem is reduced to M + N

LSP Architecture

Language Server Protocol is implemented as two separate processes, a client and server processes, with no restriction to run on the same physical machine. To become a client, the code editor adds a small extension, which provides a language-agnostic, front-end editing support without any awareness of the semantics of the language [see Figure-2]. Language-server[2] provides language semantics and serves to a single client at a time. It listens to the meta-state of the editor and based on syntax or semantic analysis, returns a set of actions. This communication happens based on rules defined by an extended version of JSON RPC v2.0[3], which is a transport agnostic protocol that uses JSON as data format (JSON-RPC Working Group, 2018).

Figure-2: LSP Architecture offers us flexibility of choosing any technology combination to implement client and language-server independently

The language-server Java implementation is built upon Eclipse LSP4J API[4], which supports the development and consumption of language servers, defines the methods and expected data structures, and the rules around the communication. To provide at least basic language-server functionality, you need to provide an implementation for the core interfaces: LanguageServer, TextDocumentService and WorkspaceService. Those interfaces provide methods to handle LSP messages (notifications, requests or responses) from different operational categories (general, window, client, workspace and textDocument), whereas LanguageServer takes care of general messages (e.g., client-server-handshake, initialize, shutdown, etc.); TextDocumentService handles the text document synchronization messages (diagnostics, opening, modifying files, etc.); and WorkspaceService implements the methods for command execution and workspace management.

JSON-RPC allows a client to request a server to run a method with parameters. Language-server inspects the document and ensures if the code has correct syntax and if it detects an error it reports back to the client providing the location information in the message. The relation between request and response messages is managed by request id.

Figure-3: Interprocess communication [5] between the client and language server.

LSP support for Mainframe Programming Languages

Since a sizable mainframe business exists in the market, but processes are managed using traditional tools by a workforce at or near the age of retirement, steps to modernize the mainframe tools and motivating the young generation to use mainframe technologies like COBOL, HLASM, REXX and JCL Check extension, are inevitable. Modern tooling and interfaces to the mainframe in support of process modernization has already been started by the Open Mainframe and Zowe, and Che4z projects. From a modern IDE point of view, Language Server Protocol brings the magic of modern editing capabilities..

Based on the above LSP architecture, Broadcom provides multiple extensions dedicated to specific languages, like COBOL Language Support, HLASM Language Support, JCL Language Support and an extension for REXX is also coming very soon.

LSP Support for COBOL is an Open source project under the Eclipse License che-che4z-lsp-for-COBOL. It is a part of all-in-one mainframe Code4z extension and freely available for VS Code editor in Marketplace and it can be also used in Eclipse Theia Cloud Editor via provided dev-file. COBOL Language Support extension provides you with language aware features like: autocomplete, highlighting, diagnostics, and copybooks support on file extensions .cob and .cbl. It is also able to connect to a mainframe using Zowe CLI z/OSMF profile to support downloading copybooks.

COBOL Support in VS Code Editor — Traditional UI

In your VS Code extension tab, search for code4z and install the extension pack.

Create a new file with .cbl or .cob extension or open an existing COBOL file, and start using language aware features during coding.

COBOL Support in Theia — Cloud Web IDE

Eclipse Che[6] is the world’s first Kubernetes-based, next-generation container development platform, developer workspace server and cloud-native Web IDE. It provides a default Web IDE based on the Eclipse Theia project. Theia is built on the Language Server Protocol (LSP) and supports a variety of programming languages. Our COBOL extension, che4z, is tailored to be used in the Theia Editor via a Che devfile , which is used to create a workspace with all required plugins. The Theia editor allows you to create a new file with a .cbl or .cob extension or open an existing COBOL file and start using language aware features during coding.

JCL Extension Support

Now that you understand the LSP architecture and what it provides using a COBOL example, in the next series of the blog we demonstrate the power of the LSP Architecture for JCL: Introducing the JCL Language Support VS Code Extension.

References

[1] https://microsoft.github.io/language-server-protocol/specifications/specification-current/

[2] https://langserver.org/

[3] https://www.jsonrpc.org/specification

[4] https://projects.eclipse.org/projects/technology.lsp4j

[5] https://microsoft.github.io//language-server-protocol/overviews/lsp/overview/

[6] https://www.eclipse.org/che/

https://github.com/eclipse/che-che4z-lsp-for-COBOL

https://marketplace.visualstudio.com/items?itemName=broadcomMFD.code4z-extension-pack

--

--