Bug 421445 - Opening double quote in sql-postgresql has "comment" attribute instead of "identifier"
Summary: Opening double quote in sql-postgresql has "comment" attribute instead of "id...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: syntax (show other bugs)
Version: 5.70.0
Platform: Ubuntu Linux
: NOR minor
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-13 04:33 UTC by Benjamin Wuethrich
Modified: 2020-05-15 15:45 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Screenshot of incorrectly highlighted opening double quote (22.75 KB, image/png)
2020-05-13 04:33 UTC, Benjamin Wuethrich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Wuethrich 2020-05-13 04:33:56 UTC
Created attachment 128412 [details]
Screenshot of incorrectly highlighted opening double quote

SUMMARY

When double quoting a string in a PostgreSQL statement such as when setting an output name in a select statement, the opening double quote is highlighted as a comment instead of as an identifier.


STEPS TO REPRODUCE

1. Create a new document in Kate
2. Set syntax highlighting language to "SQL (PostgreSQL)"
3. Write a statement including a double quote, for example

        select 'foo' "bar";


OBSERVED RESULT

The opening double quote is highlighted as a comment, the identifier and the closing double quote as an identifier (see attachment).


EXPECTED RESULT

The quoted string is highlighted as an identifier, both quotes included.


SOFTWARE/OS VERSIONS

Ubuntu 19.10
Kate 19.04.3
KDE Frameworks 5.62.0
Qt 5.12.4 (built against 5.12.4)


ADDITIONAL INFORMATION

The same error affects Pandoc syntax highlighting, which uses Skylighting, which uses the KDE syntax definition files.

John MacFarlane, the creator of Skylighting and Pandoc, pointed me to this line in the syntax file, which seems to be the culprit:

    <DetectChar attribute="Comment" context="Identifier" char="&quot;"/>

Phabricator link: https://phabricator.kde.org/source/syntax-highlighting/browse/master/data/syntax/sql-postgresql.xml$1010

Looking further to when this was introduced, I found this commit back when syntax highlighting was in Kate: https://invent.kde.org/kde/kate/-/commit/2e55bd0ca7deaaffe5546f04e2925112cca2a9a6#5d04d3f12b2774e3618e339c318f3154ac45df03

It changes line 749 from

    <DetectChar attribute="9" context="5" char="&quot;"/>

to the line shown above (line 750 after commit diff):

    <DetectChar attribute="Comment" context="Identifier" char="&quot;"/>

but attribute="9" corresponds to "Identifier"; "Comment" would be "8", as can be seen by inspecting the surrounding lines and the <itemDatas> array.
Comment 1 Christoph Cullmann 2020-05-15 15:45:19 UTC
Git commit f804af905ef3a3de8aa6bdd49344f231e420b82d by Christoph Cullmann.
Committed on 15/05/2020 at 15:45.
Pushed by cullmann into branch 'master'.

Assign "Identifier" attribute to opening double quote instead of "Comment"

Summary:
When the PostgreSQL syntax definition file was converted from using named attributes and contexts instead of numbers in [this commit](https://invent.kde.org/kde/kate/-/commit/2e55bd0ca7deaaffe5546f04e2925112cca2a9a6#5d04d3f12b2774e3618e339c318f3154ac45df03), the attribute for an opening double quote was incorrectly set to `"Comment"` instead of `"Identifier"`. This patch fixes that.

Test Plan:
Incorrect opening double quote before fix:

{F8318517}

Correct opening double quote after fix:

{F8318530}

Reviewers: #framework_syntax_highlighting, dhaumann

Reviewed By: #framework_syntax_highlighting, dhaumann

Subscribers: cullmann, dhaumann, kwrite-devel, kde-frameworks-devel

Tags: #framework_syntax_highlighting, #kate, #frameworks

Differential Revision: https://phabricator.kde.org/D29735

M  +2    -2    data/syntax/sql-postgresql.xml

https://commits.kde.org/syntax-highlighting/f804af905ef3a3de8aa6bdd49344f231e420b82d