TypeCobolTeam / TypeCobol

TypeCobol is an Incremental Cobol parser for IBM Enterprise Cobol 6 for zOS syntax. TypeCobol is also an extension of Cobol 85 language which can then be converted to Cobol85.
Other
78 stars 26 forks source link

Adjust FILLER may produce invalid edits #2645

Closed fm-117 closed 2 months ago

fm-117 commented 2 months ago

Describe the bug TextEdits produced by refactor/adjustFillers may break code when applied because AdjustFillers does not account for line format.

To Reproduce (Type)Cobol code that cause the bug : (if any)

       IDENTIFICATION DIVISION.
       PROGRAM-ID. TCOMFL06.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 target-zone PIC X(200).
       01 redef1 REDEFINES target-zone.
          05 var1 PIC X(100).                                           01234567
       01 redef2 REDEFINES target-zone.
          05 var2 PIC X(100).
          05 FILLER PIC X(50).                                          01234567
       PROCEDURE DIVISION.
           GOBACK
           .
       END PROGRAM TCOMFL06.

When applying the refactoring on this document, both edits will be incorrect :

Expected behavior Ideally all edits should produce valid code. This may be difficult to implement when there is no space left on the line to edit.

Technical Improve AdjustFillerVisitor in order to reduce the probability of bad edits.

How to test automatically LSR tests.

fm-117 commented 2 months ago

More complex example for removal:

000100 IDENTIFICATION DIVISION.                                         00000100
000200 PROGRAM-ID. TCOMFL06.                                            00000200
000300 DATA DIVISION.                                                   00000300
000400 WORKING-STORAGE SECTION.                                         00000400
000500 01 group1.                                                       00000500
000600    05 target-zone PIC X(100).                                    00000600
000700    05 redef2 REDEFINES target-zone.                              00000700
000800       10 var2-1 PIC X(50).                                       00000800
000900       10 var2-2 PIC X(50). 10 FILLER                             00000800
000900* And a comment right in the middle of my useless FILLER !        00000800
001000                            PIC X(5). 05 other-data PIC X.        00001000
001100 PROCEDURE DIVISION.                                              00001100
001200      GOBACK                                                      00001200
001300      .                                                           00001300
001400 END PROGRAM TCOMFL06.                                            00001400