codefori / vscode-rpgle

RPGLE language tools for VS Code
MIT License
39 stars 20 forks source link

RPGLE Lint error on DS sub field defined in Workstation/Keyed file #185

Open m-tyler opened 1 year ago

m-tyler commented 1 year ago

Is it possible to remove the not reference lint error for fields defined in DSPF or PF and used on a DCL-F statement? These fields are defined in a DS to then overlaid by an array. While technically true these fields are not used in the RPGLE source to define these DS's to use overlay is cumbersome.

image

I will work on a test sample if this can be done and if desired.

worksofliam commented 1 year ago

It's likely possible, yes. If you've got a sample, that'd make my life just that bit easier.

m-tyler commented 1 year ago

ISSUE_185D.DSPF.txt ISSUE_185.RPGLE.txt

These two members compile for me.

worksofliam commented 1 year ago

After some thought about this, I could make this change, but the better thing I should likely do is make this rule more granular.

This is because the linter needs to work offline and when offline we don't have access to external file information.

Liam

m-tyler commented 1 year ago

Okay. You may prioritize as a low to medium need.

worksofliam commented 1 year ago

I think the right answer here is that if the POS keyword is found and the parent DS has references, then it should not be marked as unused.

m-tyler commented 1 year ago

This would make a lot of source I have to deal with look better.

m-tyler commented 1 year ago

Your solution looks like it will work for the example I gave above but looking over the DS for CRTFRMSTMF tool there are null named sub-fields that are marked up. It seems like *n field definitions should be ignored.

image

**FREE
...
// Valid commands and the corresponding object type
DCL-DS CommandsDS;
  *n CHAR(10) INZ('CRTCMD');
  *n CHAR(10) INZ('CRTBNDCL');
  *n CHAR(10) INZ('CRTCLMOD');
  *n CHAR(10) INZ('CRTDSPF');
  *n CHAR(10) INZ('CRTPRTF');
  *n CHAR(10) INZ('CRTLF');
  *n CHAR(10) INZ('CRTPF');
  *n CHAR(10) INZ('CRTMNU');
  *n CHAR(10) INZ('CRTPNLGRP');
  *n CHAR(10) INZ('CRTQMQRY');
  *n CHAR(10) INZ('CRTSRVPGM');
  *n CHAR(10) INZ('CRTWSCST');
  *n CHAR(10) INZ('CRTRPGPGM');
  *n CHAR(10) INZ('CRTSQLRPG');
  Commands CHAR(10) DIM(14) POS(1);
END-DS;

DCL-DS ObjTypesDS;
  *n CHAR(10) INZ('CMD');
  *n CHAR(10) INZ('PGM');
  *n CHAR(10) INZ('MODULE');
  *n CHAR(10) INZ('FILE');
  *n CHAR(10) INZ('FILE');
  *n CHAR(10) INZ('FILE');
  *n CHAR(10) INZ('FILE');
  *n CHAR(10) INZ('MENU');
  *n CHAR(10) INZ('PNLGRP');
  *n CHAR(10) INZ('QMQRY');
  *n CHAR(10) INZ('SRVPGM');
  *n CHAR(10) INZ('WSCST');
  *n CHAR(10) INZ('PGM');
  *n CHAR(10) INZ('PGM');
  ObjTypes CHAR(10) DIM(14) POS(1);
END-DS;