Bug 471319 - Kotlin syntax does not permit comments in very many places
Summary: Kotlin syntax does not permit comments in very many places
Status: RESOLVED FIXED
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: syntax (other bugs)
Version First Reported In: 5.107.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-22 04:33 UTC by hatzka
Modified: 2023-07-12 20:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Sample code containing comments that aren't highlighted as comments (179 bytes, text/x-kotlin)
2023-06-23 01:37 UTC, hatzka
Details
The sample code, as displayed in Kate. (35.37 KB, image/png)
2023-06-23 01:38 UTC, hatzka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description hatzka 2023-06-22 04:33:49 UTC
SUMMARY
The Kotlin syntax (the one used for highlighting, as opposed to the syntax of the actual language) is unnecessarily restrictive about where comments can be placed. For example, it will not recognize comments on import lines, in variable definitions (before the identifier), in class bodies (after the first member), 

STEPS TO REPRODUCE
1. Create or open a Kotlin file.
2. Place a comment in any of the locations described above.

OBSERVED RESULT
The comment is not highlighted as a comment.

EXPECTED RESULT
The comment should be highlighted as a comment.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: couldn't find, sorry
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.107.0
Qt Version: 5.15.10
Comment 1 Waqar Ahmed 2023-06-22 06:58:30 UTC
Hi,

Would be great if you could provide sample code that exhibits the issue along with a screenshot. That would make it easier for anyone wanting to work on this.

Even better if you can fix this yourself and submit a patch. The syntax file for kotlin lives here https://invent.kde.org/frameworks/syntax-highlighting/-/blob/master/data/syntax/kotlin.xml. Checkout  https://docs.kde.org/stable5/en/kate/katepart/highlight.html to know how to test the file and changes locally.
Comment 2 hatzka 2023-06-23 01:37:41 UTC
Created attachment 159846 [details]
Sample code containing comments that aren't highlighted as comments
Comment 3 hatzka 2023-06-23 01:38:18 UTC
Created attachment 159847 [details]
The sample code, as displayed in Kate.
Comment 4 hatzka 2023-06-23 01:45:33 UTC
I did try to fix this myself, and I found that documentation, but it was complex enough I had to give up. I suppose if nobody who knows the format better is around to do it, I can try again.
Comment 5 Bug Janitor Service 2023-07-11 22:22:14 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/501
Comment 6 Jonathan Poelen 2023-07-12 20:18:05 UTC
Git commit 4c5d01c5937baa59c195ff61e1cec8b790adcff4 by Jonathan Poelen.
Committed on 11/07/2023 at 22:13.
Pushed by cullmann into branch 'master'.

Kotlin: fix Comment and Annotation ; add keywords

M  +33   -0    autotests/folding/test.kt.fold
M  +33   -0    autotests/html/test.kt.dark.html
M  +33   -0    autotests/html/test.kt.html
M  +33   -0    autotests/input/test.kt
M  +33   -0    autotests/reference/test.kt.ref
M  +39   -6    data/syntax/kotlin.xml

https://invent.kde.org/frameworks/syntax-highlighting/-/commit/4c5d01c5937baa59c195ff61e1cec8b790adcff4