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

Member resolves, IFS resolves and local includePath support #225

Merged
merged 19 commits into from
Aug 14, 2023

Conversation

worksofliam
Copy link
Contributor

@worksofliam worksofliam commented Jun 15, 2023

Changes

  • Include and copy statements that have a member path will now resolve via the library list.
  • Include and copy statements that have a unix style path from a local file will now resolve via the includePath in iproj.json.
  • Streamfiles and local sources can now support member include paths correctly (valid in RPG)

Checklist

  • have tested my change
  • updated relevant documentation
  • Remove any/all console.logs I added
  • eslint is not complaining
  • have added myself to the contributors' list in the README
  • for feature PRs: PR only includes one feature enhancement.

Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
@chrjorgensen
Copy link
Contributor

chrjorgensen commented Jun 18, 2023

@worksofliam I was curious and went through your code for include and copy of members. And I noticed some things, that is not how the RPG compiler works (according to the documentation):

  • If no source file is specified, you assume QRPGLEREF - but the compiler searches QRPGLESRC, not QRPGLEREF!
  • If a member is found, you add the extension .rpgleinc - but the member extension is not known if shell search is performed, only if SQL is used at a later point in time.
  • Extension .rpgleinc is only used when a member is not found and IFS files are searched for. Then IFS files with the name and extension specified is searched for, or if no extension is specified, the name with extensions .rpgle and .rpgleinc.

It seems like there's some confusion about this subject, probably because of different conventions and company standards. But IMHO we should follow the rules laid out by the RPG compiler. ➡️

@worksofliam
Copy link
Contributor Author

@chrjorgensen wow, great write up!

  1. Whoops! Simple mistake on my part. I can correct to QRPGLESRC!
  2. We use rpgleinc just to give the member an extension. At resolve time, the extension isn't import, but we use it just to signify it is an include.
  3. I will fix up those IFS resolve inconsistencies.

Changes incoming over the next day or two with your suggestions. Thanks you!!

Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
@worksofliam
Copy link
Contributor Author

@chrjorgensen Based on your feedback, the only change I made is to use QRPGLESRC instead of QRPGLEREF.

The plan is to first get member resolves working, and then move onto IFS/local.

Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
@worksofliam worksofliam changed the title Feature/member resolves Member resolves, local includePath support Jun 23, 2023
Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
@worksofliam
Copy link
Contributor Author

worksofliam commented Jun 23, 2023

@chrjorgensen Further updates to improve the code and allow cross file system resolves and cleaner code. I updated the PR description to reflect all new changes.

@worksofliam worksofliam added the build Build in PR label Jun 23, 2023
Copy link
Contributor

@chrjorgensen chrjorgensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worksofliam

I tested by creating a library TESTPR225 and using the following RPGLE main source with /copy and /include statements from the documentation:

**free

/COPY MBR1
/INCLUDE SRCFIL,MBR2
/COPY TESTPR225/SRCFIL,MBR3
/INCLUDE TESTPR225/"SRC>3","MBR¬3"
/COPY /dir1/dir2/file.rpg
/COPY /dir1/dir2/file
/COPY dir1/dir2/file.rpg¬3"
/COPY "ifs file containing blanks"
/COPY 'ifs file containing blanks'

I tested the member / streamfile resolve by putting the cursor on the name and press Alt-F12 to peek the content of the include file.

I noted the following:

  1. The copy of MBR1 worked fine, member found was TESTPR225/QRPGLESRC/MBR1.RPGLE.
  2. The include of SRCFIL/MBR2 worked fine, member found was TESTPR225/SRCFIL/MBR2.RPGLE.
  3. The copy of TESTPR225/SRCFIL/MBR3 worked fine, member found was TESTPR225/SRCFIL/MBR3.RPGLE.
  4. The include of TESTPR225/"SRC>3","MBR¬3" could not be resolved. Compile found it.
  5. The IFS copy of /dir1/dir2/file.rpg could not be resolved. Compile found it.
  6. The IFS copy of /dir1/dir2/file could not be resolved. Compile found it.
  7. The IFS copy of dir1/dir2/file.rpg could not be resolved. Compile found it.
  8. The IFS copy of "ifs file containing blanks" could not be resolved. Compile found it.
  9. The IFS copy of 'ifs file containing blanks' could not be resolved. Compile found it.
  10. The member resolve worked both when TESTPR225 was the current library or in the library list (I had it as the last library in the list with a prior library also containing a source file called SRCFIL).

Changing the current library also didn't affect the resolve cache - I had to disconnect and reconnect to make the resolve work, after first having another current library than TESTPR225.

Should there be some command or other way of resetting the cache? Would be nice for the user to be able to do that, when the cache has old or obsolete content... or at least it should be cleared when the current library or library list changes...

Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
@github-actions
Copy link

👋 A new build is available for this PR based on 6178f1d.

Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
@github-actions
Copy link

👋 A new build is available for this PR based on 173bfb7.

@worksofliam
Copy link
Contributor Author

worksofliam commented Jun 29, 2023

