Updated codemirror to 5.4.0

This commit is contained in:
Wu Cheng-Han 2015-07-04 11:31:01 +08:00
parent 1d843c8ac2
commit 01685c255f
69 changed files with 2988 additions and 558 deletions

View file

@ -68,15 +68,6 @@ CodeMirror.defineMode("xquery", function() {
return kwObj;
}();
// Used as scratch variables to communicate multiple values without
// consing up tons of objects.
var type, content;
function ret(tp, style, cont) {
type = tp; content = cont;
return style;
}
function chain(stream, state, f) {
state.tokenize = f;
return f(stream, state);
@ -95,7 +86,7 @@ CodeMirror.defineMode("xquery", function() {
if(stream.match("![CDATA", false)) {
state.tokenize = tokenCDATA;
return ret("tag", "tag");
return "tag";
}
if(stream.match("?", false)) {
@ -112,28 +103,28 @@ CodeMirror.defineMode("xquery", function() {
// start code block
else if(ch == "{") {
pushStateStack(state,{ type: "codeblock"});
return ret("", null);
return null;
}
// end code block
else if(ch == "}") {
popStateStack(state);
return ret("", null);
return null;
}
// if we're in an XML block
else if(isInXmlBlock(state)) {
if(ch == ">")
return ret("tag", "tag");
return "tag";
else if(ch == "/" && stream.eat(">")) {
popStateStack(state);
return ret("tag", "tag");
return "tag";
}
else
return ret("word", "variable");
return "variable";
}
// if a number
else if (/\d/.test(ch)) {
stream.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/);
return ret("number", "atom");
return "atom";
}
// comment start
else if (ch === "(" && stream.eat(":")) {
@ -149,27 +140,27 @@ CodeMirror.defineMode("xquery", function() {
}
// assignment
else if(ch ===":" && stream.eat("=")) {
return ret("operator", "keyword");
return "keyword";
}
// open paren
else if(ch === "(") {
pushStateStack(state, { type: "paren"});
return ret("", null);
return null;
}
// close paren
else if(ch === ")") {
popStateStack(state);
return ret("", null);
return null;
}
// open paren
else if(ch === "[") {
pushStateStack(state, { type: "bracket"});
return ret("", null);
return null;
}
// close paren
else if(ch === "]") {
popStateStack(state);
return ret("", null);
return null;
}
else {
var known = keywords.propertyIsEnumerable(ch) && keywords[ch];
@ -204,15 +195,14 @@ CodeMirror.defineMode("xquery", function() {
// if the previous word was element, attribute, axis specifier, this word should be the name of that
if(isInXmlConstructor(state)) {
popStateStack(state);
return ret("word", "variable", word);
return "variable";
}
// as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
// push the stack so we know to look for it on the next word
if(word == "element" || word == "attribute" || known.type == "axis_specifier") pushStateStack(state, {type: "xmlconstructor"});
// if the word is known, return the details of that else just call this a generic 'word'
return known ? ret(known.type, known.style, word) :
ret("word", "variable", word);
return known ? known.style : "variable";
}
}
@ -235,7 +225,7 @@ CodeMirror.defineMode("xquery", function() {
maybeNested = (ch == "(");
}
return ret("comment", "comment");
return "comment";
}
// tokenizer for string literals
@ -247,7 +237,7 @@ CodeMirror.defineMode("xquery", function() {
if(isInString(state) && stream.current() == quote) {
popStateStack(state);
if(f) state.tokenize = f;
return ret("string", "string");
return "string";
}
pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });
@ -255,7 +245,7 @@ CodeMirror.defineMode("xquery", function() {
// if we're in a string and in an XML block, allow an embedded code block
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
state.tokenize = tokenBase;
return ret("string", "string");
return "string";
}
@ -269,13 +259,13 @@ CodeMirror.defineMode("xquery", function() {
// if we're in a string and in an XML block, allow an embedded code block in an attribute
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
state.tokenize = tokenBase;
return ret("string", "string");
return "string";
}
}
}
return ret("string", "string");
return "string";
};
}
@ -293,7 +283,7 @@ CodeMirror.defineMode("xquery", function() {
}
stream.eatWhile(isVariableChar);
state.tokenize = tokenBase;
return ret("variable", "variable");
return "variable";
}
// tokenizer for XML tags
@ -303,19 +293,19 @@ CodeMirror.defineMode("xquery", function() {
if(isclose && stream.eat(">")) {
popStateStack(state);
state.tokenize = tokenBase;
return ret("tag", "tag");
return "tag";
}
// self closing tag without attributes?
if(!stream.eat("/"))
pushStateStack(state, { type: "tag", name: name, tokenize: tokenBase});
if(!stream.eat(">")) {
state.tokenize = tokenAttribute;
return ret("tag", "tag");
return "tag";
}
else {
state.tokenize = tokenBase;
}
return ret("tag", "tag");
return "tag";
};
}
@ -326,14 +316,14 @@ CodeMirror.defineMode("xquery", function() {
if(ch == "/" && stream.eat(">")) {
if(isInXmlAttributeBlock(state)) popStateStack(state);
if(isInXmlBlock(state)) popStateStack(state);
return ret("tag", "tag");
return "tag";
}
if(ch == ">") {
if(isInXmlAttributeBlock(state)) popStateStack(state);
return ret("tag", "tag");
return "tag";
}
if(ch == "=")
return ret("", null);
return null;
// quoted string
if (ch == '"' || ch == "'")
return chain(stream, state, tokenString(ch, tokenAttribute));
@ -351,7 +341,7 @@ CodeMirror.defineMode("xquery", function() {
state.tokenize = tokenBase;
}
return ret("attribute", "attribute");
return "attribute";
}
// handle comments, including nested
@ -360,7 +350,7 @@ CodeMirror.defineMode("xquery", function() {
while (ch = stream.next()) {
if (ch == "-" && stream.match("->", true)) {
state.tokenize = tokenBase;
return ret("comment", "comment");
return "comment";
}
}
}
@ -372,7 +362,7 @@ CodeMirror.defineMode("xquery", function() {
while (ch = stream.next()) {
if (ch == "]" && stream.match("]", true)) {
state.tokenize = tokenBase;
return ret("comment", "comment");
return "comment";
}
}
}
@ -383,7 +373,7 @@ CodeMirror.defineMode("xquery", function() {
while (ch = stream.next()) {
if (ch == "?" && stream.match(">", true)) {
state.tokenize = tokenBase;
return ret("comment", "comment meta");
return "comment meta";
}
}
}