IBM / zopeneditor-about

IBM Z Open Editor: File issues here!
https://ibm.github.io/zopeneditor-about
Apache License 2.0
49 stars 20 forks source link

API for interacting with source code opened in Z Open Editor #93

Open FALLAI-Denis opened 3 years ago

FALLAI-Denis commented 3 years ago

Description of the enhancement requested

We come from an experience of more than 30 years of using a COBOL code generator, (IBM VisualAge Pacbase, whose successor is IBM Rational Programming Patterns).

As this COBOL code generator is no longer supported, we have chosen to use VS Code and the Z Open Editor extension to maintain and develop our COBOL programs.

We are in the process of defining a new "native COBOL" development framework based on COPYBOOKs to outsource and reuse certain elements (resource description, reusable processing), and snippets to assist the developer in his coding work.

Our COBOL code generator had a particular functionality: the possibility of distributing source code on several insertion points, (concept of macro-structure in IBM Visual Age Pacbase, and in IBM Rational Programming Patterns).

We would like to have the equivalent functionality with VS Code: to have a mechanism allowing to distribute code to several places in the source code being edited in a single action, even if possible to be able to modify this distributed code after the fact (which supposes having markers in the source code to find the insertion points).

We do not have enough experience to know if VS Code is natively capable of providing this code distribution service.

This functionality could perhaps be offered by Z Open Editor since it must use a representation of the syntax tree of the code being edited.

The idea would be that Z Open Editor publishes an API allowing to interact with the source code being edited from a snippet or an evolution of the snippet principle.

Example of need to distribute code to multiple locations: add a read file in a COBOL program. This requires:

Each of these actions can be managed by a snippet, but the developer must intervene on each point to call the corresponding snippet. We would like the developer to have only one action to do and all points to be dealt with at once, and possibly editable later.

FALLAI-Denis commented 3 years ago

I think I have found an answer to the expressed need: the "macros" extension in the VS Code marketplace. https://marketplace.visualstudio.com/items?itemName=geddski.macros or https://marketplace.visualstudio.com/items?itemName=ctf0.macros

This extension allows you to insert pre-declared snipets by procedural code, optionally after searching the source code to find the appropriate insertion point.

But if this functionality could be integrated natively into Z Open Editor, with the intelligence of the Language Server to identify information, I think it would be even better.

FALLAI-Denis commented 1 year ago

Hi,

VS Code can display the Outline view on a program (COBOL), and this Outline view allows you to position yourself in the source code text of the program (COBOL).

It is still necessary that the structure of the program displayed by the Outline view be made available, and it seems to me that this is the role of the Language Server (COBOL) of Z Open Editor.

There must therefore exist native VS Code APIs, not linked to Z Open Editor, to create and manipulate the program structure information and from this structure to position itself in the source code.

Unfortunately my knowledge of VS Code APIs is very limited.

Could someone put me on the trail of these APIs?

With these APIs we could improve our code injection tooling by referencing the structure of the program rather than key lookup functions in the text of the source file (currently source code markup in line number area, columns 1 to 6), which is far from satisfactory.