codefori / codefori/vscode-rpgle
support IGNORE and INCLUDE file keywords that filter which record formats are brought into the RPG name space
- Dominant language
- TypeScript
- Stars
- 57
- Forks
- 35
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 1
Description
The IGNORE keyword removes a record format from the RPG names space and should be reflected in the outline view/symbols
A separate bug is the KEY01 is not showing and it should, even though it has not named fields, the record format itself is a referencable symbol.
Likewise the INCLUDE keyword should only include the named record format and no others. In this case neither CTL01 or SFL01 should have been available:
THese examples are found in [data/explain/IBM/AGR300](https://github.ibm.com/ibmi-toronto/rpg-genai-data/tree/main/data/explain/IBM/AGR300) used as a Bob project - build the project and make sure it is in the library list so the FILE objects are found. Feel free to use them in your testcases.
Here is the Java code I used to handled IGNORE, INCLUDE
```java
if (file.isExternalDescribed() && _connection != null) {
// What external library/file should be resolved
String externalLibraryName = CONST_LIBL;
String externalFileName = file.getName();
DeviceType externalDevice = file.getDevice();
Keyword extdesc = fileKeywords.findKeyword(KeywordId.EXTDESC);
if (extdesc != null) {
QsysObjectName name = null;
//Resolving EXTDESC(constant)
String qualifiedname = extdesc.getParmConstantStringValue(0, file.getDataScope());
if (qualifiedname != null) {
name = new QsysObjectName(qualifiedname);
} if (name == null) {
name = extdesc.getParmQsysObjectName(0);
}
if (name != null) {
externalLibraryName = name.getLibrary();
externalFileName = name.getObject();
}
}
else if (file.isLikeFile()) {
externalFileName = file.getRootFileName();
//If the file is not found
if (externalFileName == null) {
file.setStatus(ExtractStatus.FAILED);
return false;
}
}
file.setResolvedFile(externalLibraryName, externalFileName);
IHostFile hostFile = HostCache.instance.retrieveAndUpdate(_populateCache, _connection, externalLibraryName, externalFileName, externalDevice);
// now update the File model node with the host info
if (hostFile != null) {
file.setResolvedFile(hostFile.getResolvedLibraryName(), hostFile.getFileName());
DataScope dataScope = file.getDataScope();
//**************************************************************
// Start: Fetch all keywords before constructing file descriptions
//**************************************************************
...
HashSet ignoreList = null;
HashSet includeList = null;
Keyword ignoreKwd = fileKeywords.findKeyword(KeywordId.IGNORE);
if (ignoreKwd != null) {
if (ignoreKwd.getParameters().size() > 0)
ignoreList = new HashSet();
for (IExpression parm : ignoreKwd.getParameters()) {
if (parm instanceof SymbolReference &&
!ignoreList.contains(((SymbolReference) parm).getName()))
ignoreList.add(NlsUtil.toUpperCase(((SymbolReference) parm).getName()));
}
}
else {
Keyword includeKwd = fileKeywords.findKeyword(KeywordId.INCLUDE);
if (includeKwd != null) {
if (includeKwd.getParameters().size() > 0)
includeList = new HashSet();
for (IExpression parm : includeKwd.getParameters()) {
if (parm instanceof SymbolReference &&
!includeList.contains(((SymbolReference) parm).getName()))
includeList.add(NlsUtil.toUpperCase(((SymbolReference) parm).getName()));
}
}
}
//************************************************************
// End: Fetch all keywords before constructing file descriptions
//************************************************************
for (IHostRecordFormat record : hostFile.getRecords()) {
String recordName = record.getName();
// if the record format is on the ignore list, skip
if (ignoreList != null) {
if (ignoreList.contains(recordName))
continue;
}
// if an include list exists, and the record format is not on the list, skip
else if (includeList != null) {
if (!includeList.contains(recordName))
continue;
}
ExternalRecordFormat extRecordFormat = RpgleFactory.eINSTANCE.createExternalRecordFormat();
...
dataScope.addSymbolDefinition(extRecordFormat);
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.