Comments (5)
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.
from che-che4z-lsp-for-cobol.
@FALLAI-Denis would you be interested in providing input to this feature?
from che-che4z-lsp-for-cobol.
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.
Released in v2.1.1
from che-che4z-lsp-for-cobol.
Related Issues (20)
- Support for User-defined-functions HOT 1
- Generate COBOL Control Flow only shows the Nested Program, not the Main program that called it HOT 3
- ENTRY as variable name question HOT 1
- Log Server messages to VS Code output panel
- CCF & Cobol language support problem HOT 2
- copybook resolution breaks the analysis (corner case scenario)
- Support for "FUNCTION ALL INTRINSIC" HOT 2
- Version 2.0.2 keeps crashing HOT 3
- Don't allow variable names which are not supported by IBM cobol
- Provide Warning Messages HOT 1
- Add warning for unreachable code HOT 2
- Add warnings for moving a PIC X(n) variable to PIC S9(n) COMP
- Support relative paths from the current file HOT 1
- Rename dialects to custom preprocessors and add "real" dialect support. HOT 4
- DB2 dialect should inject variables and section as done by DB2 precompiler
- Intrinsic FUNCTION TRIM with LEADING / TRAILING support missing
- Add more SQL dialects (Oracle/Pro*COBOL, postgresql) HOT 3
- Support `CONTINUE AFTER`
- Uncommenting via Cmd+/ does not support floating comments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from che-che4z-lsp-for-cobol.