Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/dart
File: dart.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others
[0] Fix | Delete
// Distributed under an MIT license: http://codemirror.net/LICENSE
[1] Fix | Delete
[2] Fix | Delete
(function(mod) {
[3] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[4] Fix | Delete
mod(require("../../lib/codemirror"), require("../clike/clike"));
[5] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[6] Fix | Delete
define(["../../lib/codemirror", "../clike/clike"], mod);
[7] Fix | Delete
else // Plain browser env
[8] Fix | Delete
mod(CodeMirror);
[9] Fix | Delete
})(function(CodeMirror) {
[10] Fix | Delete
"use strict";
[11] Fix | Delete
[12] Fix | Delete
var keywords = ("this super static final const abstract class extends external factory " +
[13] Fix | Delete
"implements get native operator set typedef with enum throw rethrow " +
[14] Fix | Delete
"assert break case continue default in return new deferred async await " +
[15] Fix | Delete
"try catch finally do else for if switch while import library export " +
[16] Fix | Delete
"part of show hide is as").split(" ");
[17] Fix | Delete
var blockKeywords = "try catch finally do else for if switch while".split(" ");
[18] Fix | Delete
var atoms = "true false null".split(" ");
[19] Fix | Delete
var builtins = "void bool num int double dynamic var String".split(" ");
[20] Fix | Delete
[21] Fix | Delete
function set(words) {
[22] Fix | Delete
var obj = {};
[23] Fix | Delete
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
[24] Fix | Delete
return obj;
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
function pushInterpolationStack(state) {
[28] Fix | Delete
(state.interpolationStack || (state.interpolationStack = [])).push(state.tokenize);
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
function popInterpolationStack(state) {
[32] Fix | Delete
return (state.interpolationStack || (state.interpolationStack = [])).pop();
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
function sizeInterpolationStack(state) {
[36] Fix | Delete
return state.interpolationStack ? state.interpolationStack.length : 0;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
CodeMirror.defineMIME("application/dart", {
[40] Fix | Delete
name: "clike",
[41] Fix | Delete
keywords: set(keywords),
[42] Fix | Delete
blockKeywords: set(blockKeywords),
[43] Fix | Delete
builtin: set(builtins),
[44] Fix | Delete
atoms: set(atoms),
[45] Fix | Delete
hooks: {
[46] Fix | Delete
"@": function(stream) {
[47] Fix | Delete
stream.eatWhile(/[\w\$_\.]/);
[48] Fix | Delete
return "meta";
[49] Fix | Delete
},
[50] Fix | Delete
[51] Fix | Delete
// custom string handling to deal with triple-quoted strings and string interpolation
[52] Fix | Delete
"'": function(stream, state) {
[53] Fix | Delete
return tokenString("'", stream, state, false);
[54] Fix | Delete
},
[55] Fix | Delete
"\"": function(stream, state) {
[56] Fix | Delete
return tokenString("\"", stream, state, false);
[57] Fix | Delete
},
[58] Fix | Delete
"r": function(stream, state) {
[59] Fix | Delete
var peek = stream.peek();
[60] Fix | Delete
if (peek == "'" || peek == "\"") {
[61] Fix | Delete
return tokenString(stream.next(), stream, state, true);
[62] Fix | Delete
}
[63] Fix | Delete
return false;
[64] Fix | Delete
},
[65] Fix | Delete
[66] Fix | Delete
"}": function(_stream, state) {
[67] Fix | Delete
// "}" is end of interpolation, if interpolation stack is non-empty
[68] Fix | Delete
if (sizeInterpolationStack(state) > 0) {
[69] Fix | Delete
state.tokenize = popInterpolationStack(state);
[70] Fix | Delete
return null;
[71] Fix | Delete
}
[72] Fix | Delete
return false;
[73] Fix | Delete
},
[74] Fix | Delete
[75] Fix | Delete
"/": function(stream, state) {
[76] Fix | Delete
if (!stream.eat("*")) return false
[77] Fix | Delete
state.tokenize = tokenNestedComment(1)
[78] Fix | Delete
return state.tokenize(stream, state)
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
});
[82] Fix | Delete
[83] Fix | Delete
function tokenString(quote, stream, state, raw) {
[84] Fix | Delete
var tripleQuoted = false;
[85] Fix | Delete
if (stream.eat(quote)) {
[86] Fix | Delete
if (stream.eat(quote)) tripleQuoted = true;
[87] Fix | Delete
else return "string"; //empty string
[88] Fix | Delete
}
[89] Fix | Delete
function tokenStringHelper(stream, state) {
[90] Fix | Delete
var escaped = false;
[91] Fix | Delete
while (!stream.eol()) {
[92] Fix | Delete
if (!raw && !escaped && stream.peek() == "$") {
[93] Fix | Delete
pushInterpolationStack(state);
[94] Fix | Delete
state.tokenize = tokenInterpolation;
[95] Fix | Delete
return "string";
[96] Fix | Delete
}
[97] Fix | Delete
var next = stream.next();
[98] Fix | Delete
if (next == quote && !escaped && (!tripleQuoted || stream.match(quote + quote))) {
[99] Fix | Delete
state.tokenize = null;
[100] Fix | Delete
break;
[101] Fix | Delete
}
[102] Fix | Delete
escaped = !raw && !escaped && next == "\\";
[103] Fix | Delete
}
[104] Fix | Delete
return "string";
[105] Fix | Delete
}
[106] Fix | Delete
state.tokenize = tokenStringHelper;
[107] Fix | Delete
return tokenStringHelper(stream, state);
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
function tokenInterpolation(stream, state) {
[111] Fix | Delete
stream.eat("$");
[112] Fix | Delete
if (stream.eat("{")) {
[113] Fix | Delete
// let clike handle the content of ${...},
[114] Fix | Delete
// we take over again when "}" appears (see hooks).
[115] Fix | Delete
state.tokenize = null;
[116] Fix | Delete
} else {
[117] Fix | Delete
state.tokenize = tokenInterpolationIdentifier;
[118] Fix | Delete
}
[119] Fix | Delete
return null;
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
function tokenInterpolationIdentifier(stream, state) {
[123] Fix | Delete
stream.eatWhile(/[\w_]/);
[124] Fix | Delete
state.tokenize = popInterpolationStack(state);
[125] Fix | Delete
return "variable";
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
function tokenNestedComment(depth) {
[129] Fix | Delete
return function (stream, state) {
[130] Fix | Delete
var ch
[131] Fix | Delete
while (ch = stream.next()) {
[132] Fix | Delete
if (ch == "*" && stream.eat("/")) {
[133] Fix | Delete
if (depth == 1) {
[134] Fix | Delete
state.tokenize = null
[135] Fix | Delete
break
[136] Fix | Delete
} else {
[137] Fix | Delete
state.tokenize = tokenNestedComment(depth - 1)
[138] Fix | Delete
return state.tokenize(stream, state)
[139] Fix | Delete
}
[140] Fix | Delete
} else if (ch == "/" && stream.eat("*")) {
[141] Fix | Delete
state.tokenize = tokenNestedComment(depth + 1)
[142] Fix | Delete
return state.tokenize(stream, state)
[143] Fix | Delete
}
[144] Fix | Delete
}
[145] Fix | Delete
return "comment"
[146] Fix | Delete
}
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins));
[150] Fix | Delete
[151] Fix | Delete
// This is needed to make loading through meta.js work.
[152] Fix | Delete
CodeMirror.defineMode("dart", function(conf) {
[153] Fix | Delete
return CodeMirror.getMode(conf, "application/dart");
[154] Fix | Delete
}, "clike");
[155] Fix | Delete
});
[156] Fix | Delete
[157] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function