mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Add comment highlighting to JSONata and fix regex handling
Closes #2701
This commit is contained in:
		| @@ -12,7 +12,7 @@ ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/m | ||||
|     jsonataFunctions.sort(function(A,B) { | ||||
|         return B.length-A.length; | ||||
|     }); | ||||
|     jsonataFunctions = jsonataFunctions.join("|").replace(/\$/g,"\\$"); | ||||
|     jsonataFunctions = "("+jsonataFunctions.join("|").replace(/\$/g,"\\$")+")(\\b)"; | ||||
|  | ||||
|     var JSONataHighlightRules = function() { | ||||
|  | ||||
| @@ -27,12 +27,17 @@ ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/m | ||||
|             "function" | ||||
|         }, "identifier"); | ||||
|         this.$rules = { | ||||
|             "start" : [ | ||||
|             "no_regex" : [ | ||||
|                 { | ||||
|                     token: "string.regexp", | ||||
|                     regex: "\\/", | ||||
|                     next: "regex" | ||||
|                     token : "comment.doc", // doc comment | ||||
|                     regex : "\\/\\*", | ||||
|                     next  : "comments" | ||||
|                 }, | ||||
|                 // { | ||||
|                 //     token: "string.regexp", | ||||
|                 //     regex: "\\/", | ||||
|                 //     next: "regex" | ||||
|                 // }, | ||||
|                 { | ||||
|                     token : "string", | ||||
|                     regex : "'(?=.)", | ||||
| @@ -91,7 +96,7 @@ ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/m | ||||
|                 { | ||||
|                     token : "string", | ||||
|                     regex : '"|$', | ||||
|                     next  : "start" | ||||
|                     next  : "no_regex" | ||||
|                 }, | ||||
|                 { | ||||
|                     defaultToken: "string" | ||||
| @@ -101,7 +106,7 @@ ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/m | ||||
|                 { | ||||
|                     token : "string", | ||||
|                     regex : "'|$", | ||||
|                     next  : "start" | ||||
|                     next  : "no_regex" | ||||
|                 }, | ||||
|                 { | ||||
|                     defaultToken: "string" | ||||
| @@ -110,15 +115,37 @@ ace.define("ace/mode/jsonata",["require","exports","module","ace/lib/oop","ace/m | ||||
|             "regex" : [ | ||||
|                 { | ||||
|                     token: "string.regexp", | ||||
|                     regex: "\\\\/" | ||||
|                     regex: "/[sxngimy]*", | ||||
|                     next: "start" | ||||
|                 }, { | ||||
|                     defaultToken: "string.regexp" | ||||
|                 } | ||||
|             ], | ||||
|             "start": [ | ||||
|                 { | ||||
|                     token : "comment.doc", // doc comment | ||||
|                     regex : "\\/\\*", | ||||
|                     next  : "comments" | ||||
|                 }, | ||||
|                 { | ||||
|                     token: "string.regexp", | ||||
|                     regex: "/[sxngimy]*", | ||||
|                     next: "start" | ||||
|                     regex: "\\/", | ||||
|                     next: "regex", | ||||
|                 },{ | ||||
|                 // immediately return to the start mode without matching | ||||
|                 // anything | ||||
|                 token: "empty", | ||||
|                 regex: "", | ||||
|                 next: "no_regex" | ||||
|             }], | ||||
|             "comments": [ | ||||
|                 { | ||||
|                     token : "comment.doc", // doc comment | ||||
|                     regex : "\\*\\/", | ||||
|                     next  : "start" | ||||
|                 }, | ||||
|                 { | ||||
|                     defaultToken: "string.regexp" | ||||
|                     defaultToken: "comment.doc" | ||||
|                 } | ||||
|             ] | ||||
|         }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user