From 69edbf946058365345d27886464ed8fe462de944 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 27 Aug 2014 17:30:12 +0400 Subject: [PATCH 1/6] github pages now requires https submodule urls --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 4678c516..07bbe371 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "doc/wiki"] path = doc/wiki - url = git://github.com/ajaxorg/ace.wiki.git + url = https://github.com/ajaxorg/ace.wiki.git [submodule "build"] path = build - url = git://github.com/ajaxorg/ace-builds.git + url = https://github.com/ajaxorg/ace-builds.git From 7a3a84c8583d49f6acf5948ad6a386737fa7ee17 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 2 Sep 2014 01:16:10 +0400 Subject: [PATCH 2/6] fix error in coffeeScript mode --- lib/ace/mode/_test/text_coffee.txt | 1 + lib/ace/mode/_test/tokens_coffee.json | 17 +++++++++++++++++ lib/ace/mode/_test/tokens_latex.json | 4 +++- lib/ace/mode/_test/tokens_php.json | 2 +- lib/ace/tokenizer.js | 8 +++++--- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/ace/mode/_test/text_coffee.txt b/lib/ace/mode/_test/text_coffee.txt index 094e61b7..2d9ba5ad 100644 --- a/lib/ace/mode/_test/text_coffee.txt +++ b/lib/ace/mode/_test/text_coffee.txt @@ -42,6 +42,7 @@ class Foo extends Bar foo.static.function #!test tokenize string with interpolation a = "#{ 22 / 7 + {x: "#{a + b}"} + 2}" +" #{ "" + {} } )" """heredoc """ do -> diff --git a/lib/ace/mode/_test/tokens_coffee.json b/lib/ace/mode/_test/tokens_coffee.json index 9c3967e4..b0703b37 100644 --- a/lib/ace/mode/_test/tokens_coffee.json +++ b/lib/ace/mode/_test/tokens_coffee.json @@ -466,6 +466,23 @@ ["constant.numeric","2"], ["paren.string","}"], ["string.end","\""] +],[ + "start", + ["string.start","\""], + ["string"," "], + ["paren.string","#{"], + ["text"," "], + ["string.start","\""], + ["string.end","\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["paren","{}"], + ["text"," "], + ["paren.string","}"], + ["string"," )"], + ["string.end","\""], + ["text"," "] ],[ "qqdoc", ["string","\"\"\"heredoc"] diff --git a/lib/ace/mode/_test/tokens_latex.json b/lib/ace/mode/_test/tokens_latex.json index 4ae69afa..52508e0d 100644 --- a/lib/ace/mode/_test/tokens_latex.json +++ b/lib/ace/mode/_test/tokens_latex.json @@ -92,7 +92,9 @@ ],[ "start", ["text"," E &= mc^2 "], - ["constant.character.escape","\\\\"], + ["constant.character.escape","\\\\"] +],[ + "start", ["text"," m &= "], ["storage.type","\\frac"], ["lparen","{"], diff --git a/lib/ace/mode/_test/tokens_php.json b/lib/ace/mode/_test/tokens_php.json index d1458a65..2134dccb 100644 --- a/lib/ace/mode/_test/tokens_php.json +++ b/lib/ace/mode/_test/tokens_php.json @@ -138,7 +138,7 @@ ["text"," "], ["support.php_tag"," 1) { if (stack[0] !== currentState) - stack.unshift(currentState); + stack.unshift("#tmp", currentState); } return { tokens : tokens, From 09ddbeb3417d668cdb47a46225d3f46a68f42d80 Mon Sep 17 00:00:00 2001 From: nightwing Date: Mon, 18 Nov 2013 10:43:42 +0400 Subject: [PATCH 3/6] add Io mode --- demo/kitchen-sink/docs/io.io | 6 ++ lib/ace/ext/modelist.js | 11 +-- lib/ace/mode/io.js | 58 ++++++++++++++ lib/ace/mode/io_highlight_rules.js | 120 +++++++++++++++++++++++++++++ lib/ace/snippets/io.js | 69 +++++++++++++++++ 5 files changed, 259 insertions(+), 5 deletions(-) create mode 100644 demo/kitchen-sink/docs/io.io create mode 100644 lib/ace/mode/io.js create mode 100644 lib/ace/mode/io_highlight_rules.js create mode 100644 lib/ace/snippets/io.js diff --git a/demo/kitchen-sink/docs/io.io b/demo/kitchen-sink/docs/io.io new file mode 100644 index 00000000..4b80b6c2 --- /dev/null +++ b/demo/kitchen-sink/docs/io.io @@ -0,0 +1,6 @@ +// computes factorial of a number +factorial := method(n, + if(n == 0, return 1) + res := 1 + Range 1 to(n) foreach(i, res = res * i) +) \ No newline at end of file diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index 14a55f7b..3ffac26b 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -66,8 +66,8 @@ var supportedModes = { Dockerfile: ["^Dockerfile"], Dot: ["dot"], Eiffel: ["e"], - Erlang: ["erl|hrl"], EJS: ["ejs"], + Erlang: ["erl|hrl"], Forth: ["frt|fs|ldr"], FTL: ["ftl"], Gcode: ["gcode"], @@ -83,6 +83,7 @@ var supportedModes = { HTML: ["html|htm|xhtml"], HTML_Ruby: ["erb|rhtml|html.erb"], INI: ["ini|conf|cfg|prefs"], + Io: ["io"], Jack: ["jack"], Jade: ["jade"], Java: ["java"], @@ -103,11 +104,11 @@ var supportedModes = { LuaPage: ["lp"], Lucene: ["lucene"], Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], - MATLAB: ["matlab"], Markdown: ["md|markdown"], + MATLAB: ["matlab"], MEL: ["mel"], - MySQL: ["mysql"], MUSHCode: ["mc|mush"], + MySQL: ["mysql"], Nix: ["nix"], ObjectiveC: ["m|mm"], OCaml: ["ml|mli"], @@ -129,14 +130,14 @@ var supportedModes = { SASS: ["sass"], SCAD: ["scad"], Scala: ["scala"], - Smarty: ["smarty|tpl"], Scheme: ["scm|rkt"], SCSS: ["scss"], SH: ["sh|bash|^.bashrc"], SJS: ["sjs"], - Space: ["space"], + Smarty: ["smarty|tpl"], snippets: ["snippets"], Soy_Template:["soy"], + Space: ["space"], SQL: ["sql"], Stylus: ["styl|stylus"], SVG: ["svg"], diff --git a/lib/ace/mode/io.js b/lib/ace/mode/io.js new file mode 100644 index 00000000..f3cd4cf0 --- /dev/null +++ b/lib/ace/mode/io.js @@ -0,0 +1,58 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +/* + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js +*/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var IoHighlightRules = require("./io_highlight_rules").IoHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = IoHighlightRules; + this.foldingRules = new FoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "//"; + this.blockComment = {start: "/*", end: "*/"}; + // Extra logic goes here. + this.$id = "ace/mode/io" +}).call(Mode.prototype); + +exports.Mode = Mode; +}); \ No newline at end of file diff --git a/lib/ace/mode/io_highlight_rules.js b/lib/ace/mode/io_highlight_rules.js new file mode 100644 index 00000000..99bc4cda --- /dev/null +++ b/lib/ace/mode/io_highlight_rules.js @@ -0,0 +1,120 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +/* This file was autogenerated from tm bundles\io.tmbundle/Syntaxes/io.plist (uuid: ) */ +/**************************************************************************************** + * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * + * fileTypes * + ****************************************************************************************/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var IoHighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { start: + [ { token: [ 'text', 'meta.empty-parenthesis.io' ], + regex: '(\\()(\\))', + comment: 'we match this to overload return inside () --Allan; scoping rules for what gets the scope have changed, so we now group the ) instead of the ( -- Rob' }, + { token: [ 'text', 'meta.comma-parenthesis.io' ], + regex: '(\\,)(\\))', + comment: 'We want to do the same for ,) -- Seckar; same as above -- Rob' }, + { token: 'keyword.control.io', + regex: '\\b(?:if|ifTrue|ifFalse|ifTrueIfFalse|for|loop|reverseForeach|foreach|map|continue|break|while|do|return)\\b' }, + { token: 'punctuation.definition.comment.io', + regex: '/\\*', + push: + [ { token: 'punctuation.definition.comment.io', + regex: '\\*/', + next: 'pop' }, + { defaultToken: 'comment.block.io' } ] }, + { token: 'punctuation.definition.comment.io', + regex: '//', + push: + [ { token: 'comment.line.double-slash.io', + regex: '$', + next: 'pop' }, + { defaultToken: 'comment.line.double-slash.io' } ] }, + { token: 'punctuation.definition.comment.io', + regex: '#', + push: + [ { token: 'comment.line.number-sign.io', regex: '$', next: 'pop' }, + { defaultToken: 'comment.line.number-sign.io' } ] }, + { token: 'variable.language.io', + regex: '\\b(?:self|sender|target|proto|protos|parent)\\b', + comment: 'I wonder if some of this isn\'t variable.other.language? --Allan; scoping this as variable.language to match Objective-C\'s handling of \'self\', which is inconsistent with C++\'s handling of \'this\' but perhaps intentionally so -- Rob' }, + { token: 'keyword.operator.io', + regex: '<=|>=|=|:=|\\*|\\||\\|\\||\\+|-|/|&|&&|>|<|\\?|@|@@|\\b(?:and|or)\\b' }, + { token: 'constant.other.io', regex: '\\bGL[\\w_]+\\b' }, + { token: 'support.class.io', regex: '\\b[A-Z](?:\\w+)?\\b' }, + { token: 'support.function.io', + regex: '\\b(?:clone|call|init|method|list|vector|block|\\w+(?=\\s*\\())\\b' }, + { token: 'support.function.open-gl.io', + regex: '\\bgl(?:u|ut)?[A-Z]\\w+\\b' }, + { token: 'punctuation.definition.string.begin.io', + regex: '"""', + push: + [ { token: 'punctuation.definition.string.end.io', + regex: '"""', + next: 'pop' }, + { token: 'constant.character.escape.io', regex: '\\\\.' }, + { defaultToken: 'string.quoted.triple.io' } ] }, + { token: 'punctuation.definition.string.begin.io', + regex: '"', + push: + [ { token: 'punctuation.definition.string.end.io', + regex: '"', + next: 'pop' }, + { token: 'constant.character.escape.io', regex: '\\\\.' }, + { defaultToken: 'string.quoted.double.io' } ] }, + { token: 'constant.numeric.io', + regex: '\\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:L|l|UL|ul|u|U|F|f)?\\b' }, + { token: 'variable.other.global.io', regex: 'Lobby\\b' }, + { token: 'constant.language.io', + regex: '\\b(?:TRUE|true|FALSE|false|NULL|null|Null|Nil|nil|YES|NO)\\b' } ] } + + this.normalizeRules(); +}; + +IoHighlightRules.metaData = { fileTypes: [ 'io' ], + keyEquivalent: '^~I', + name: 'Io', + scopeName: 'source.io' } + + +oop.inherits(IoHighlightRules, TextHighlightRules); + +exports.IoHighlightRules = IoHighlightRules; +}); \ No newline at end of file diff --git a/lib/ace/snippets/io.js b/lib/ace/snippets/io.js new file mode 100644 index 00000000..14bbfcb6 --- /dev/null +++ b/lib/ace/snippets/io.js @@ -0,0 +1,69 @@ +define(function(require, exports, module) { +"use strict"; + +exports.snippets = [ + { + "content": "assertEquals(${1:expected}, ${2:expr})", + "name": "assertEquals", + "scope": "io", + "tabTrigger": "ae" + }, + { + "content": "${1:${2:newValue} := ${3:Object} }clone do(\n\t$0\n)", + "name": "clone do", + "scope": "io", + "tabTrigger": "cdo" + }, + { + "content": "docSlot(\"${1:slotName}\", \"${2:documentation}\")", + "name": "docSlot", + "scope": "io", + "tabTrigger": "ds" + }, + { + "content": "(${1:header,}\n\t${2:body}\n)$0", + "keyEquivalent": "@(", + "name": "Indented Bracketed Line", + "scope": "io", + "tabTrigger": "(" + }, + { + "content": "\n\t$0\n", + "keyEquivalent": "\r", + "name": "Special: Return Inside Empty Parenthesis", + "scope": "io meta.empty-parenthesis.io, io meta.comma-parenthesis.io" + }, + { + "content": "${1:methodName} := method(${2:args,}\n\t$0\n)", + "name": "method", + "scope": "io", + "tabTrigger": "m" + }, + { + "content": "newSlot(\"${1:slotName}\", ${2:defaultValue}, \"${3:docString}\")$0", + "name": "newSlot", + "scope": "io", + "tabTrigger": "ns" + }, + { + "content": "${1:name} := Object clone do(\n\t$0\n)", + "name": "Object clone do", + "scope": "io", + "tabTrigger": "ocdo" + }, + { + "content": "test${1:SomeFeature} := method(\n\t$0\n)", + "name": "testMethod", + "scope": "io", + "tabTrigger": "ts" + }, + { + "content": "${1:Something}Test := ${2:UnitTest} clone do(\n\t$0\n)", + "name": "UnitTest", + "scope": "io", + "tabTrigger": "ut" + } +]; +exports.scope = "io"; + +}); From 9f2fba320d2dcb3f75d3911e9615e630abe63136 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 2 Sep 2014 13:04:33 +0400 Subject: [PATCH 4/6] fix herestring highlighting in sh mode --- lib/ace/mode/sh_highlight_rules.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ace/mode/sh_highlight_rules.js b/lib/ace/mode/sh_highlight_rules.js index 43f536f4..9dd9aa33 100644 --- a/lib/ace/mode/sh_highlight_rules.js +++ b/lib/ace/mode/sh_highlight_rules.js @@ -99,8 +99,12 @@ var ShHighlightRules = function() { }, { defaultToken: "string" }] - }, { + }, { + regex : "<<<", + token : "keyword.operator" + }, { stateName: "heredoc", + regex : "(<<)(\\s*)(['\"`]?)([\\w\\-]+)(['\"`]?)", onMatch : function(value, currentState, stack) { var next = value[2] == '-' ? "indentedHeredoc" : "heredoc"; var tokens = value.split(this.splitRegex); @@ -113,7 +117,6 @@ var ShHighlightRules = function() { {type:"string", value: tokens[5]} ]; }, - regex : "(<<-?)(\\s*)(['\"`]?)([\\w\-]+)(['\"`]?)", rules: { heredoc: [{ onMatch: function(value, currentState, stack) { @@ -131,7 +134,7 @@ var ShHighlightRules = function() { }], indentedHeredoc: [{ token: "string", - regex: "^ +" + regex: "^\t+" }, { onMatch: function(value, currentState, stack) { if (value === stack[1]) { @@ -178,7 +181,7 @@ var ShHighlightRules = function() { regex : integer + "\\b" }, { token : keywordMapper, - regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + regex : "[a-zA-Z_][a-zA-Z0-9_]*\\b" }, { token : "keyword.operator", regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|~|<|>|<=|=>|=|!=" From 30f7f8a3f2264efbe55e46227c0165af7d782a8f Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 2 Sep 2014 13:42:59 +0400 Subject: [PATCH 5/6] add es6 template string highlighting to javascript mode --- lib/ace/edit_session/bracket_match.js | 2 ++ lib/ace/mode/javascript_highlight_rules.js | 35 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/lib/ace/edit_session/bracket_match.js b/lib/ace/edit_session/bracket_match.js index 825f6924..064ee3dc 100644 --- a/lib/ace/edit_session/bracket_match.js +++ b/lib/ace/edit_session/bracket_match.js @@ -117,6 +117,7 @@ function BracketMatch() { typeRe = new RegExp( "(\\.?" + token.type.replace(".", "\\.").replace("rparen", ".paren") + .replace(/\b(?:end|start|begin)\b/, "") + ")+" ); } @@ -173,6 +174,7 @@ function BracketMatch() { typeRe = new RegExp( "(\\.?" + token.type.replace(".", "\\.").replace("lparen", ".paren") + .replace(/\b(?:end|start|begin)\b/, "") + ")+" ); } diff --git a/lib/ace/mode/javascript_highlight_rules.js b/lib/ace/mode/javascript_highlight_rules.js index b5393b13..252a4f3b 100644 --- a/lib/ace/mode/javascript_highlight_rules.js +++ b/lib/ace/mode/javascript_highlight_rules.js @@ -193,6 +193,39 @@ var JavaScriptHighlightRules = function() { token : "punctuation.operator", regex : /\?|\:|\,|\;|\./, next : "start" + }, { + regex: "[{}]", onMatch: function(val, state, stack) { + console.log(val, state, stack) + this.next = ""; + if (val == "{" && stack.length) { + stack.unshift("start", state); + return "paren"; + } + if (val == "}" && stack.length) { + stack.shift(); + this.next = stack.shift(); + if (this.next.indexOf("string") != -1) + return "paren.quasi.end"; + } + return "paren"; + } + }, { + token : "string.quasi.start", + regex : /`/, + push : [{ + token : "constant.language.escape", + regex : escapedRe + }, { + token : "paren.quasi.start", + regex : /\${/, + push : "start" + }, { + token : "string.quasi.end", + regex : /`/, + next : "pop" + }, { + defaultToken: "string.quasi" + }] }, { token : "paren.lparen", regex : /[\[({]/, @@ -357,6 +390,8 @@ var JavaScriptHighlightRules = function() { this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("no_regex") ]); + + this.normalizeRules(); }; oop.inherits(JavaScriptHighlightRules, TextHighlightRules); From 3d6b93b9466c8eb652e37d2b0fb18864299308b4 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 2 Sep 2014 15:12:15 +0400 Subject: [PATCH 6/6] update tests --- lib/ace/mode/_test/tokens_javascript.json | 2 +- lib/ace/mode/javascript_highlight_rules.js | 83 +++++++++++----------- lib/ace/mode/sjs_highlight_rules.js | 6 +- lib/ace/mode/text_highlight_rules.js | 3 +- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/lib/ace/mode/_test/tokens_javascript.json b/lib/ace/mode/_test/tokens_javascript.json index 42e9bf5e..1be3f605 100644 --- a/lib/ace/mode/_test/tokens_javascript.json +++ b/lib/ace/mode/_test/tokens_javascript.json @@ -379,7 +379,7 @@ ["constant.numeric","1."], ["text","00"], ["identifier","E"], - ["text","^"], + ["keyword.operator","^"], ["constant.numeric","1"], ["punctuation.operator",","], ["text"," "], diff --git a/lib/ace/mode/javascript_highlight_rules.js b/lib/ace/mode/javascript_highlight_rules.js index 252a4f3b..e81a2dce 100644 --- a/lib/ace/mode/javascript_highlight_rules.js +++ b/lib/ace/mode/javascript_highlight_rules.js @@ -35,7 +35,7 @@ var oop = require("../lib/oop"); var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; -var JavaScriptHighlightRules = function() { +var JavaScriptHighlightRules = function(options) { // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects var keywordMapper = this.createKeywordMapper({ "variable.language": @@ -187,45 +187,12 @@ var JavaScriptHighlightRules = function() { regex : identifierRe }, { token : "keyword.operator", - regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/, + regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/, next : "start" }, { token : "punctuation.operator", - regex : /\?|\:|\,|\;|\./, + regex : /[?:,;.]/, next : "start" - }, { - regex: "[{}]", onMatch: function(val, state, stack) { - console.log(val, state, stack) - this.next = ""; - if (val == "{" && stack.length) { - stack.unshift("start", state); - return "paren"; - } - if (val == "}" && stack.length) { - stack.shift(); - this.next = stack.shift(); - if (this.next.indexOf("string") != -1) - return "paren.quasi.end"; - } - return "paren"; - } - }, { - token : "string.quasi.start", - regex : /`/, - push : [{ - token : "constant.language.escape", - regex : escapedRe - }, { - token : "paren.quasi.start", - regex : /\${/, - push : "start" - }, { - token : "string.quasi.end", - regex : /`/, - next : "pop" - }, { - defaultToken: "string.quasi" - }] }, { token : "paren.lparen", regex : /[\[({]/, @@ -233,10 +200,6 @@ var JavaScriptHighlightRules = function() { }, { token : "paren.rparen", regex : /[\])}]/ - }, { - token : "keyword.operator", - regex : /\/=?/, - next : "start" }, { token: "comment", regex: /^#!.*$/ @@ -387,7 +350,45 @@ var JavaScriptHighlightRules = function() { } ] }; - + + + if (!options || !options.noES6) { + this.$rules.no_regex.unshift({ + regex: "[{}]", onMatch: function(val, state, stack) { + this.next = val == "{" ? this.nextState : ""; + if (val == "{" && stack.length) { + stack.unshift("start", state); + return "paren"; + } + if (val == "}" && stack.length) { + stack.shift(); + this.next = stack.shift(); + if (this.next.indexOf("string") != -1) + return "paren.quasi.end"; + } + return val == "{" ? "paren.lparen" : "paren.rparen"; + }, + nextState: "start" + }, { + token : "string.quasi.start", + regex : /`/, + push : [{ + token : "constant.language.escape", + regex : escapedRe + }, { + token : "paren.quasi.start", + regex : /\${/, + push : "start" + }, { + token : "string.quasi.end", + regex : /`/, + next : "pop" + }, { + defaultToken: "string.quasi" + }] + }); + } + this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("no_regex") ]); diff --git a/lib/ace/mode/sjs_highlight_rules.js b/lib/ace/mode/sjs_highlight_rules.js index f51787b2..e8ced77b 100644 --- a/lib/ace/mode/sjs_highlight_rules.js +++ b/lib/ace/mode/sjs_highlight_rules.js @@ -36,7 +36,7 @@ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScrip var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var SJSHighlightRules = function() { - var parent = new JavaScriptHighlightRules(); + var parent = new JavaScriptHighlightRules({noES6: true}); var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex "u[0-9a-fA-F]{4}|" + // unicode "[0-2][0-7]{0,2}|" + // oct @@ -177,10 +177,10 @@ var SJSHighlightRules = function() { // for use within interpreted contexts // without interfering with context nesting var embeddableRules = []; - for (var i=0; i