mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-22 11:15:23 -04:00
Updated codemirror to 5.4.0
This commit is contained in:
parent
1d843c8ac2
commit
01685c255f
69 changed files with 2988 additions and 558 deletions
13
public/vendor/codemirror/mode/groovy/groovy.js
vendored
13
public/vendor/codemirror/mode/groovy/groovy.js
vendored
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue