: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
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
})(function(CodeMirror) {
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b");
"Global", "PrimaryGlobal",
"LegacyUnenumerableNamedProperties",
var builtins = wordRegexp(builtinArray);
"unsigned", "short", "long", // UnsignedIntegerType
"unrestricted", "float", "double", // UnrestrictedFloatType
"boolean", "byte", "octet", // Rest of PrimitiveType
"Promise", // PromiseType
"ArrayBuffer", "DataView", "Int8Array", "Int16Array", "Int32Array",
"Uint8Array", "Uint16Array", "Uint32Array", "Uint8ClampedArray",
"Float32Array", "Float64Array", // BufferRelatedType
"ByteString", "DOMString", "USVString", "sequence", "object", "RegExp",
"Error", "DOMException", "FrozenArray", // Rest of NonAnyType
"any", // Rest of SingleType
"void" // Rest of ReturnType
var types = wordRegexp(typeArray);
"attribute", "callback", "const", "deleter", "dictionary", "enum", "getter",
"implements", "inherit", "interface", "iterable", "legacycaller", "maplike",
"partial", "required", "serializer", "setlike", "setter", "static",
"stringifier", "typedef", // ArgumentNameKeyword except
"optional", "readonly", "or"
var keywords = wordRegexp(keywordArray);
"true", "false", // BooleanLiteral
"Infinity", "NaN", // FloatLiteral
"null" // Rest of ConstValue
var atoms = wordRegexp(atomArray);
CodeMirror.registerHelper("hintWords", "webidl",
builtinArray.concat(typeArray).concat(keywordArray).concat(atomArray));
var startDefArray = ["callback", "dictionary", "enum", "interface"];
var startDefs = wordRegexp(startDefArray);
var endDefArray = ["typedef"];
var endDefs = wordRegexp(endDefArray);
var singleOperators = /^[:<=>?]/;
var integers = /^-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)/;
var floats = /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/;
var identifiers = /^_?[A-Za-z][0-9A-Z_a-z-]*/;
var identifiersEnd = /^_?[A-Za-z][0-9A-Z_a-z-]*(?=\s*;)/;
var strings = /^"[^"]*"/;
var multilineComments = /^\/\*.*?\*\//;
var multilineCommentsStart = /^\/\*.*/;
var multilineCommentsEnd = /^.*?\*\//;
function readToken(stream, state) {
if (stream.eatSpace()) return null;
if (stream.match(multilineCommentsEnd)) {
if (stream.match("//")) {
if (stream.match(multilineComments)) return "comment";
if (stream.match(multilineCommentsStart)) {
if (stream.match(/^-?[0-9\.]/, false)) {
if (stream.match(integers) || stream.match(floats)) return "number";
if (stream.match(strings)) return "string";
if (state.startDef && stream.match(identifiers)) return "def";
if (state.endDef && stream.match(identifiersEnd)) {
if (stream.match(keywords)) return "keyword";
if (stream.match(types)) {
var lastToken = state.lastToken;
var nextToken = (stream.match(/^\s*(.+?)\b/, false) || [])[1];
if (lastToken === ":" || lastToken === "implements" ||
nextToken === "implements" || nextToken === "=") {
if (stream.match(builtins)) return "builtin";
if (stream.match(atoms)) return "atom";
if (stream.match(identifiers)) return "variable";
if (stream.match(singleOperators)) return "operator";
CodeMirror.defineMode("webidl", function() {
// Is in multiline comment
// Last non-whitespace, matched token
// Next token is a definition
// Last token of the statement is a definition
token: function(stream, state) {
var style = readToken(stream, state);
var cur = stream.current();
if (style === "keyword") {
state.startDef = startDefs.test(cur);
state.endDef = state.endDef || endDefs.test(cur);
CodeMirror.defineMIME("text/x-webidl", "webidl");