зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1393825 - Update Codemirror to 5.29.0. r=bgrins
This commit is contained in:
Родитель
324acfa7c1
Коммит
5782fcc756
|
@ -5,7 +5,7 @@ code, and optionally help with indentation.
|
|||
|
||||
# Upgrade
|
||||
|
||||
Currently used version is 5.28.0. To upgrade: download a new version of
|
||||
Currently used version is 5.29.0. To upgrade: download a new version of
|
||||
CodeMirror from the project's page [1] and replace all JavaScript and
|
||||
CSS files inside the codemirror directory [2].
|
||||
|
||||
|
|
|
@ -18,30 +18,28 @@
|
|||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), mode, inserts = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var pos = ranges[i].head, token = cm.getTokenAt(pos);
|
||||
if (token.type != "comment") return CodeMirror.Pass;
|
||||
var modeHere = CodeMirror.innerMode(cm.getMode(), token.state).mode;
|
||||
var pos = ranges[i].head
|
||||
if (!/\bcomment\b/.test(cm.getTokenTypeAt(pos))) return CodeMirror.Pass;
|
||||
var modeHere = cm.getModeAt(pos)
|
||||
if (!mode) mode = modeHere;
|
||||
else if (mode != modeHere) return CodeMirror.Pass;
|
||||
|
||||
var insert = null;
|
||||
if (mode.blockCommentStart && mode.blockCommentContinue) {
|
||||
var end = token.string.indexOf(mode.blockCommentEnd);
|
||||
var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
|
||||
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length && pos.ch >= end) {
|
||||
var line = cm.getLine(pos.line).slice(0, pos.ch)
|
||||
var end = line.indexOf(mode.blockCommentEnd), found
|
||||
if (end != -1 && end == pos.ch - mode.blockCommentEnd.length) {
|
||||
// Comment ended, don't continue it
|
||||
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
|
||||
insert = full.slice(0, token.start);
|
||||
if (!/^\s*$/.test(insert)) {
|
||||
insert = "";
|
||||
for (var j = 0; j < token.start; ++j) insert += " ";
|
||||
} else if ((found = line.indexOf(mode.blockCommentStart)) > -1) {
|
||||
insert = line.slice(0, found)
|
||||
if (/\S/.test(insert)) {
|
||||
insert = ""
|
||||
for (var j = 0; j < found; ++j) insert += " "
|
||||
}
|
||||
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
|
||||
found + mode.blockCommentContinue.length > token.start &&
|
||||
/^\s*$/.test(full.slice(0, found))) {
|
||||
insert = full.slice(0, found);
|
||||
} else if ((found = line.indexOf(mode.blockCommentContinue)) > -1 && !/\S/.test(line.slice(0, found))) {
|
||||
insert = line.slice(0, found)
|
||||
}
|
||||
if (insert != null) insert += mode.blockCommentContinue;
|
||||
if (insert != null) insert += mode.blockCommentContinue
|
||||
}
|
||||
if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) {
|
||||
var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
|
||||
|
|
|
@ -152,8 +152,7 @@
|
|||
};
|
||||
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
|
||||
var keyName = CodeMirror.keyName(event)
|
||||
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
|
||||
if (!cmd) cmd = cm.getOption('extraKeys')[keyName]
|
||||
var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
|
||||
if (cmd == "findNext" || cmd == "findPrev" ||
|
||||
cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
|
||||
CodeMirror.e_stop(event);
|
||||
|
|
|
@ -5405,7 +5405,7 @@ var CodeMirror =
|
|||
var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to)
|
||||
if (split) {
|
||||
for (var i = split.length - 1; i >= 0; --i)
|
||||
{ makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}) }
|
||||
{ makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}) }
|
||||
} else {
|
||||
makeChangeInner(doc, change)
|
||||
}
|
||||
|
@ -9130,7 +9130,7 @@ var CodeMirror =
|
|||
var markerID = node.getAttribute("cm-marker"), range
|
||||
if (markerID) {
|
||||
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))
|
||||
if (found.length && (range = found[0].find()))
|
||||
if (found.length && (range = found[0].find(0)))
|
||||
{ addText(getBetween(cm.doc, range.from, range.to).join(lineSep)) }
|
||||
return
|
||||
}
|
||||
|
@ -9714,7 +9714,7 @@ var CodeMirror =
|
|||
|
||||
addLegacyProps(CodeMirror)
|
||||
|
||||
CodeMirror.version = "5.28.0"
|
||||
CodeMirror.version = "5.29.0"
|
||||
|
||||
return CodeMirror;
|
||||
|
||||
|
@ -10173,8 +10173,7 @@ var CodeMirror =
|
|||
};
|
||||
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
|
||||
var keyName = CodeMirror.keyName(event)
|
||||
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
|
||||
if (!cmd) cmd = cm.getOption('extraKeys')[keyName]
|
||||
var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
|
||||
if (cmd == "findNext" || cmd == "findPrev" ||
|
||||
cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
|
||||
CodeMirror.e_stop(event);
|
||||
|
@ -10878,11 +10877,6 @@ var CodeMirror =
|
|||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function expressionAllowed(stream, state, backUp) {
|
||||
return /^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
||||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
||||
}
|
||||
|
||||
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var statementIndent = parserConfig.statementIndent;
|
||||
|
@ -10927,6 +10921,7 @@ var CodeMirror =
|
|||
"private": kw("modifier"),
|
||||
"protected": kw("modifier"),
|
||||
"abstract": kw("modifier"),
|
||||
"readonly": kw("modifier"),
|
||||
|
||||
// types
|
||||
"string": type, "number": type, "boolean": type, "any": type
|
||||
|
@ -11235,6 +11230,9 @@ var CodeMirror =
|
|||
if (isTS && value == "type") {
|
||||
cx.marked = "keyword"
|
||||
return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
||||
} if (isTS && value == "declare") {
|
||||
cx.marked = "keyword"
|
||||
return cont(statement)
|
||||
} else {
|
||||
return cont(pushlex("stat"), maybelabel);
|
||||
}
|
||||
|
@ -11301,7 +11299,7 @@ var CodeMirror =
|
|||
var expr = noComma == false ? expression : expressionNoComma;
|
||||
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
||||
if (type == "operator") {
|
||||
if (/\+\+|--/.test(value)) return cont(me);
|
||||
if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
|
||||
if (value == "?") return cont(expression, expect(":"), expr);
|
||||
return cont(expr);
|
||||
}
|
||||
|
@ -11335,6 +11333,7 @@ var CodeMirror =
|
|||
function maybeTarget(noComma) {
|
||||
return function(type) {
|
||||
if (type == ".") return cont(noComma ? targetNoComma : target);
|
||||
else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
|
||||
else return pass(noComma ? expressionNoComma : expression);
|
||||
};
|
||||
}
|
||||
|
@ -11416,9 +11415,18 @@ var CodeMirror =
|
|||
if (value == "?") return cont(maybetype);
|
||||
}
|
||||
}
|
||||
function typeexpr(type) {
|
||||
if (type == "variable") {cx.marked = "type"; return cont(afterType);}
|
||||
function typeexpr(type, value) {
|
||||
if (type == "variable") {
|
||||
if (value == "keyof") {
|
||||
cx.marked = "keyword"
|
||||
return cont(typeexpr)
|
||||
} else {
|
||||
cx.marked = "type"
|
||||
return cont(afterType)
|
||||
}
|
||||
}
|
||||
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
|
||||
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
|
||||
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
|
||||
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
||||
}
|
||||
|
@ -11447,6 +11455,9 @@ var CodeMirror =
|
|||
if (type == "[") return cont(expect("]"), afterType)
|
||||
if (value == "extends") return cont(typeexpr)
|
||||
}
|
||||
function maybeTypeArgs(_, value) {
|
||||
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
||||
}
|
||||
function vardef() {
|
||||
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
||||
}
|
||||
|
@ -11504,7 +11515,7 @@ var CodeMirror =
|
|||
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, functiondef)
|
||||
}
|
||||
function funarg(type) {
|
||||
if (type == "spread") return cont(funarg);
|
||||
if (type == "spread" || type == "modifier") return cont(funarg);
|
||||
return pass(pattern, maybetype, maybeAssign);
|
||||
}
|
||||
function classExpression(type, value) {
|
||||
|
@ -11522,13 +11533,14 @@ var CodeMirror =
|
|||
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
||||
}
|
||||
function classBody(type, value) {
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
if ((value == "async" || value == "static" || value == "get" || value == "set" ||
|
||||
(isTS && (value == "public" || value == "private" || value == "protected" || value == "readonly" || value == "abstract"))) &&
|
||||
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
|
||||
cx.marked = "keyword";
|
||||
return cont(classBody);
|
||||
}
|
||||
if (type == "modifier" || type == "async" ||
|
||||
(type == "variable" &&
|
||||
(value == "static" || value == "get" || value == "set") &&
|
||||
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
|
||||
cx.marked = "keyword";
|
||||
return cont(classBody);
|
||||
}
|
||||
if (type == "variable") {
|
||||
cx.marked = "property";
|
||||
return cont(isTS ? classfield : functiondef, classBody);
|
||||
}
|
||||
|
@ -11588,6 +11600,12 @@ var CodeMirror =
|
|||
/[,.]/.test(textAfter.charAt(0));
|
||||
}
|
||||
|
||||
function expressionAllowed(stream, state, backUp) {
|
||||
return state.tokenize == tokenBase &&
|
||||
/^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
||||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
|
@ -11662,6 +11680,7 @@ var CodeMirror =
|
|||
jsonMode: jsonMode,
|
||||
|
||||
expressionAllowed: expressionAllowed,
|
||||
|
||||
skipExpression: function(state) {
|
||||
var top = state.cc[state.cc.length - 1]
|
||||
if (top == expression || top == expressionNoComma) state.cc.pop()
|
||||
|
@ -12474,7 +12493,8 @@ var CodeMirror =
|
|||
style = style[0];
|
||||
}
|
||||
override = style;
|
||||
state.state = states[state.state](type, stream, state);
|
||||
if (type != "comment")
|
||||
state.state = states[state.state](type, stream, state);
|
||||
return override;
|
||||
},
|
||||
|
||||
|
@ -13588,6 +13608,10 @@ var CodeMirror =
|
|||
return external;
|
||||
});
|
||||
|
||||
// IANA registered media type
|
||||
// https://www.iana.org/assignments/media-types/
|
||||
CodeMirror.defineMIME("application/vnd.coffeescript", "coffeescript");
|
||||
|
||||
CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
|
||||
CodeMirror.defineMIME("text/coffeescript", "coffeescript");
|
||||
|
||||
|
@ -15295,7 +15319,7 @@ var CodeMirror =
|
|||
"Ctrl-/": repeated("undo"), "Shift-Ctrl--": repeated("undo"),
|
||||
"Ctrl-Z": repeated("undo"), "Cmd-Z": repeated("undo"),
|
||||
"Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd",
|
||||
"Ctrl-S": "findNext", "Ctrl-R": "findPrev", "Ctrl-G": quit, "Shift-Alt-5": "replace",
|
||||
"Ctrl-S": "findPersistentNext", "Ctrl-R": "findPersistentPrev", "Ctrl-G": quit, "Shift-Alt-5": "replace",
|
||||
"Alt-/": "autocomplete",
|
||||
"Enter": "newlineAndIndent",
|
||||
"Ctrl-J": repeated(function(cm) { cm.replaceSelection("\n", "end"); }),
|
||||
|
|
|
@ -369,7 +369,7 @@
|
|||
"Ctrl-/": repeated("undo"), "Shift-Ctrl--": repeated("undo"),
|
||||
"Ctrl-Z": repeated("undo"), "Cmd-Z": repeated("undo"),
|
||||
"Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd",
|
||||
"Ctrl-S": "findNext", "Ctrl-R": "findPrev", "Ctrl-G": quit, "Shift-Alt-5": "replace",
|
||||
"Ctrl-S": "findPersistentNext", "Ctrl-R": "findPersistentPrev", "Ctrl-G": quit, "Shift-Alt-5": "replace",
|
||||
"Alt-/": "autocomplete",
|
||||
"Enter": "newlineAndIndent",
|
||||
"Ctrl-J": repeated(function(cm) { cm.replaceSelection("\n", "end"); }),
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
font-family: monospace;
|
||||
height: 300px;
|
||||
color: black;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
/* PADDING */
|
||||
|
@ -319,8 +320,8 @@ div.CodeMirror-dragcursors {
|
|||
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
||||
|
||||
.cm-searching {
|
||||
background: #ffa;
|
||||
background: rgba(255, 255, 0, .4);
|
||||
background-color: #ffa;
|
||||
background-color: rgba(255, 255, 0, .4);
|
||||
}
|
||||
|
||||
/* Used to force a border model for a node */
|
||||
|
|
|
@ -5163,7 +5163,7 @@ function makeChange(doc, change, ignoreReadOnly) {
|
|||
var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to)
|
||||
if (split) {
|
||||
for (var i = split.length - 1; i >= 0; --i)
|
||||
{ makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}) }
|
||||
{ makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}) }
|
||||
} else {
|
||||
makeChangeInner(doc, change)
|
||||
}
|
||||
|
@ -8888,7 +8888,7 @@ function domTextBetween(cm, from, to, fromLine, toLine) {
|
|||
var markerID = node.getAttribute("cm-marker"), range
|
||||
if (markerID) {
|
||||
var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))
|
||||
if (found.length && (range = found[0].find()))
|
||||
if (found.length && (range = found[0].find(0)))
|
||||
{ addText(getBetween(cm.doc, range.from, range.to).join(lineSep)) }
|
||||
return
|
||||
}
|
||||
|
@ -9472,7 +9472,7 @@ CodeMirror.fromTextArea = fromTextArea
|
|||
|
||||
addLegacyProps(CodeMirror)
|
||||
|
||||
CodeMirror.version = "5.28.0"
|
||||
CodeMirror.version = "5.29.0"
|
||||
|
||||
return CodeMirror;
|
||||
|
||||
|
|
|
@ -349,6 +349,10 @@ CodeMirror.defineMode("coffeescript", function(conf, parserConf) {
|
|||
return external;
|
||||
});
|
||||
|
||||
// IANA registered media type
|
||||
// https://www.iana.org/assignments/media-types/
|
||||
CodeMirror.defineMIME("application/vnd.coffeescript", "coffeescript");
|
||||
|
||||
CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
|
||||
CodeMirror.defineMIME("text/coffeescript", "coffeescript");
|
||||
|
||||
|
|
|
@ -383,7 +383,8 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
|
|||
style = style[0];
|
||||
}
|
||||
override = style;
|
||||
state.state = states[state.state](type, stream, state);
|
||||
if (type != "comment")
|
||||
state.state = states[state.state](type, stream, state);
|
||||
return override;
|
||||
},
|
||||
|
||||
|
|
|
@ -11,11 +11,6 @@
|
|||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function expressionAllowed(stream, state, backUp) {
|
||||
return /^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
||||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
||||
}
|
||||
|
||||
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var statementIndent = parserConfig.statementIndent;
|
||||
|
@ -60,6 +55,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
"private": kw("modifier"),
|
||||
"protected": kw("modifier"),
|
||||
"abstract": kw("modifier"),
|
||||
"readonly": kw("modifier"),
|
||||
|
||||
// types
|
||||
"string": type, "number": type, "boolean": type, "any": type
|
||||
|
@ -368,6 +364,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (isTS && value == "type") {
|
||||
cx.marked = "keyword"
|
||||
return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
||||
} if (isTS && value == "declare") {
|
||||
cx.marked = "keyword"
|
||||
return cont(statement)
|
||||
} else {
|
||||
return cont(pushlex("stat"), maybelabel);
|
||||
}
|
||||
|
@ -434,7 +433,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
var expr = noComma == false ? expression : expressionNoComma;
|
||||
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
||||
if (type == "operator") {
|
||||
if (/\+\+|--/.test(value)) return cont(me);
|
||||
if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
|
||||
if (value == "?") return cont(expression, expect(":"), expr);
|
||||
return cont(expr);
|
||||
}
|
||||
|
@ -468,6 +467,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
function maybeTarget(noComma) {
|
||||
return function(type) {
|
||||
if (type == ".") return cont(noComma ? targetNoComma : target);
|
||||
else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
|
||||
else return pass(noComma ? expressionNoComma : expression);
|
||||
};
|
||||
}
|
||||
|
@ -549,9 +549,18 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (value == "?") return cont(maybetype);
|
||||
}
|
||||
}
|
||||
function typeexpr(type) {
|
||||
if (type == "variable") {cx.marked = "type"; return cont(afterType);}
|
||||
function typeexpr(type, value) {
|
||||
if (type == "variable") {
|
||||
if (value == "keyof") {
|
||||
cx.marked = "keyword"
|
||||
return cont(typeexpr)
|
||||
} else {
|
||||
cx.marked = "type"
|
||||
return cont(afterType)
|
||||
}
|
||||
}
|
||||
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
|
||||
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
|
||||
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
|
||||
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
||||
}
|
||||
|
@ -580,6 +589,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (type == "[") return cont(expect("]"), afterType)
|
||||
if (value == "extends") return cont(typeexpr)
|
||||
}
|
||||
function maybeTypeArgs(_, value) {
|
||||
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
||||
}
|
||||
function vardef() {
|
||||
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
||||
}
|
||||
|
@ -637,7 +649,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, functiondef)
|
||||
}
|
||||
function funarg(type) {
|
||||
if (type == "spread") return cont(funarg);
|
||||
if (type == "spread" || type == "modifier") return cont(funarg);
|
||||
return pass(pattern, maybetype, maybeAssign);
|
||||
}
|
||||
function classExpression(type, value) {
|
||||
|
@ -655,13 +667,14 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
||||
}
|
||||
function classBody(type, value) {
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
if ((value == "async" || value == "static" || value == "get" || value == "set" ||
|
||||
(isTS && (value == "public" || value == "private" || value == "protected" || value == "readonly" || value == "abstract"))) &&
|
||||
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
|
||||
cx.marked = "keyword";
|
||||
return cont(classBody);
|
||||
}
|
||||
if (type == "modifier" || type == "async" ||
|
||||
(type == "variable" &&
|
||||
(value == "static" || value == "get" || value == "set") &&
|
||||
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
|
||||
cx.marked = "keyword";
|
||||
return cont(classBody);
|
||||
}
|
||||
if (type == "variable") {
|
||||
cx.marked = "property";
|
||||
return cont(isTS ? classfield : functiondef, classBody);
|
||||
}
|
||||
|
@ -721,6 +734,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
/[,.]/.test(textAfter.charAt(0));
|
||||
}
|
||||
|
||||
function expressionAllowed(stream, state, backUp) {
|
||||
return state.tokenize == tokenBase &&
|
||||
/^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
||||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
|
@ -795,6 +814,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
|||
jsonMode: jsonMode,
|
||||
|
||||
expressionAllowed: expressionAllowed,
|
||||
|
||||
skipExpression: function(state) {
|
||||
var top = state.cc[state.cc.length - 1]
|
||||
if (top == expression || top == expressionNoComma) state.cc.pop()
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
"scripts": {
|
||||
"build": "webpack"
|
||||
},
|
||||
"babel": {
|
||||
"presets": [ "es2015" ]
|
||||
"babel": {
|
||||
"presets": [
|
||||
"es2015"
|
||||
]
|
||||
},
|
||||
"author": "",
|
||||
"license": "",
|
||||
|
|
|
@ -339,6 +339,19 @@
|
|||
TS("typescript_complex_type_casting",
|
||||
"[keyword const] [def giftpay] [operator =] [variable config].[property get]([string 'giftpay']) [keyword as] { [[ [variable platformUuid]: [type string] ]]: { [property version]: [type number]; [property apiCode]: [type string]; } };")
|
||||
|
||||
TS("typescript_keyof",
|
||||
"[keyword function] [def x][operator <][type T] [keyword extends] [keyword keyof] [type X][operator >]([def a]: [type T]) {",
|
||||
" [keyword return]")
|
||||
|
||||
TS("typescript_new_typeargs",
|
||||
"[keyword let] [def x] [operator =] [keyword new] [variable Map][operator <][type string], [type Date][operator >]([string-2 `foo${][variable bar][string-2 }`])")
|
||||
|
||||
TS("modifiers",
|
||||
"[keyword class] [def Foo] {",
|
||||
" [keyword public] [keyword abstract] [property bar]() {}",
|
||||
" [property constructor]([keyword readonly] [keyword private] [def x]) {}",
|
||||
"}")
|
||||
|
||||
var jsonld_mode = CodeMirror.getMode(
|
||||
{indentUnit: 2},
|
||||
{name: "javascript", jsonld: true}
|
||||
|
|
|
@ -128,7 +128,9 @@
|
|||
(st.indentFailures || (st.indentFailures = [])).push(
|
||||
"Indentation of line " + (i + 1) + " is " + indent + " (expected " + ws.length + ")");
|
||||
}
|
||||
var stream = new CodeMirror.StringStream(line);
|
||||
var stream = new CodeMirror.StringStream(line, 4, {
|
||||
lookAhead: function(n) { return lines[i + n] }
|
||||
});
|
||||
if (line == "" && mode.blankLine) mode.blankLine(state);
|
||||
/* Start copied code from CodeMirror.highlight */
|
||||
while (!stream.eol()) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче