Giter Site home page Giter Site logo

Comments (5)

VitGottwald avatar VitGottwald commented on July 28, 2024 1

Happy new year and thank you for the input @FALLAI-Denis!

We have an implementation that uses the language server AST for understanding of the statement boundaries and implements folding for IF/ELSE, EVALUATE/WHEN, and multiline PERFORM statements.

We also supports bracket pair colorization.

If you would like to try this out and suggest any improvements a direct link to the zipped VSIX build is https://github.com/eclipse-che4z/che-che4z-lsp-for-cobol/actions/runs/7264557185/artifacts/1124525865 .

We welcome all feedback.

Please, make sure to disable all other COBOL and folding extensions when testing to make sure the behaviour you see actually comes from our extension. Also, please, make sure that "editor.foldingStrategy" is set to "auto".

from che-che4z-lsp-for-cobol.

VitGottwald avatar VitGottwald commented on July 28, 2024

#2181

from che-che4z-lsp-for-cobol.

VitGottwald avatar VitGottwald commented on July 28, 2024

@FALLAI-Denis would you be interested in providing input to this feature?

from che-che4z-lsp-for-cobol.

FALLAI-Denis avatar FALLAI-Denis commented on July 28, 2024

Hi,

The difficulty in doing folding at the level of COBOL statements is to determine the start of the folding area but also to determine the end of the folding area.
This end of fold area depends on the COBOL syntax used: end of scope statement (END-xxx) or COBOL point.
In the case of the COBOL point, the end of area can be common to several COBOL instructions, therefore several end of folding areas.
If multiple instructions are written on the same source code line (which should be rare but not impossible), then the same source code line may correspond to more than one start folding area. Same if multiple END-xxx are written on the same source code line: they correspond to more than one end folding area.

As indicated above, this cannot be done by means of a simple scan of the source code, even by means of regex, and requires having access to a semantic / syntactic representation of the program (like abstract syntax tree, AST ) with a mapping between this representation and the start and end line numbers (and columns ?) in the source code of each COBOL instruction.
This may be possible when using a Language Server, and subject to having an API to access this representation, which is not the case in native VS Code.

The analysis must also take into account calls to copybooks/includes, and also conditional compilation which can impact the final source code and it is this final source code that the folding should focus on.
For our part, we have developed a COBOL framework based on the use of cascading copybooks and conditional compilation to control calls to these copybooks. This makes the work of COBOL parsers more complex.

Folding on COBOL blocks of statements is useful for hiding a part of code that we do not want to view/analyze, but this may not be the first need.
To understand the structure of a program, an alternative to folding can be the use of start and end structure markers, (bracket pairs, possibly colorized), with the use of horizontal and vertical lines to connect the start and end of a structure and the colorization of pairs of markers.
But here too it is necessary to identify and pair the beginnings and ends of blocks which may require a semantic/syntactic analysis of the program.

from che-che4z-lsp-for-cobol.

zimlu02 avatar zimlu02 commented on July 28, 2024

Released in v2.1.1

from che-che4z-lsp-for-cobol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.