-
Notifications
You must be signed in to change notification settings - Fork 3
CL Syntax Checker #35
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
base: main
Are you sure you want to change the base?
Conversation
|
@bobcozzi Is this PR ready for review? |
|
@bobcozzi We're going to need to use the components API in this PR like we discussed. |
|
Hey, welcome back. The PR currently is using cmd/ctrl+F5 to trigger syntax checking on the current line. I did not try to change the existing code. Perhaps it needs to also be triggered on an Enter key? |
I take it you got pulled into a million things to do before you "turn the page". I don't know what those "merging is blocked" message means so I am going to leave this with you and go back to the other extensions. Let me know if you need/want me to tweak anything regarding the CL syntax checker. |
|
Hello @bobcozzi. This is an awesome PR! There are some changes which will need to be made - one in particular is to move to use the component API provided by Code for IBM i. This will standardize the versioning and installation process to fit in with how we install other pieces on the IBM i. Would you be interested in doing this or would you like me to take a look at this if you don't mind me pushing directly to this branch? |
|
I haven't had success implementing the component API in my extensions, so yes, I'd like to see one in action. Feel free to push directly into this branch. Thanks! |
Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
…ggers Signed-off-by: Sanjula Ganepola <[email protected]>
|
@bobcozzi Sorry about the delay with getting to this. I was able to finish a first pass at making the changes to use the component API. In addition to that, I made some significant changes to how and when the syntax checker is triggered (so it is more inline with how the SQL syntax checker behaves in the Db2 for IBM i extension). I am open to discuss if you think it makes more sense for it to be user invoked as it was before rather than automatically (details below). I personally find having it automatically check to be very convenient. Changes
Currently, these changes are in my own branch (feature/cl-syntax-checker-component). I can go ahead and merge those changes into this branch if these changes sound good. I do have a couple questions for you: |
Signed-off-by: Sanjula Ganepola <[email protected]>
|
I sorry I was out of town the last few weeks. The UDTF's CHECKOPT parameter, accepts any of those values. Right nowt he default is *CL (command entry) which I selected because Liam was an advocate of developers running CL commands (which I don't think most people do during development). But that can be modified before we ship it. Note my UDTF parameter values such as *CLLE, *PDM, etc. are case insensitive. |
|
Your 2nd question about when to check---yes I agree that it should be when a statement is entered. |
@bobcozzi Even with From my testing, while this worked: SELECT * FROM TABLE(
CL_SYNTAX_CHECK(cmd=>'CHECKFILE: PGM PARM(&FILE &FILEATTR &OPTION)' , CHECKOPT=>'*CLLE'));this kinda thing fails: SELECT * FROM TABLE(
CL_SYNTAX_CHECK(cmd=>'CRTORD CUID(&CUID)' , CHECKOPT=>'*CLLE'));same for stuff like: SELECT * FROM TABLE(
CL_SYNTAX_CHECK(cmd=>'IF (&YYYY2 *LT 40) THEN(DO)' , CHECKOPT=>'*CLLE'));I am I using the UDTF incorrectly?
I probably didn't explain this clearly, but it doesn't actually check every 1.5 seconds constantly. Rather there needs to be a file change which starts a timer. Basically whenever a change is made, it starts a 1.5 second timer. If it hits the end the timer, it will run the syntax checker. If a change is made before that, it will restart the timer. This is to ensure it's not constantly being run as the user is typing. We could increase this to like 3 seconds if you think that is better. Users can also disable this automatic checking all together if they prefer (using the settings below). What do you think? |
|
I’m out of the country right now be back next week. Don’t have any computer stuff with me to check this out, so I’ll look at it next week thanks.Sent from my iPhoneOn Oct 7, 2025, at 7:06 PM, Sanjula Ganepola ***@***.***> wrote:SanjulaGanepola left a comment (IBM/vscode-clle#35)
So to get CL Program for ILE CL
@bobcozzi Even with CHECKOPT set to *CLLE, I see that it still fails in the cases I mentioned earlier. I have included the examples again below:
From my testing, while this worked:
SELECT * FROM TABLE(
CL_SYNTAX_CHECK(cmd=>'CHECKFILE: PGM PARM(&FILE &FILEATTR &OPTION)' , CHECKOPT=>'*CLLE'));
this kinda thing fails:
SELECT * FROM TABLE(
CL_SYNTAX_CHECK(cmd=>'CRTORD CUID(&CUID)' , CHECKOPT=>'*CLLE'));
same for stuff like:
SELECT * FROM TABLE(
CL_SYNTAX_CHECK(cmd=>'IF (&YYYY2 *LT 40) THEN(DO)' , CHECKOPT=>'*CLLE'));
I am I using the UDTF incorrectly?
Checking it every 1.5 seconds seems overkill for CL commands. I suppose we could also do it on a user idle-wait then go ahead and check it.
I probably didn't explain this clearly, but it doesn't actually check every 1.5 seconds constantly. Rather there needs to be a file change which starts a timer. Basically whenever a change is made, it starts a 1.5 second timer. If it hits the end the timer, it will run the the syntax checker. If a change is made before that, it will restart the timer. This is to ensure its not constantly being run as the user is typing. We could increase this to like 3 seconds if you think that is better. Users can also disable this automatic checking all together if they prefer:
image.png (view on web)
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
|
I was able to reproduce the issue on my system. I will look into it. |
|
The issue was that the documentation was unclear on the actual purpose of option 0 and 1. The new update will default to Option 3 which is Command Entry syntax checking. The following options will be available for the CHECKOPT parameter (upper/lower case is ignored):
I'll post this on Monday or Tuesday/ |
|
I have updated the code to use the appropriate syntax check environment option (see above msg) and have just now pushed the PR update. Hopefully I did the git push correctly. |
Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
…ommand checks Signed-off-by: Sanjula Ganepola <[email protected]>
Signed-off-by: Sanjula Ganepola <[email protected]>
|
@bobcozzi Thanks for making those changes. I gave it a try and it is work as expected now which is great! We are very close to getting these changes in. Did you by chance take a look at my clarification regarding the automatic syntax checking. If not, I have included the details again below:
A couple additional changes I made today:
This will probably all make more sense if you give this a try. I went ahead and pushed all my changes (as described throughout this PR) directly to this same branch. Can you do a |
Signed-off-by: Sanjula Ganepola <[email protected]>
|
I can do this tomorrow morning. Not sure why we need a progress bar but I'll see what it looks like--unless it is only appearing on the "Syntax Check On Open" option, then I get it. |
It would appear on both |
|
I had to update some parameters that were changed on the update() and one other function. |
Signed-off-by: Sanjula Ganepola <[email protected]>
|
I just pushed a commit to immediately run the syntax checker if the enter key is pressed. Can you give this a try? As for when the user is typing in general, what do you think about lowering the default check interval back to |
|
I've got a family obligation today, suddenly, so I'll test your addition Enter key this evening when I get home. If that's too late, I'm sure it is fine. (I assume you applied my changes) |
Signed-off-by: Sanjula Ganepola <[email protected]>
|
I pulled down everything I believe I should have and do not see the Enter key processing. |
|
@bobcozzi This branch should have the enter key changes as well as the changes you made as well. The specific changes for the enter key can be seen here: b4c4883 Can you double check that you are on the cl-syntax-checker branch and not the cl-syntax-checker-ibm-latest branch which I see you also created. That one is 4 commits behind:
|
|
When I press Enter, syntax checking doesn't seems to react to the Enter key. The timer still does however. [UPDATE] I updated the logic and now the sequence is that the message follows the original statement, however once the 1500 ms timer fires, all messages are cleared (as designed), but it only checks the current line. |
|
Okay, so while I managed to get the syntax errors to be more efficient in their use of the CL Syntax Checker (not calling it for all statements when one is changed or a new line is inserted) VS Code's desire to keep a Diagnostic message assigned to a specific line number ("hard coded") means that when a line is inserted or deleted above any existing Diagnostic messages (if they are not removed) are not shifted with the code itself. So they appear to be on the "wrong" line. Lastly, I'm wondering why you're not using the VS CODE "eol" identifier instead of '\r\n' and similar? |
|
Perhaps we need to only syntax check the current statement and leave it up until the next one. That's kind of how you had it working. What do you think??? |
|
Looking into this now |
Signed-off-by: Sanjula Ganepola <[email protected]>
This is still odd as this logic here should handle that. Can you try debugging this logic on your end and see if it properly detects if there is an enter and then validates right away?
Hmm I hadn't noticed this earlier as I always resolved the error before adding or removing a line above. This is an interesting problem since diagnostics are just tied to ranges in the document like you said. I gave this a try with the SQL syntax checker and looks like it also has this issue. @worksofliam Any suggestions here?
Good point. I updated this. |
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.
That looks correct (the EOL patcth)
|
I think the only thing we can do with CL short of porting the CL syntax checker to TypeScript (LOL) is to only check the current statement on either a timer or a keydown that is a character key (i.e., X, Y Z) and not an arrow key. Then when the next line is syntax checked, it currently clears that old line's diagnostics anyway. So if the error isn't cleared it will vanish until they get to it again. Then we can add in that "Check All" option, which unfortunately unless I update the UDTF will be a lengthy process. What do you think? |
|
I've experimented with the CL Syntax Checker UDTF and found that it's not practical to modify it to accept multiple source lines. Since CL statements can span multiple lines, passing an array of "lines" would require the UDTF to re-assemble each CL command from potentially fragmented lines. While associating errors with the primary line of a command is straightforward, reliably reconstructing commands from lines is complex and error-prone. Current Limitations
Recommended Approach
This approach checks one statement at a time, triggering syntax checking on a keyboard pause or the Enter key, and balances performance and functionality for CL development.
Summary
Optional Enhancements
SummaryThis approach delivers a practical, efficient, and developer-friendly syntax-checking experience for CL development in VS Code.
|
@SanjulaGanepola In the RPGLE extension, we have a feature where the diagnostic will clear when the range is edited: https://github.com/codefori/vscode-ibmi/blob/473c34ab435e26c70f4392231f2df84eb4a5edc5/src/ui/diagnostics.ts#L29-L42 Perhaps the CL and SQL extensions could follow this same configuration setting? |
|
@worksofliam Yes I do remember that, but the issue here is actually when changes are made outside the range (in particular above it). If a line above is removed or added, the diagnostics no longer apply to the correct line. |
|
@SanjulaGanepola I realise that now. But, it might be good if we wrote standard logic to be able to move diagnostics in accordance to the user edit that we could use across all the extensions. |
|
Yes, the Diagnostics object has a range associated with it. The code below may doe this for the CL syntax checker, if you'd like to integrate it into it. |







This is my pr to integrate the syntax checker into CLLE