vendor/assets/javascripts/codemirror/modes/xquery.js in codemirror-rails-5.2 vs vendor/assets/javascripts/codemirror/modes/xquery.js in codemirror-rails-5.3

- old
+ new

@@ -66,19 +66,10 @@ for(var i=0, l=axis_specifiers.length; i < l; i++) { kwObj[axis_specifiers[i]] = qualifier; }; 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); } @@ -93,11 +84,11 @@ if(stream.match("!--", true)) return chain(stream, state, tokenXMLComment); if(stream.match("![CDATA", false)) { state.tokenize = tokenCDATA; - return ret("tag", "tag"); + return "tag"; } if(stream.match("?", false)) { return chain(stream, state, tokenPreProcessing); } @@ -110,32 +101,32 @@ return chain(stream, state, tokenTag(tagName, isclose)); } // 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(":")) { pushStateStack(state, { type: "comment"}); return chain(stream, state, tokenComment); @@ -147,31 +138,31 @@ else if(ch === "$") { return chain(stream, state, tokenVariable); } // 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]; // if there's a EQName ahead, consume the rest of the string portion, it's likely a function @@ -202,19 +193,18 @@ if(mightBeFunction && !known) known = {type: "function_call", style: "variable def"}; // 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"; } } // handle comments, including nested function tokenComment(stream, state) { @@ -233,11 +223,11 @@ } maybeEnd = (ch == ":"); maybeNested = (ch == "("); } - return ret("comment", "comment"); + return "comment"; } // tokenizer for string literals // optionally pass a tokenizer function to set state.tokenize back to when finished function tokenString(quote, f) { @@ -245,19 +235,19 @@ var ch; 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) }); // 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"; } while (ch = stream.next()) { if (ch == quote) { @@ -267,17 +257,17 @@ } else { // 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"; }; } // tokenizer for variables function tokenVariable(stream, state) { @@ -291,51 +281,51 @@ stream.eatWhile(isVariableChar); if(!stream.match(":=", false)) stream.eat(":"); } stream.eatWhile(isVariableChar); state.tokenize = tokenBase; - return ret("variable", "variable"); + return "variable"; } // tokenizer for XML tags function tokenTag(name, isclose) { return function(stream, state) { stream.eatSpace(); 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"; }; } // tokenizer for XML attributes function tokenAttribute(stream, state) { var ch = stream.next(); 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)); if(!isInXmlAttributeBlock(state)) @@ -349,20 +339,20 @@ if(stream.match(">", false) || stream.match("/", false)) { popStateStack(state); state.tokenize = tokenBase; } - return ret("attribute", "attribute"); + return "attribute"; } // handle comments, including nested function tokenXMLComment(stream, state) { var ch; while (ch = stream.next()) { if (ch == "-" && stream.match("->", true)) { state.tokenize = tokenBase; - return ret("comment", "comment"); + return "comment"; } } } @@ -370,21 +360,21 @@ function tokenCDATA(stream, state) { var ch; while (ch = stream.next()) { if (ch == "]" && stream.match("]", true)) { state.tokenize = tokenBase; - return ret("comment", "comment"); + return "comment"; } } } // handle preprocessing instructions function tokenPreProcessing(stream, state) { var ch; while (ch = stream.next()) { if (ch == "?" && stream.match(">", true)) { state.tokenize = tokenBase; - return ret("comment", "comment meta"); + return "comment meta"; } } }