1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add better regex highlighting in jsonata edit mode

Fixes #2465
This commit is contained in:
Nick O'Leary 2020-02-24 13:27:42 +00:00
parent 04d3981921
commit e16fe1e6a5
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -28,6 +28,11 @@ ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/m
}, "identifier"); }, "identifier");
this.$rules = { this.$rules = {
"start" : [ "start" : [
{
token: "string.regexp",
regex: "\\/",
next: "regex"
},
{ {
token : "string", token : "string",
regex : "'(?=.)", regex : "'(?=.)",
@ -46,34 +51,35 @@ ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/m
token : "constant.numeric", // float token : "constant.numeric", // float
regex : /[+-]?\d[\d_]*(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ regex : /[+-]?\d[\d_]*(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, },
{ token: "keyword", {
regex: /λ/ token: "keyword",
}, regex: /λ/
{ },
token: "keyword", {
regex: jsonataFunctions token: "keyword",
}, regex: jsonataFunctions
{ },
token : keywordMapper, {
regex : "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*" token : keywordMapper,
}, regex : "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*"
{ },
token : "punctuation.operator", {
regex : /[.](?![.])/ token : "punctuation.operator",
}, regex : /[.](?![.])/
{ },
token : "keyword.operator", {
regex : /\|\||<=|>=|\.\.|\*\*|!=|:=|[=<>`!$%&*+\-~\/^]/, token : "keyword.operator",
next : "start" regex : /\|\||<=|>=|\.\.|\*\*|!=|:=|[=<>`!$%&*+\-~\/^]/,
}, next : "start"
{ },
token : "punctuation.operator", {
regex : /[?:,;.]/, token : "punctuation.operator",
next : "start" regex : /[?:,;.]/,
}, next : "start"
{ },
token : "paren.lparen", {
regex : /[\[({]/, token : "paren.lparen",
regex : /[\[({]/,
next : "start" next : "start"
}, },
{ {
@ -86,7 +92,8 @@ ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/m
token : "string", token : "string",
regex : '"|$', regex : '"|$',
next : "start" next : "start"
}, { },
{
defaultToken: "string" defaultToken: "string"
} }
], ],
@ -95,9 +102,24 @@ ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/m
token : "string", token : "string",
regex : "'|$", regex : "'|$",
next : "start" next : "start"
}, { },
{
defaultToken: "string" defaultToken: "string"
} }
],
"regex" : [
{
token: "string.regexp",
regex: "\\\\/"
},
{
token: "string.regexp",
regex: "/[sxngimy]*",
next: "start"
},
{
defaultToken: "string.regexp"
}
] ]
}; };
}; };