From 01685c255fda6e13f1cd2980130d2e388d52125c Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 4 Jul 2015 11:31:01 +0800 Subject: Updated codemirror to 5.4.0 --- public/vendor/codemirror/mode/groovy/groovy.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'public/vendor/codemirror/mode/groovy') diff --git a/public/vendor/codemirror/mode/groovy/groovy.js b/public/vendor/codemirror/mode/groovy/groovy.js index e3a1db86..721933b0 100755 --- a/public/vendor/codemirror/mode/groovy/groovy.js +++ b/public/vendor/codemirror/mode/groovy/groovy.js @@ -24,6 +24,7 @@ CodeMirror.defineMode("groovy", function(config) { "short static strictfp super switch synchronized threadsafe throw throws transient " + "try void volatile while"); var blockKeywords = words("catch class do else finally for if switch try while enum interface def"); + var standaloneKeywords = words("return break continue"); var atoms = words("null true false this"); var curPunc; @@ -50,7 +51,7 @@ CodeMirror.defineMode("groovy", function(config) { stream.skipToEnd(); return "comment"; } - if (expectExpression(state.lastToken)) { + if (expectExpression(state.lastToken, false)) { return startString(ch, stream, state); } } @@ -70,6 +71,7 @@ CodeMirror.defineMode("groovy", function(config) { if (atoms.propertyIsEnumerable(cur)) { return "atom"; } if (keywords.propertyIsEnumerable(cur)) { if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement"; + else if (standaloneKeywords.propertyIsEnumerable(cur)) curPunc = "standalone"; return "keyword"; } return "variable"; @@ -132,9 +134,10 @@ CodeMirror.defineMode("groovy", function(config) { return "comment"; } - function expectExpression(last) { + function expectExpression(last, newline) { return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) || - last == "newstatement" || last == "keyword" || last == "proplabel"; + last == "newstatement" || last == "keyword" || last == "proplabel" || + (last == "standalone" && !newline); } function Context(indented, column, type, align, prev) { @@ -174,7 +177,7 @@ CodeMirror.defineMode("groovy", function(config) { state.indented = stream.indentation(); state.startOfLine = true; // Automatic semicolon insertion - if (ctx.type == "statement" && !expectExpression(state.lastToken)) { + if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) { popContext(state); ctx = state.context; } } @@ -209,7 +212,7 @@ CodeMirror.defineMode("groovy", function(config) { indent: function(state, textAfter) { if (!state.tokenize[state.tokenize.length-1].isBase) return 0; var firstChar = textAfter && textAfter.charAt(0), ctx = state.context; - if (ctx.type == "statement" && !expectExpression(state.lastToken)) ctx = ctx.prev; + if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) ctx = ctx.prev; var closing = firstChar == ctx.type; if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit); else if (ctx.align) return ctx.column + (closing ? 0 : 1); -- cgit v1.2.3