MarkusAmshove / natls

Language Server implementation for the Natural 4GL programming language
MIT License
12 stars 3 forks source link

Subdescriptors #507

Closed awilkins closed 2 weeks ago

awilkins commented 3 weeks ago

Fixes #506

Not sure about whether I need to add the subdescriptor fields to another collection ; superdescriptors reference existing fields, subdescriptors create new fields that are views on their parent (?).

You're not allowed to mix them, I think, which is how we are deciding whether it's super or sub.

MarkusAmshove commented 2 weeks ago

Side note: You can format the code with gradlew spotlessApply (documentation) if the check CI / Check formatting (pull_request) fails. That way your code will automatically get formatted to keep the diffs smaller :)

MarkusAmshove commented 2 weeks ago

If I understand the documentation correctly, then the following (previously unknown to me) rules apply:

With that in mind, I would change the parsing like this:

So having the following DDM:

DB: 000 FILE: 100  - COMPLETE-DDM                      DEFAULT SEQUENCE: 
TYPE: ADABAS
T L DB Name                              F Leng  S D Remark
- - -- --------------------------------  - ----  - - ------------------------
  1 AC ALPHA-FIELD                       A    8  N
  1 AB ANOTHER-NUMBER                    N   12  N
  1 AG A-SUBDESCRIPTOR                   A   20  N S
*      -------- SOURCE FIELD(S) -------
*      A-SUB-FIELD   (1-8)
*      SUB-FIELD-TWO (1-12)

The DDM should contain these fields:

and these descriptors:

I'm unsure about the descriptor type of A-SUBDESCRIPTOR, because the documentation states that it might be a descriptor itself, but we don't know how predict generates those sources.


Your changes don't raise any issues on our 6M LoC code base, so I don't have a problem with merging your changes, I'd do a few renames though.

We have a few choices now, you can decide :-)

The DDM parser will be rewritten in the future to enable the output to be used in the language server, but I've not planned when I come around to do it.

awilkins commented 2 weeks ago

Apologies for the intermittent communication : I work for this client Tue-Thu so there can sadly be these four day gaps ... my goal here is "eliminate all the ERROR level problems for code that clearly compiles and runs on the mainframe" and the codebase is ... on a similar order of magnitude in size (not as large as yours though), and several decades old, so hopefully we both get something out of collaborating :-)

I'd love to get to the point where I can put the sonar job in a CI pipeline and benefit from all that lovely linting, but even being able to use VSCode fluently is better than NaturalONE. Honestly, I started to write a tree-sitter parser for Natural and rapidly realized it would drive me mad before I got useful results.

I think the semi-big rewrite sounds better - you know your code better, you will know better how to refactor it. I'm at the stage where all I can do is copy how you've done something already.

I have more red squigglies to submit issues / PRs for :-)

We don't know how predict generates those sources.

If there are any experiments I can do for you I can try to get them done.

sonarcloud[bot] commented 2 weeks ago

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots

See analysis details on SonarCloud

MarkusAmshove commented 2 weeks ago

No problem, I'll close this PR and see what I can do. I'll @ you in the new one so you can get an idea what I was talking about :)

In our code base we have around 3000 parser diagnostics left. Some of them are still missing parts in the parser, others are actual runtime errors (like PERFORM to non existing subroutines, CALLNATs etc.). For us this is such a usable state, that almost all our developers (aside from 1-2) have switched to the Language Server for their daily work :)

If you want to summarize those issues better, you can run the linter CLI in your project root like this:

java -jar natlint.jar --sink=CSV -xlint

-xlint skips the linting, so only parser errors will come up --sink=CSV will write all diagnostics into a diagnostics.csv file

If you ever want to have a chat, feel free to send me an email to the address associated with my commits, I can send you my MS Teams contact then.

Claes is also working on mainframe support, they have a huge Natural project too :-)