@chrjorgensen

  • The include of TESTPR225/"SRC>3","MBR¬3" could not be resolved. Compile found it.
    • No plans to implement this style.
  • The IFS copy of /dir1/dir2/file.rpg could not be resolved. Compile found it.
    • This has been done. Explicit path started from root (/) will now resolve.
  • The IFS copy of /dir1/dir2/file could not be resolved. Compile found it.
    • Now works when path is relative.
  • The IFS copy of dir1/dir2/file.rpg could not be resolved. Compile found it.
    • This has been done. If not root (/) is provided, it will search relative of the working directory (which can be changed in the IFS path)
  • The IFS copy of "ifs file containing blanks" could not be resolved. Compile found it.
    • Support for double quotes is in.
  • The IFS copy of 'ifs file containing blanks' could not be resolved. Compile found it.
    • I think this should work now.

Changing the current library also didn't affect the resolve cache - I had to disconnect and reconnect to make the resolve work, after first having another current library than TESTPR225.

You can simple close and re-open the member/IFS/local file now.

I will post again when the remaining items are complete.

@worksofliam
Copy link
Contributor Author

Great progress has been made.

image

@chrjorgensen Back to you for another review whenever you can.

@worksofliam worksofliam requested a review from chrjorgensen June 29, 2023 23:21
@worksofliam worksofliam changed the title Member resolves, local includePath support Member resolves, IFS resolves and local includePath support Jun 29, 2023
Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
@github-actions
Copy link

👋 A new build is available for this PR based on 7dfe7f7.

Copy link
Contributor

@chrjorgensen chrjorgensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some further testing on the same test source:

❌ The copy of TESTPR225/SRCFIL,MBR3 no longer worked - your code probably thinks it's a UNIX path, when it's actually a QSYS path.
✔️ The IFS copy of /dir1/dir2/file.rpg worked now.
❌ The IFS copy of /dir1/dir2/file worked - partially. Could only be resolved, when exact filename existed, but no seatch for suffixes .rpgle and .rpgleinc is performed.
✔️ The IFS copy of dir1/dir2/file.rpg worked now.
❌ I could not get the IFS copy of "ifs file containing blanks" to work.
❌ I could not get the IFS copy of 'ifs file containing blanks' to work.

