Outline function in VS Code not working for COBOL files

I'm running the following environment:

VisualCOBOL 9 Patch Update 2
Micro Focus VS Code extension 1.0.57
VS Code version 1.90.0 on Linux (Ubuntu) and Windows (10 and 11)

The outlining feature does not work when a COBOL file is loaded into the editor.  The message "No symbols found in document <filename>.cbl" is displayed.

Syntax highlighting is working, however there is no dynamic parsing of the source (I'm not sure if there should be - it's present for other languages such as shell scripts).  Nothiing ever shows up in the "Problems" tab.

I seem to recall that code outlining worked for about 10 minutes after I installed the extension, but hasn't worked since.   I can't replicate this by reinstalling the extension.

In addition CTRL-clicking on variables to see their definitions, CTRL clicking on paragraph or section names, or hovering over either of them does nothing either.

There are no other enabled COBOL extensions installed.

In short, the extension seems to be providing little other than syntax highlighting and debugging.  We compile with an external script.

Any ideas on how to get this working?

  • The support for these advanced editing features is provided by the COBOL Language Server which is part of the full Visual COBOL install.
    It sounds as if the Language Server is not started.

    Please see the docs covering the COBOL Language Server for the Visual Studio Code COBOL extension here.

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • Thanks for the quick reply, Chris.

    I can verify that the COBOL Language Server is running and restarts successfully.  However I neglected to mention that we're doing remote development, and have connected VS Code to a remote Linux server, which has a licensed VisualCOBOL v9 installation.

    I have modified the extension settings to include the installation path on the remote server (the default of /opt/microfocus/VisualCOBOL), but this had no effect.  The documentation that you supplied says:

    Important: This functionality requires a licensed version of a Micro Focus Visual COBOL or Enterprise Developer product on the same machine.

    Does this mean that the extension and Language Server require an installation of VisualCOBOL on the client machine (Windows or Linux desktop) when doing remote development?

  • Quick updates on my findings.

    If I remove all VS Code settings from my user on the remote server (.vscode, ~/.config/Code, .vscode-server), remove the COBOL extension, and start again, it works, but only for VS Code running over remote X (either natively with Linux or with Reflection X for Windows).

    It doesn't work for VS Code using the remote development extension from my Linux client machine, even though both remote X and remote development are the same user connecting to and using the same folders on the same remote server.

    If I modify the extension's settings, adding in the SQL precompiler string, it stops working.

    Removing the SQL precompiler string from the settings does not fix it - it remains broken.

  • I am a bit confused as to what configuration works and what doesn't. Can you please clarify, as you mention a Linux remote server, a Linux client and Windows?

    When you state that it works, do you mean that the original problem of the Language Server features not working is solved?

    You don't need any Micro Focus products on the VS Code client machine, you just need VS Code with the Remote Development extension pack from Microsoft installed and on the remote machine you need the VS Code Server and the Micro Focus extension installed.

    There is a walk-thru of this scenario in the docs here.

    What SQL precompiler are you using, OpenESQL, Pro*COBOL/COBSQL, DB2, etc.?
    Can you show me what the directive setting looks like for SQL?

    Thanks

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • Thanks Chris, and sorry about the confusion.

    The desired working model is exactly the one described in your link, using the Microsoft Remote Development extension pack.

    The remote server is Linux - the client machines running VS Code are both Linux and Windows:

    Linux client -> Linux Server (where VisualCOBOL is installed)
    Windows client -> Linux Server (where VisualCOBOL is installed)

    The SQL precompiler is for Sybase.  The string I'm using is:

    preprocess(cobsql) cobsqltype==sybase end-cobsql -m endp

    I've made some further discoveries - here are steps to reproduce for me:

    * SSH to the remote server, and remove all VS Code settings:
        * rm -rf ~/.vscode
        * rm -rf ~/.vscode-server
        * rm -rf ~/.config/Code

    * Start VS Code on the client machine, and connect to the remote Linux server.  The VS Code server will be downloaded.
    * Open the remote folder containing the source if needed.
    * Open a COBOL source file.  Without the extension it will not be parsed or colourised.
    * Install the Micro Focus COBOL extension on the remote connection.
    * The outlining will work, and errors will be shown for SQL statements:


    * Modify the extension settings to include the SQL precompiler:
        * preprocess(cobsql) cobsqltype==sybase end-cobsql -m endp


    * Switch back to the COBOL source - the SQL errors have disappeared.
    * Modify the source in any way.  Saving is not required.
    * The COBOL extension stops outlining the source code.
    * Remove the precompiler directive from the COBOL extension settings.
    * The outliner still does not work however SQL errors appear in the Problems tab.
    * Modify the source in any way - the outliner will begin working again.

    In summary, once the precompiler directive is added and the source file modified, outlining (and other extension functions) stops working.

    Removing the precompiler directive and modifying the source reinstates outlining and other functions.

  • I have discussed this with Development and there does appear to be a problem when working with the COBSQL precompiler directive when set as a Default Directive in VS Code. This will require a change in the Visual COBOL product. If you create a ticket with Technical Support and put my name as part of the description, I will raise a product defect for this.

    As a temporary workaround, you can try replacing:
        preprocess(cobsql) cobsqltype==sybase end-cobsql -m endp
    with
        SQL(COBSQL)

    This should allow you to edit your source code without errors.

    Thanks

    Chris Glazier
    Rocket Software - Principal Technical Support Specialist
    If you found this post useful, give it a “Like” or click on "Verify Answer" under the "More" button

  • Thanks Chris.

    I've created this:  https://portal.microfocus.com/s/customdetailpage?500Q40000096GcrIAE

    The SQL(COBSQL) directive reduces the number of SQL errors, but cannot deal with Sybase specific variables:

    We can live with that, though, until a patch is released for the extension.  Thanks for your help!

  •  I've not used the Sybase precompiler myself but as the first error is 'Unknown copybook sqlca specified' you may be able to reduce the errors further by adding the COPYPATH directive to the Default Directives and including the location of the sqlca copybook file used by Sybase, and possibly the COPYEXT directive too depending on what extension it uses.

    It might not make a difference, but could be worth a try.

    Gael

  • Thanks Gael, that was a great idea but unfortunately did not work.

    The extension complains:

    Directive COPYPATH=<list of directories including the Sybase directory> invalid or not allowed here.

    I've modified the COBCPY environment variable as well to include the sqlca include file, and restarted VS Code, but that did not help either.  I also tried setting COBCPY in the compiler directives to no avail - same message.  It seems setting environment variables in the compiler directives is not supported.

    Thanks for the idea though!

  • Just to clarify the reason for these errors , the 'Default Directives' in the VS Code extension settings allows you to specify compiler directives and the directives specified need to conform to the directive syntax defined in the Visual COBOL documentation. As such, COPYPATH needs to be of the form COPYPATH(<list of paths>) or COPYPATH"<list of paths>" and was rejected because you used =.

    COBCPY is an environment variable, not a directive, and therefore is not valid in the Default Directives.

    Gael