JavaScript: move keywords from TypeScript and other improvements
ClosedPublic

Authored by nibags on Nov 24 2019, 9:44 AM.

Details

Summary

In javascript.xml, keywords are moved from TypeScript. TypeScript and QML highlighters require JavaScript, therefore the content of javascript.xml is grouped into contexts for better inclusion. For example, keywords of built-in clases aren't included in QML and redundant content is excluded in TypeScript.

JavaScript:

  • Move keywords of built-in classes and functions from typescript.xml to javascript.xml.
    • Update list of classes.
    • Highlight Number, Math and DOM constants anywhere in the code.

  • After a string, just highlight valid regular expressions.

  • Numbers: highlight float of type 2e10 (since this form isn't highlighted by the Float rule), correctly highlight Bigint in hexadecimal, octale and binary.

  • Highlight all brackets (){}[] with "Normal Text", not with "Symbol", for better consistency in Solorized schemes.

  • Object highlighting is inconsistent: Before, they are highlighted as "Objects" (dsVariable), but only when they are before .. Now they will always be highlighted as "Normal text". Functions are now highlighted with "dsFunction", not with "dsAttribute" as the attributes.

TypeScript:

  • Adapt to JavaScript changes: highlight brackets {} with "Normal Text", not with "Symbol".
  • Some minor fixes.

JavaScript React (JSX) & TypeScript React (TSX):

  • Adapt to JavaScript changes: highlight brackets {} with "Normal Text", not with "Symbol".
  • Now the highlighter is more strict in detecting tag names, if the user writes an invalid name, the tag is simply not highlighted (it was previously highlighted as "Error"). This avoids a possible incorrect highlighting, between type assertion and tag.

QML:

  • Adapt to changes in JavaScript.
  • Fix the highlighting of conditional expressions a ? b : c. This bug is produced by D23272, the text in conditional expressions is incorrectly highlighted as a parameter.

  • Use JavaScript escapes in string, via IncludeRules.

CoffeeScript:

  • Adapt to changes in JavaScript (JS in embedded code): use "Normal" attribute in curly brackets and regular expressions after templates.

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nibags created this revision.Nov 24 2019, 9:44 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptNov 24 2019, 9:44 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Nov 24 2019, 9:44 AM
nibags updated this revision to Diff 70254.Nov 24 2019, 10:14 AM
  • Update comment

I think this is ok.

I recognize only now that a much better syntax would have been

<include definition="JavaScript">variable_property</include>

but that is off-topic :)

If the kateversions are correct, then I'm fine with this.

cullmann accepted this revision.Nov 26 2019, 6:03 PM

Nice improvements! Thanks a lot.

This revision is now accepted and ready to land.Nov 26 2019, 6:03 PM
This revision was automatically updated to reflect the committed changes.