-
Notifications
You must be signed in to change notification settings - Fork 59
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
Nested block comments handled incorrectly for Transact-SQL (Microsoft SQL Server) #87
Comments
Block comments do not nest in C++ or Java. For SQL it depends on the variant: Oracle does not support nested comments but other vendors may allow them. https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/fundamentals.htm#BEIJCJED |
This issue is invalid as currently stated. The scope of the issue should be restricted to the particular SQL variant used where nested comments are allowed. Some documentation that shows the validity of nested quotes in that variant should be linked. |
Before I (regrettably) shepherded this issue from downstream, it was only about LexSQL's treatment of nested block comments in Transact-SQL queries. T-SQL does permit nested block comments, and, at a glance, so does LexMSSQL: Lines 229 to 234 in 22777f4
As in #85, the only discernible issue here is with the downstream application not providing bespoke lexing of T-SQL queries, since it does not implement LexMSSQL. |
Doesn't appear to be implemented from the code or running it. Since block comment nesting generally occurs over multiple lines, there needs to be a counter for the nesting lexel. This may be stored in line state or similar (there are no calls to line state in LexMSSQL) or as a limited set of styles like LexHaskell's It would be reasonable to add comment nesting to LexMSSQL. It may also be OK as an option to LexSQL as downstream projects often only support it. |
Sorry, I didn't add that I meant Microsoft SQL |
I would say its lack is a bug. Nested block comments appear to be a permanent feature of the specification, unlike the optional semi-colon after statements (the root cause of #85), which was deprecated a few editions ago.
Experience has shown that "multi-lexers" are more likely to be the source of future bug reports. Once you make an exception for this or that particular specification, where do you stop? |
There are many SQL variants around and it's unlikely there will be specific lexers for most. Where there are dialect specific lexers, then new features and bug fixes are less likely to propagate than with shared lexers. Providing options for features like nested comments also makes it possible to specify a profile that may, for example, highlight portability or versioning concerns.
The project should be able to follow language changes and extensions. |
Along those lines, here's a draft implementation of nested T-SQL block comments, using line state: 0001-LexMSSQL-Implement-nested-stream-comments.diff.txt These test files provide a quick proof of concept: An omnibus lexer test has to wait for a patch to an unrelated problem with USE [test]
GO
The first line should resume
To acheive that, however, this branch takes Unix EOLs for granted: Lines 267 to 271 in 55a507f
In CRLF mode,
|
DECLARE @find AS CHAR(30);
SELECT p.LastName + CHAR(13) FROM Person.Person p;
|
Here is a sample file that exercises most mssql styles along with some properties to show the styles. |
Committed the above Since the change fixes this issue it gets marked |
The author left no instance of The continuation of this issue is at #90, so a resolution, if any, can be made there. |
Description of the Issue
Code of SQL or C++ or Java commented by block commands which is nested (example below) is not highlighted correctly. Please notice that in development environments I tested, which I suppose doesn't use ScintillaOrg, highlighting works well.
I tested Microsoft SQ Server Management Studio, KDevelop, QtCreator.
/* aaaaaaaaaa
/* bbbbbbbbbbbbbbb */
aaaaaaaaaa */
Steps to Reproduce the Issue
Expected Behavior
all lines coming from example should be like as commented
Actual Behavior
last line is incorrectly highlighted - like would be not commented
Other information
I reported this issue also in Notepad++ bug tracker: notepad-plus-plus/notepad-plus-plus#11718
The text was updated successfully, but these errors were encountered: