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

Implement syntax checking features #307

Merged
merged 57 commits into from
Jan 9, 2025
Merged

Conversation

worksofliam
Copy link
Contributor

@worksofliam worksofliam commented Dec 17, 2024

Introduce a problem provider that highlights SQL syntax issues and allows for configurable syntax check intervals. This feature will only syntax check as you are typing. If you're working in a document made up of multiple statements, it will only check the statement you're currently working on while you type. You can use the newly added button to check an entire document.

How to test while editing:

  1. Connect to IBM i with Code for IBM i
  2. Open an SQL document (new or existing)
  3. Start typing. There is wait period before the syntax is checked (configurable), but the default is 1.5 seconds.

Test the Check Syntax button:

  1. Connect to IBM i with Code for IBM i
  2. Open an SQL document (new or existing)
  3. Press the Check Syntax button, which appears next to the Run button in the editor bar in the top right.
image

@worksofliam worksofliam changed the title Implement problem provider and syntax checking features Implement syntax checking features Dec 17, 2024
Copy link

github-actions bot commented Dec 17, 2024

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

@p-behr
Copy link

p-behr commented Dec 18, 2024

It sure appears to provide the same syntax check as running the SQL in ACS Run SQL Scripts :-)

@chrjorgensen chrjorgensen self-requested a review December 18, 2024 16:46
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 Looking good and working fine with most samples. 👍

I found one issue:

  • connect to IBM i (7.5 in my test)
  • open a new SQL document
  • enter the following source:
update qtemp.temp_rcpout
   set COL1 = '123'
     , COL2 = replace( COL2, 'a', 'A' )
     , COL3 = replace( COL3, 'b', 'B' )
     , COL4 = 'L'
     , COL5 = '/dir1/'
     , COL6 = 0
  • press the button to syntax check

I then get this:

billede

@worksofliam
Copy link
Contributor Author

@chrjorgensen Have another look. I added some additional logic to handle when the message ID is not returned, which is why you were seeing the blank message. It actually looks like this could be a bug in the system API, and IMO shouldn't be impactful to this PR.

I also made it so 01 SQL states are warnings and not errors.

@worksofliam
Copy link
Contributor Author

@chrjorgensen I added a new VS Code configuration option to determine if warnings should be shown. It is false by default.

@worksofliam worksofliam linked an issue Dec 19, 2024 that may be closed by this pull request
@julesyan
Copy link
Collaborator

julesyan commented Jan 8, 2025

There seems to be some issue with the syntax checking running when I comment out a line. I have the following

stop;
stop;
stop;

Which produces three errors. If i press CMD + / that line gets checked correctly. But if i comment out a second line, that second line does not get checked and the error remains. Same if i comment out a third line. The order of the lines do not seem to matter.

@julesyan
Copy link
Collaborator

julesyan commented Jan 8, 2025

Another issue found for CL commands. If i start with CL on a line it syntax check and gives an error. Then when i continue writing the rest of the line where it is CL: <command>; it never rechecks to remove the error.
Same happens if i delete the : on an existing CL command, wait for syntax check, then add it back in.

Signed-off-by: worksofliam <[email protected]>
…st error offsets for syntax errors outside statement boundaries. Add test case for mixed valid and invalid SELECT statements.

Signed-off-by: worksofliam <[email protected]>
Signed-off-by: worksofliam <[email protected]>
Copy link
Collaborator

@forstie forstie left a comment

Choose a reason for hiding this comment

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

Good job dealing with the side issues found during testing.
A very nice addition indeed.

Copy link
Collaborator

@julesyan julesyan left a comment

Choose a reason for hiding this comment

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

There seems to be some issue with the syntax checking running when I comment out a line.

Actually this is still happening

Signed-off-by: worksofliam <[email protected]>
@worksofliam worksofliam merged commit 268ffb5 into main Jan 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offset to error into the string of SQL when creating procedures and function Syntax checker
5 participants