Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cli option to include language parser details #102

Open
ajshedivy opened this issue Jan 13, 2025 · 3 comments
Open

Add cli option to include language parser details #102

ajshedivy opened this issue Jan 13, 2025 · 3 comments
Assignees

Comments

@ajshedivy
Copy link
Member

Overview

Introduce an option to integrate additional metadata from the RPG Language Server into the existing workflow. This enhancement will merge the source orbit output with detailed language information from the server. This utility will be used to improve contextualization of RPG Model.

so -withLsData -g "src/test.rpgle" -bf json

Example

For a single file:

**FREE

Dcl-Pr theExtProcedure ExtProc;
  theNewValue Char(20);
End-Pr;

Source orbit output:

{
  "targets": [
    {
      "systemName": "COPY1",
      "type": "MODULE",
      "relativePath": "test/copy1.rpgle",
      "extension": "rpgle",
      "imports": [
        "theExtProcedure"
      ],
      "deps": []
    }
  ],
  "resolved": [
    {
      "systemName": "COPY1",
      "type": "MODULE",
      "relativePath": "test/copy1.rpgle",
      "extension": "rpgle",
      "imports": [
        "theExtProcedure"
      ]
    }
  ],
  "exports": {},
  "messages": {
    "test/copy1.rpgle": [
      {
        "message": "type detected as MODULE but NOMAIN keyword was not found. Is it possible the extension should include '.pgm'?",
        "type": "warning"
      }
    ]
  }
}

RPG Language server cache on same source:

{
  "keyword": {},
  "parameters": [],
  "subroutines": [],
  "procedures": [
    {
      "type": "procedure",
      "name": "theExtProcedure",
      "keyword": {
        "EXTPROC": true
      },
      "description": "",
      "tags": [],
      "position": {
        "path": "/Users/adamshedivy/Documents/IBM/sandbox/oss/vscode/vscode-rpgle/cli/rpgparse/test/copy1.rpgle",
        "range": {
          "start": 15,
          "end": 30,
          "line": 2
        }
      },
      "references": [
        {
          "uri": "/Users/adamshedivy/Documents/IBM/sandbox/oss/vscode/vscode-rpgle/cli/rpgparse/test/copy1.rpgle",
          "offset": {
            "start": 15,
            "end": 30,
            "line": 2
          }
        }
      ],
      "subItems": [
        {
          "type": "subitem",
          "name": "theNewValue",
          "keyword": {
            "CHAR": "20"
          },
          "description": "",
          "tags": [],
          "position": {
            "path": "/Users/adamshedivy/Documents/IBM/sandbox/oss/vscode/vscode-rpgle/cli/rpgparse/test/copy1.rpgle",
            "range": {
              "start": 42,
              "end": 53,
              "line": 3
            }
          },
          "references": [
            {
              "uri": "/Users/adamshedivy/Documents/IBM/sandbox/oss/vscode/vscode-rpgle/cli/rpgparse/test/copy1.rpgle",
              "offset": {
                "start": 42,
                "end": 53,
                "line": 3
              }
            }
          ],
          "subItems": [],
          "readParms": false,
          "range": {
            "start": null,
            "end": null
          }
        }
      ],
      "readParms": true,
      "range": {
        "start": 2,
        "end": 4
      }
    }
  ],
  "files": [],
  "variables": [],
  "structs": [],
  "constants": [],
  "sqlReferences": [],
  "indicators": [],
  "tags": [],
  "includes": []
}

Add parser data under resolved:

...
  "resolved": [
    {
      "systemName": "COPY1",
      "type": "MODULE",
      "relativePath": "test/copy1.rpgle",
      "extension": "rpgle",
      "imports": [
        "theExtProcedure"
      ],
      "detail": {...}
    }
  ],

Procedurally generate natural language summary of source orbit and parser data:

The code provided has 4 procedures. procedureA, procedureB, procedureC, procedureD. File X is used in two of the defined procedures: procedureA and procedureB. This source also imports three export procedures, all of which are system APIs. File X is found based on the library list. procedureC contains Y SQL statements, which reference 3 tables: tableA, tableB, tableC
@worksofliam
Copy link
Member

The internal RPGLE and SQL parsers need to be updated for this.

@edmundreinhardt
Copy link
Member

@worksofliam Not sure what you mean by that.
I will have to try this out, but I was hoping to have not only included files resolved, but database record formats with all their subfields since they will likely be important to understanding most DB access code.

@edmundreinhardt
Copy link
Member

As i am testing this out, I realize that "so" does not access the IBM i host and therefore cannot resolve DB references

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants