Updated codemirror to v4.12.
Did a lot of cleanup to limit the size of the plugin. I kept the emmet plugin.
This commit is contained in:
+34
-5
@@ -1,3 +1,16 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("sparql", function(config) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var curPunc;
|
||||
@@ -6,18 +19,28 @@ CodeMirror.defineMode("sparql", function(config) {
|
||||
return new RegExp("^(?:" + words.join("|") + ")$", "i");
|
||||
}
|
||||
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
|
||||
"iri", "uri", "bnode", "count", "sum", "min", "max", "avg", "sample",
|
||||
"group_concat", "rand", "abs", "ceil", "floor", "round", "concat", "substr", "strlen",
|
||||
"replace", "ucase", "lcase", "encode_for_uri", "contains", "strstarts", "strends",
|
||||
"strbefore", "strafter", "year", "month", "day", "hours", "minutes", "seconds",
|
||||
"timezone", "tz", "now", "uuid", "struuid", "md5", "sha1", "sha256", "sha384",
|
||||
"sha512", "coalesce", "if", "strlang", "strdt", "isnumeric", "regex", "exists",
|
||||
"isblank", "isliteral", "a"]);
|
||||
var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
|
||||
"ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",
|
||||
"graph", "by", "asc", "desc", "as", "having", "undef", "values", "group",
|
||||
"minus", "in", "not", "service", "silent", "using", "insert", "delete", "union",
|
||||
"true", "false", "with",
|
||||
"data", "copy", "to", "move", "add", "create", "drop", "clear", "load"]);
|
||||
var operatorChars = /[*+\-<>=&|]/;
|
||||
var operatorChars = /[*+\-<>=&|\^\/!\?]/;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
curPunc = null;
|
||||
if (ch == "$" || ch == "?") {
|
||||
if(ch == "?" && stream.match(/\s/, false)){
|
||||
return "operator";
|
||||
}
|
||||
stream.match(/^[\w\d]*/);
|
||||
return "variable-2";
|
||||
}
|
||||
@@ -31,7 +54,7 @@ CodeMirror.defineMode("sparql", function(config) {
|
||||
}
|
||||
else if (/[{}\(\),\.;\[\]]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
return "bracket";
|
||||
}
|
||||
else if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
@@ -39,12 +62,16 @@ CodeMirror.defineMode("sparql", function(config) {
|
||||
}
|
||||
else if (operatorChars.test(ch)) {
|
||||
stream.eatWhile(operatorChars);
|
||||
return null;
|
||||
return "operator";
|
||||
}
|
||||
else if (ch == ":") {
|
||||
stream.eatWhile(/[\w\d\._\-]/);
|
||||
return "atom";
|
||||
}
|
||||
else if (ch == "@") {
|
||||
stream.eatWhile(/[a-z\d\-]/i);
|
||||
return "meta";
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(/[_\w\d]/);
|
||||
if (stream.eat(":")) {
|
||||
@@ -53,7 +80,7 @@ CodeMirror.defineMode("sparql", function(config) {
|
||||
}
|
||||
var word = stream.current();
|
||||
if (ops.test(word))
|
||||
return null;
|
||||
return "builtin";
|
||||
else if (keywords.test(word))
|
||||
return "keyword";
|
||||
else
|
||||
@@ -142,4 +169,6 @@ CodeMirror.defineMode("sparql", function(config) {
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("application/x-sparql-query", "sparql");
|
||||
CodeMirror.defineMIME("application/sparql-query", "sparql");
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user