JavaScript: move keywords from TypeScript and other improvements

Authored by nibags on Nov 26 2019, 6:03 PM.

Description

JavaScript: move keywords from TypeScript and other improvements

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.

Reviewers: cullmann, dhaumann, Framework: Syntax Highlighting

Reviewed By: cullmann, Framework: Syntax Highlighting

Subscribers: kwrite-devel, kde-frameworks-devel

Tags: Kate, Frameworks

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