Visual Studio Code Source Code



This extension was originally aimed at providing syntax highlighting for COBOL but overtime is has been extended to provide syntax highlighting for other related languages/file formats such JCL, PL/I and Micro Focus directive files and Micro Focus Unit Test Reports.

What can I expect from this extension

This extension is certainly not an Integrated Development Environment for COBOL. It does provide enough functionality for the casual developer to view, edit and compile source code (via tasks & problem matchers).

Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications. Source code for Visual Studio Code is available at under the MIT license agreement. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Automated Teller Machine System in VB.Net and MS Access Database with Full Source Code The Automated Teller Machine System is a software based system that is developed using Visual Basic 2015 and MS Access Database. This contains an admin section which controls all the functions of the system. Read all about WhiteSource visualstudiocode open source vulnerabilities database project.

Does this extension include a language server protocol for COBOL

Visual Studio Code has two ways of providing language extensions, the first is provided by the use of a language server protocol and the second is via a set of Visual Studio Code APIs.

This extension uses the Visual Studio Code APIs because the Language Server Protocol did not exist when this extension was created.

What platform can it be used on?

Everywhere Visual Studio Code works.

Code colorization for COBOL, PL/I and JCL:

IntelliSense example:

Breadcrumb support:

Outline support:

Go to definition:

Peek definition:

Keybindings

KeysDescription
ctrl+alt+pGo to procedure division
ctrl+alt+wGo to working-storage section
ctrl+alt+dGo to data division (or working-storage section if not present)
ctrl+alt+,Go backwards to next section/division
ctrl+alt+.Go forward to next next section/division
f12 or ctrl+clickGo to copybook/file
ctrl+hoverPeek head of copybook or symbol/field
right mouse/peekPeek copybook without opening the file)

Settings

  • COBOL tab stops can be changed by editing the coboleditor.tabstops setting.
  • Extensions used for Go to copybook, can be changed by editing the coboleditor.copybookexts settings.
  • Directories used for Go to copybook, can be changed by editing the coboleditor.copybookdirs settings.

Tasks

Visual Studio code can be setup to build your COBOL source code.

Task: Using MsBuild

MsBuild based projects can be consumed as build task, allowing navigation to error/warnings when they occur.

Below is an example of build task that uses mycobolproject.sln.

Task: Single file compile using Micro Focus COBOL - ERRFORMAT(3)

The example below shows you how you can create a single task to compile one program using the cobol command.

For Net Express/Server Express compilers use the '$mfcobol-errformat3-netx-sx' problem matcher as although the directive ERRFORMAT'3' is used, the compiler output error format is slightly different.

Task: Single file compile using Micro Focus COBOL - ERRFORMAT(2)

The example below shows you how you can create a single task to compile one program using the cobol command.

For Net Express/Server Express compilers use the '$mfcobol-errformat2-netx-sx' problem matcher as although the directive ERRFORMAT'2' is used, the compiler output error format is slightly different.

Task: Single file compile using COBOL-IT

The example below shows you how you can create a single task to compile one program using the cobc command.

Task: Single file compile using ACUCOBOL-GT

The example below shows you how you can create a single task to compile one program using the ccbl32 command.

Task: Breakdown of problem matchers

Product and VersionToolsProblem matcher(s)
COBOL-ITcobc$cobolit-cobc
COBOL-ITcobc for errors/notes$cobolit-error-cobc + $cobolit-note-cobc
ACU-COBOLGTccbl for errors/warnings$acucobol-ccbl + $acucobol-warning-ccbl
Micro Focus COBOL Net Express/Server Expresscob or cobol.exe + ERRFORMAT'2'$mfcobol-errformat2-netx-sx
cob or cobol.exe + ERRFORMAT'2' for errors in copybooks+mfcobol-errformat2-copybook-netx-sx
cob or cobol.exe + ERRFORMAT'3'$mfcobol-errformat3-netx-sx
cob or cobol.exe + ERRFORMAT'3' for information+mfcobol-errformat3-info
Micro Focus Visual COBOL/Enterprise Developermsbuild$mfcobol-msbuild
cob or cobol.exe + ERRFORMAT'3'$mfcobol-errformat3
cob or cobol.exe + ERRFORMAT'3' / filename extract with PATH$mfcobol-errformat3-basefn
cob or cobol.exe + ERRFORMAT'2'$mfcobol-errformat2
cob or cobol.exe + ERRFORMAT'2' for errors in copybooks$mfcobol-errformat2-copybook

NOTE: Problem matchers can be stacked in your task definition. It is recommended that any '-copybook', '-info', '-note' and similar problem matcher are included before problem matchers without this suffix.

Remote development using containers

If your main development is Micro Focus Visual COBOL/Enterprise Developer you may have access to base images that provide the compiler and its tools.

If you do, all that is required is another image that contains extra tools and a devcontainer.json to configure its use.

The following Dockerfile is an example on how you can extend your existing base image with java configured, ant, git and lsb tools.

This example uses the SLES 15.1 base images using Visual COBOL 5.0.

You may need to tweak the FROM clause in the Dockerfile and if you use a different platform or product version, the zypper will also require a change too if a different platform is used (different commands eg: yum, microdnf etc..).

Dockerfile:

devcontainer.json:

