IBM / zopeneditor-about

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

COBOL formatter - Wrongly excluding lines under conditional compilation control #425

Open FALLAI-Denis opened 4 months ago

FALLAI-Denis commented 4 months ago

Hi,

For the COBOL language, ZOE offers a code formatting system based on a zcodeformat (yaml|json) file describing the options. This feature is also available for IDz, but it is declared experimental for ZOE.

As far as we are concerned, COBOL formatting most of the time fail with an error message at the Language Server level. However, this functionality interests us because we are in the phase of migrating COBOL programs whose code was generated by a product (IBM VisualAge Pacbase, or IBM Rational Programming Patterns) to a more "academic" COBOL code.

Note that in our context we do not want to reformat the entire source code but only certain portions of the code. Our code is organized into different parts:

  1. an initial skeleton code, with the possibility of refreshing
  2. a code injected by a Coding Assistant, acting like a robot injecting snippets, but also with the possibility of refreshing this code, or removing it
  3. code manually written by the developer

It's only this third part that we want to be able to format. The other two parts must retain their formatting to ensure the possibility of refreshing or removal:

How can we diagnose formatting tool failures and thus help stabilize it?

Thanks.

phaumer commented 4 months ago

@FALLAI-Denis can you check the language server logs to see if they contain related exceptions? We would like to see those to find out what causes the crash. Also any code snippets we could reproduce issues with would be helpful.

https://ibm.github.io/zopeneditor-about/Docs/locating_local_client_logs.html#locating-vs-code-extension-and-lsp-log-files-on-the-local-client

FALLAI-Denis commented 4 months ago

Hi,

I didn't find any particular information in the files pointed to by "-data"...

No error message, no Java exception, but no formatting...: _ws_1721326660661.zip

Other logs:

zopeneditor-20240718-181734.zip

exthost.zip

FALLAI-Denis commented 4 months ago

PS: "full document format" is operational !

I found the problem: code controlled by a conditional compilation directive is not formatted, even if the condition is true.

I think code under conditional compilation control should always be formatted regardless of whether the condition is true or false.

Code out of control of conditional compilation: fully reformatted: image

Code under control of conditional compilation: not fully reformatted, (case rules applied, but alignment rules non applied), even if condition is true image

image

Also some "errors" in formatting... Some of them (left before format, right after format):

image

image

image