You should probably also take into consideration the rules for when the compiler can't determine the filesystem specified, as described here: https://www.ibm.com/docs/en/i/7.3?topic=files-include. Then both QSYS and IFS will be searched as documented. I see that you already commented on this in the code, but it seems not implemented yet?


} else {
// Path from home directory?
if (path.extname(cleanString) === ``) cleanString += `.*`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct - you can't just take any file with the name as specified and a random suffix.

The rules are like this for copy-files specified without extension:

If the path does not end with a suffix (for example ".txt"), the compiler will search for the file as named, and also for files with suffixes of ".rpgle" or ".rpgleinc".

So three files may be picked:

  1. File without suffix
  2. File with suffix .rpgleinc
  3. File with suffix .rpgle

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to wait for 2.0.0 of vscode-ibmi to search for multiple extensions.

extension/server/src/server.ts Outdated Show resolved Hide resolved
@chrjorgensen
Copy link
Contributor

@worksofliam IMHO the RPG /COPY documentation is confusingly organized - the INCLUDE FILES page seems the most important. It was probably added when RPG source code was allowed in the IFS.

An example that I was not really aware of:
/COPY mylib/myfile,mymbr can mean

  1. in the QSYS filesystem library mylib with source file myfile and member mymbr OR
  2. in the IFS (root) filesystem subdirectory mylib in the current working directory with streamfile myfile,mymbr

The page above has more examples.

So both QSYS and IFS filesystem are searched by the compiler unless the filename is in quotes.

I won't even go into the IFS include path using INCDIR parameter or RPGINCDIR environment variable...!

@chrjorgensen
Copy link
Contributor

One test still missing is /copy files in includePath - coming up later...

Signed-off-by: Liam Allan <mrliamallan@live.co.uk>
@github-actions
Copy link

👋 A new build is available for this PR based on a11c031.

@worksofliam
Copy link
Contributor Author

  • ✅ The copy of TESTPR225/SRCFIL,MBR3 no longer worked
    • This is fixed.
  • ✔️ The IFS copy of /dir1/dir2/file.rpg worked now.
  • ❌ The IFS copy of /dir1/dir2/file worked - partially. Could only be resolved, when exact filename existed, but no seatch for suffixes .rpgle and .rpgleinc is performed.
    • Left the current logic in until vscode-ibmi 2.0.0, which will allow us to search for many names.
  • ✔️ The IFS copy of dir1/dir2/file.rpg worked now.
  • ✅ I could not get the IFS copy of "ifs file containing blanks" to work.
    • This is fixed. Share what your include directive looks like if it fails again.
  • ✅ I could not get the IFS copy of 'ifs file containing blanks' to work.
    • This is fixed. Share what your include directive looks like if it fails again.

@worksofliam worksofliam requested a review from chrjorgensen July 14, 2023 13:25
@github-actions
Copy link

👋 A new build is available for this PR based on f912aed.

@worksofliam
Copy link
Contributor Author

@chrjorgensen I know you're about to depart for holiday, but whenever you're back...

✅ The copy of TESTPR225/SRCFIL,MBR3 no longer worked
This is fixed.
✔️ The IFS copy of /dir1/dir2/file.rpg worked now.
✅ The IFS copy of /dir1/dir2/file worked - partially. Could only be resolved, when exact filename existed, but no seatch for suffixes .rpgle and .rpgleinc is performed.
Left the current logic in until vscode-ibmi 2.0.0, which will allow us to search for many names.
✔️ The IFS copy of dir1/dir2/file.rpg worked now.
✅ I could not get the IFS copy of "ifs file containing blanks" to work.
This is fixed. Share what your include directive looks like if it fails again.
✅ I could not get the IFS copy of 'ifs file containing blanks' to work.
This is fixed. Share what your include directive looks like if it fails again.

@worksofliam worksofliam linked an issue Jul 17, 2023 that may be closed by this pull request
@github-actions
Copy link

👋 A new build is available for this PR based on 1ccde46.

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

👋 A new build is available for this PR based on 2be46c7.

Copy link
Contributor

@chrjorgensen chrjorgensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worksofliam I made a new review of the source and include statements:

  1. ❓ The copy of MBR1 worked almost, member found was TESTPR225/QRPGLESRC/MBR1.rpgleinc - but member extension actually was TXT.
  2. ❓ The include of SRCFIL/MBR2 worked almost, member found was TESTPR225/SRCFIL/MBR2.rpgleinc - but member extension actually was RPGLE.
  3. ❓ The copy of TESTPR225/SRCFIL/MBR3 worked almost, member found was TESTPR225/SRCFIL/MBR3.rpgleinc - but member extension actually was RPGLE.
  4. ✔️ The IFS copy of /dir1/dir2/file.rpg worked fine.
  5. ❓ The IFS copy of /dir1/dir2/file only worked, when the filename was file - but not with file.rpgle or file.rpgleinc. Can we include multi file search now?
  6. ✔️ The IFS copy of dir1/dir2/file.rpg worked fine.
  7. ❌ The IFS copy of "ifs file containing blanks" could not be resolved, even though a file named ifs file containing blanks was put in the current working directory.
  8. ❌ The IFS copy of 'ifs file containing blanks' could not be resolved, even though a file named ifs file containing blanks was put in the current working directory.

I think we're very close to having it - only minor issues except for the question of multi file search... 👍

edit from barry: added numbers to make it easier to reference

@worksofliam
Copy link
Contributor Author

worksofliam commented Aug 11, 2023

Thanks for testing @chrjorgensen!

For 1, 2 & 3: Right now, when including a member we default to rpgleinc as the extension. Our APIs don't provide the extension (always simply returns .MBR) so I decided to use .rpgleinc for now. Adding an additional call to get the valid extension is expensive and didn't seem worthy for now. While this may confuse our developers, I think initially this is something we can start with.

For 5: I tested this and it seemed to work as you described:

image

For 7 & 8: I mentioned previously that this style of include (paths with spaces) won't be supported in this PR (a risk I am also willing to take). It looks like there is a bug in the memberResolve API that will need fixing before this can work. I don't want to hold up this PR. edit: I made a PR in vscode-ibmi and requested your review which, in theory, should solve this.

@github-actions
Copy link

👋 A new build is available for this PR based on d8f74bc.

@chrjorgensen
Copy link
Contributor

@worksofliam IMHO it would be better to have no extension for members - since the extension is not specified in the /COPY statement and the extension actually is not part of the member name.

Instead of showing
billede
it should just show /TESTPR225/QRPGLESRC/MBR1 - is this difficult to implement?

I have reviewed your PR #1482 and made a suggestion...

@github-actions
Copy link

👋 A new build is available for this PR based on 4920529.

@chrjorgensen chrjorgensen self-requested a review August 11, 2023 16:00
Copy link
Contributor

@chrjorgensen chrjorgensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worksofliam I just did a final test: The hover is great now, 5 and 7-8 are still not working.

But we can fix this later, let's get this in now! Okay?

@worksofliam
Copy link
Contributor Author

@chrjorgensen 5 isn't working for you? That is odd! I actually wonder if we should take a look at that together before we merge this.

@worksofliam
Copy link
Contributor Author

worksofliam commented Aug 11, 2023

@chrjorgensen I went ahead and fixed the issue where the path name was being cut off as you discovered! Whenever you have the time, take another look with my latest commit!

@github-actions
Copy link

👋 A new build is available for this PR based on 4bb0894.

Copy link
Contributor

@chrjorgensen chrjorgensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@worksofliam Everything is working as expected now - even test 5, which was due to a mistake on my part!

Looking good! Approved! Merge at any time! 😄

@worksofliam worksofliam merged commit 8555858 into main Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build in PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

COPY/INCLUDE doesn't handle library list
2 participants