Workspace Setup

Visual Studio Code workspaces are not 'projects' but do allow you keep your source in one place.

Things to consider:

  • If you have copybooks, you should change the coboleditor.copybookdirs settings to setup where the extension can find your copybooks
  • If use the COPY verb with this extension, you may also need to adjust the coboleditor.copybookexts settings (json array).
  • If you want the extension to understand the contents of your copybook before you access it, then turn on the coboleditor.parse_copybooks_for_references settings (json array) to allow the extension to look inside the copybook references

COBOL Linter

Vscode Open Source

The COBOL linter included with the extension performs two functions, the first function is to identify sections/paragraphs that are not used and the second is to apply any 'house' standards.

The section/parapgraph linter by default generates warning message but if you prefer the messages to be marked as information, you change the coboleditor.linter_mark_as_information boolean setting, for example:

The house standards are applied to fields in various sections, each section is named and a rule defined as a regular expression to enforce.

For example to enforce all working-storage items must start with ws and local-storage ls, you can use:

Visual studio code open source code

Metadata caching

By default the metadata caching is turned on and is stored in the current code workspace but it can be turned off via the coboleditor.maintain_metadata_cache setting.

Metadata is stored in your code workspace file but can also be stored in your single folder settings file by enabling the coboleditor.maintain_metadata_cache_single_folder setting.

Pre-Processor support for 'hidden' source code

Some pre-processor reference copybooks that are inserted into the code without using standard COBOL syntax.

These source files are often difficult to edit due this extension not knowing anything about these files.

In order to help this extension, a special style of comment can be inserted into the code that allows the extension to locate these extra copybooks.

For example, if your preprocessor includes the files Shared/foo.cbl OldCopyBooks/Shared/bar.cbl, then you can use the following comment line.

The source-dependency names are separated by a space.

To enable this feature enable the scan_comments_for_hints setting, for example:

The hint token can be configured by the coboleditor.scan_comment_copybook_token setting, which has the default value set to source-dependency.

It is recommended that the token name remain consistent in your source, otherwise it will make it hard for observers of your source to understand the code.

coboleditor.fileformat

When coboleditor.margin is enabled extension will look for 'sourceformat' settings (json array) in the header of the source file itself.

However, if you need to tell the extension which file are which particular format, this can be achieved with coboleditor.fileformat property.

For example, if you want all the files that match A*.cbl to be fixed and every other *.cbl is free format, you can then use:

Handling code pages

Visual Studio Code Source Code

The defaults embedded in the extension can be overwritten by either changing sessions at the user level in the settings json file or more efficiently, you change it just for the 'COBOL' files.

For example, to ensure you use utf8 for all you files use:

Tips

  • If you find you are not getting any symbols in the outline view or the peek/goto definition functionality does not work, please check the Output->COBOL panel as it may give you a reason for this.

    For example the editor line limit has been surpassed or the file fails to be identified as a COBOL source file.

  • The colors in the editor can be changed on a per theme basis, for example:

Where comments is a token name, standard tokens can be found in the textmate documentation.

Useful tokens that are often changed are: comment.line.cobol.newpage, keyword.operator.

Complementary extensions

COBOL Language Dictionary - Code Spell Checker

Spell checking code is helpful but without specific support for the COBOL language it can be a painful experience, so in order to make it easier. I have produced a spell checker extension that has a the standard COBOL reserved words and keywords from various dialects such a Micro Focus COBOL and IBM Enterprise COBOL.

Spell checking can be enabled/disabled in your source code by using:

Visual Studio Code No Source Code Providers Registered

You can also ignore words in the code, for example:

Lastly, you use a regular expression, for example, to ignore words that contain a '-', you could use:

ToDo tree by Gruntfuggly

Although this extension does not understand comments in COBOL source files, it can be made to by adding the following user setting:

Online resources

  • Online communities
  • Stack Overflow topics/tags:
  • wikipedia
  • standards

Shortcuts

  • [ALT] + [SHIFT] + [C]: Change to COBOL Syntax (default)
  • [ALT] + [SHIFT] + [A]: Change to ACUCOBOL-GT Syntax
  • [ALT] + [SHIFT] + [M]: Toggle margins (overrides user/workspace settings)

Contributors

I would like to thank the follow contributors for providing patches, fixes, kind words of wisdom and enhancements.

  • Ted John of Berkshire, UK
  • Kevin Abel of Lincoln, NE, USA
  • Simon Sobisch of Germany

NOTE: Some of the above contributions have now been moved into the GnuCOBOL extension.

Utilize the tight integration of Visual Studio Code with the Git source-control management system.

Learning objectives

In this module, you will:

  • Perform common GitHub tasks by using the Command Palette in Visual Studio.
  • Monitor the status of your work
  • Commit your files to your repositories from the Source Control view

Prerequisites

Visual Studio Code Github

  • Git, installed
  • Visual Studio Code, installed
  • A basic understanding of Git concepts and commands, such as working with repositories, forks, clones, and branches, staging and unstaging changes, and pushing commits.
  • You need a GitHub account.
  • Exercise - Clone a repository and create a branchmin
  • Stage, commit, and push changes to a remote repositorymin
  • Exercise - Stage, commit, and push changes to a remote repositorymin