-
Notifications
You must be signed in to change notification settings - Fork 104
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
Methods for object resolves #1224
Conversation
Signed-off-by: Liam Allan <[email protected]>
Signed-off-by: Liam Allan <[email protected]>
src/api/IBMiContent.ts
Outdated
return undefined; | ||
} | ||
|
||
async streamfileResolve(name: string, directories: QsysPath[]): Promise<string|undefined> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edmundreinhardt @SanjulaGanepola Looks like there is no way to /usr/bin/find
to take a list of file names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SanjulaGanepola Thanks - that syntax works. Working on that now.
-bash-5.1$ /usr/bin/find /QSYS.LIB/LIAMA.LIB/QRPGLESRC.FILE/ /QSYS.LIB/LIAMA.LIB/QRPGLEREF.FILE -name 'BADEMPS.*' -o -name 'BANG.*'
Signed-off-by: Liam Allan <[email protected]>
@worksofliam Code looks good to me - but I have no way of testing this, since the new methods are not being called anywhere. Btw, is this first step to make copy member resolution work like the RPG compiler? 🤞 |
That's exactly right! I do hope in the future we can write tests for this also. (#1179) |
Signed-off-by: Liam Allan <[email protected]>
Signed-off-by: Liam Allan <[email protected]>
I have added tests for these new APIs. @SanjulaGanepola Note that |
Signed-off-by: Liam Allan <[email protected]>
Signed-off-by: Liam Allan <[email protected]>
Signed-off-by: Liam Allan <[email protected]>
Signed-off-by: Liam Allan <[email protected]>
src/api/IBMiContent.ts
Outdated
if (find) { | ||
const command = [ | ||
find, | ||
...directories, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to work out how we can get this to be non-recursive and only look in the directories provided.
https://unix.stackexchange.com/questions/372994/equivalent-maxdepth-for-find-in-aix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@worksofliam I think we're on the wrong track here...
You basically only want to check for whether some specific members exists.
This can easily be accomplished by a simple script:
for m in /QSYS.LIB/VSCODEIBMI.LIB/CCSID1147.FILE/MEMBER.MBR /QSYS.LIB/QGPL.LIB/CCSID1147.FILE/MEMBER.MBR;
do
if [ -f $m ]
then
echo $m
fi
done
This also works for streamfiles:
for m in /TMP/testing/subdir/test.SQL /tmp/testing/test.sql;
do
if [ -f $m ]
then
echo $m
fi
done
No need for find
or any other utility...
Building the script can be done in a few lines - the list of files probably even in your favorite one-liners...! 😄
@chrjorgensen There is a reason we're standardising here with these APIs - I don't want to write the same script in every extension (this will be used in RPGLE, CL, etc!) Though that is very cool that you have figured out how to keep it simple - how do think we could go about using your idea inside of our API without |
@worksofliam Since copy members can be specified in different ways, it's probably a good idea to check the IMHO Especially the following are important details:
|
@chrjorgensen The specifics of those rules will be handled in the right language server. The rules you mentioned are specific to RPGLE, whereas CL and COBOL have different rules. The way I implemented these APIs will allow each language server to be flexible and implement the rules separately, but still rely on the same resolver |
@chrjorgensen Tried to use your suggestion, but it is not working as expected. Currently,
|
Signed-off-by: Liam Allan <[email protected]>
@worksofliam It returns the string nonetheless because you have not included the This should do it: for f in ...a.lot.of.files...; do if [ -f $f ]; then echo $f; break; fi; done Note I changed the |
Signed-off-by: Liam Allan <[email protected]>
@chrjorgensen Only just saw your comment.. let me try with your new string! |
Signed-off-by: Liam Allan <[email protected]>
Signed-off-by: Liam Allan <[email protected]>
@chrjorgensen That is awesome! It will likely perform a lot better too! Thank you so much. It is now ready for review. |
Signed-off-by: Liam Allan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@worksofliam I have tested your PR by running the test suite - not using the resolve methods in real life. I just made a little comment, which you may address or not...
When your have considered this, I will approve and merge.
src/api/IBMiContent.ts
Outdated
}); | ||
|
||
if (result.code === 0) { | ||
const [firstMost] = result.stdout.split(`,`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have a break in your for
loop, you don't need to retrieve the "firstmost" - there will be only one...
src/api/IBMiContent.ts
Outdated
}); | ||
|
||
if (result.code === 0 && result.stdout) { | ||
const [firstMost] = result.stdout.split(`\n`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here...
Signed-off-by: Liam Allan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion @chrjorgensen! I made the fix. Please review whenever you're ready.
@chrjorgensen Sorry to bug you on this. Can I get one more review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@worksofliam LGTM - approved...
seems a bit late to ask, but here i go: this functions must necessarily be implemented using the /usr/bin/find command or coud be done with SQL? maybe using the QSYS2.SYSPARTITIONSTAT for member resolver and QSYS2.IFS_OBJECT_STATISTICS for the streamfile resolver ? |
@angelorpa Why do you think it is a requirement to use The
|
3 similar comments
@angelorpa Why do you think it is a requirement to use The
|
@angelorpa Why do you think it is a requirement to use The
|
@angelorpa Why do you think it is a requirement to use The
|
@chrjorgensen I think you misunderstood my question or may be i formulated in a wrong way. I understood what this functions have to do, but i want to know if is possible implement this functionality using SQL instead of using the find command. I only was suggesting another way to do it. Tables QSYS2.IFS_OBJECT_STATISTICS and QSYS2.SYSPARTITIONSTAT could be used to search for a streamfile or a member, may be using SQL could be faster, easy to understand and more flexible. |
@angelorpa It sure is possible to create a search function using the SQL functions you mention - but that would only cover members, not streamfiles (unless you add the QSYS2.IFS_OBJECT_STATISTICS SQL function and then it get's tricky). Also running SQL has a cost when entering the SQL CLI, which runs in a separate job. SQL is great for retrieving information about something, but we just want to know the existence of a member or streamfile, not all its attributes. Instead of SQL we went for shell scripting, which is widely used in the industry, especially in Linux, and is quick to check for files (does not start a new job for this). We use the |
nice, thanks for the feedback. |
Changes
Adds new methods to help with resolving paths to source members and streamfiles.
Checklist
console.log
s I added