Merge remote-tracking branch 'origin/master' into selective-bracket-insertion
This commit is contained in:
commit
6338bd10f3
147 changed files with 40437 additions and 79600 deletions
|
|
@ -53,8 +53,8 @@ var MultiSelect = require("./multi_select").MultiSelect;
|
|||
// The following require()s are for inclusion in the built ace file
|
||||
require("./worker/worker_client");
|
||||
require("./keyboard/hash_handler");
|
||||
require("./keyboard/state_handler");
|
||||
require("./placeholder");
|
||||
require("./mode/folding/fold_mode");
|
||||
exports.config = require("./config");
|
||||
/**
|
||||
* Ace.edit(el) -> Editor
|
||||
|
|
|
|||
|
|
@ -321,6 +321,11 @@ exports.commands = [{
|
|||
bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
|
||||
exec: function(editor) { editor.duplicateSelection(); },
|
||||
multiSelectAction: "forEach"
|
||||
}, {
|
||||
name: "sortlines",
|
||||
bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
|
||||
exec: function(editor) { editor.sortLines(); },
|
||||
multiSelectAction: "forEach"
|
||||
}, {
|
||||
name: "togglecomment",
|
||||
bindKey: bindKey("Ctrl-/", "Command-/"),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.ace_editor {
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;
|
||||
font-family: 'Menlo', 'Monaco', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
|
|
@ -242,6 +242,8 @@
|
|||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
cursor: default;
|
||||
white-space: pre-line;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.ace_folding-enabled > .ace_gutter-cell {
|
||||
|
|
@ -345,6 +347,10 @@
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ace_nobold .ace_bold {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.ace_italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
/**
|
||||
* EditSession.getSelection() -> String
|
||||
* EditSession.getSelection() -> Selection
|
||||
*
|
||||
* Returns the string of the current selection.
|
||||
**/
|
||||
|
|
@ -349,11 +349,11 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
/**
|
||||
* EditSession.getTokenAt(row, column) -> Array
|
||||
* EditSession.getTokenAt(row, column) -> Object
|
||||
* - row (Number): The row number to retrieve from
|
||||
* - column (Number): The column number to retrieve from
|
||||
*
|
||||
* Returns an array of tokens at the indicated row and column.
|
||||
* Returns an object indicating the token at the current row. The object has two properties: `index` and `start`.
|
||||
**/
|
||||
this.getTokenAt = function(row, column) {
|
||||
var tokens = this.bgTokenizer.getTokens(row);
|
||||
|
|
@ -752,15 +752,7 @@ var EditSession = function(text, mode) {
|
|||
* Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event.
|
||||
**/
|
||||
this.setAnnotations = function(annotations) {
|
||||
this.$annotations = {};
|
||||
for (var i=0; i<annotations.length; i++) {
|
||||
var annotation = annotations[i];
|
||||
var row = annotation.row;
|
||||
if (this.$annotations[row])
|
||||
this.$annotations[row].push(annotation);
|
||||
else
|
||||
this.$annotations[row] = [annotation];
|
||||
}
|
||||
this.$annotations = annotations;
|
||||
this._emit("changeAnnotation", {});
|
||||
};
|
||||
|
||||
|
|
@ -1212,8 +1204,8 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
/** related to: Document.getTextRange
|
||||
* EditSession.getTextRange(range) -> Array
|
||||
* - range (String): The range to work with
|
||||
* EditSession.getTextRange(range) -> String
|
||||
* - range (Range): The range to work with
|
||||
*
|
||||
* {:Document.getTextRange.desc}
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -683,6 +683,7 @@ function Folding() {
|
|||
};
|
||||
|
||||
this.onFoldWidgetClick = function(row, e) {
|
||||
e = e.domEvent;
|
||||
var type = this.getFoldWidget(row);
|
||||
var line = this.getLine(row);
|
||||
var onlySubfolds = e.shiftKey;
|
||||
|
|
|
|||
|
|
@ -1276,6 +1276,31 @@ var Editor = function(renderer, session) {
|
|||
this.session.outdentRows(selection.getRange());
|
||||
};
|
||||
|
||||
// TODO: move out of core when we have good mechanism for managing extensions
|
||||
this.sortLines = function() {
|
||||
var rows = this.$getSelectedRows();
|
||||
var session = this.session;
|
||||
|
||||
var lines = [];
|
||||
for (i = rows.first; i <= rows.last; i++)
|
||||
lines.push(session.getLine(i));
|
||||
|
||||
lines.sort(function(a, b) {
|
||||
if (a.toLowerCase() < b.toLowerCase()) return -1;
|
||||
if (a.toLowerCase() > b.toLowerCase()) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
var deleteRange = new Range(0, 0, 0, 0);
|
||||
for (var i = rows.first; i <= rows.last; i++) {
|
||||
var line = session.getLine(i);
|
||||
deleteRange.start.row = i;
|
||||
deleteRange.end.row = i;
|
||||
deleteRange.end.column = line.length;
|
||||
session.replace(deleteRange, lines[i-rows.first]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Editor.toggleCommentLines()
|
||||
*
|
||||
|
|
@ -1308,20 +1333,20 @@ var Editor = function(renderer, session) {
|
|||
|
||||
this.duplicateSelection = function() {
|
||||
var sel = this.selection;
|
||||
var doc = this.session;
|
||||
var range = sel.getRange();
|
||||
if (range.isEmpty()) {
|
||||
var row = range.start.row;
|
||||
doc.duplicateLines(row, row);
|
||||
} else {
|
||||
var reverse = sel.isBackwards()
|
||||
var point = sel.isBackwards() ? range.start : range.end;
|
||||
var endPoint = doc.insert(point, doc.getTextRange(range), false);
|
||||
range.start = point;
|
||||
range.end = endPoint;
|
||||
|
||||
sel.setSelectionRange(range, reverse)
|
||||
}
|
||||
var doc = this.session;
|
||||
var range = sel.getRange();
|
||||
if (range.isEmpty()) {
|
||||
var row = range.start.row;
|
||||
doc.duplicateLines(row, row);
|
||||
} else {
|
||||
var reverse = sel.isBackwards()
|
||||
var point = sel.isBackwards() ? range.start : range.end;
|
||||
var endPoint = doc.insert(point, doc.getTextRange(range), false);
|
||||
range.start = point;
|
||||
range.end = endPoint;
|
||||
|
||||
sel.setSelectionRange(range, reverse)
|
||||
}
|
||||
};
|
||||
|
||||
/** related to: EditSession.moveLinesDown
|
||||
|
|
@ -2101,4 +2126,4 @@ var Editor = function(renderer, session) {
|
|||
|
||||
|
||||
exports.Editor = Editor;
|
||||
});
|
||||
});
|
||||
|
|
@ -36,7 +36,7 @@ var UA = require("../lib/useragent");
|
|||
var net = require("../lib/net");
|
||||
var ace = require("../ace");
|
||||
|
||||
require("ace/theme/textmate");
|
||||
require("../theme/textmate");
|
||||
|
||||
module.exports = exports = ace;
|
||||
|
||||
|
|
|
|||
|
|
@ -304,76 +304,76 @@ var inputBuffer = exports.inputBuffer = {
|
|||
|
||||
lastInsertCommands: [],
|
||||
|
||||
push: function(editor, char, keyId) {
|
||||
push: function(editor, ch, keyId) {
|
||||
this.idle = false;
|
||||
var wObj = this.waitingForParam;
|
||||
if (wObj) {
|
||||
this.exec(editor, wObj, char);
|
||||
this.exec(editor, wObj, ch);
|
||||
}
|
||||
// If input is a number (that doesn't start with 0)
|
||||
else if (!(char === "0" && !this.currentCount.length) &&
|
||||
(char.match(/^\d+$/) && this.isAccepting(NUMBER))) {
|
||||
// Assuming that char is always of type String, and not Number
|
||||
this.currentCount += char;
|
||||
else if (!(ch === "0" && !this.currentCount.length) &&
|
||||
(ch.match(/^\d+$/) && this.isAccepting(NUMBER))) {
|
||||
// Assuming that ch is always of type String, and not Number
|
||||
this.currentCount += ch;
|
||||
this.currentCmd = NUMBER;
|
||||
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
||||
}
|
||||
else if (!this.operator && this.isAccepting(OPERATOR) && operators[char]) {
|
||||
else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
|
||||
this.operator = {
|
||||
char: char,
|
||||
ch: ch,
|
||||
count: this.getCount()
|
||||
};
|
||||
this.currentCmd = OPERATOR;
|
||||
this.accepting = [NUMBER, MOTION, ACTION];
|
||||
this.exec(editor, { operator: this.operator });
|
||||
}
|
||||
else if (motions[char] && this.isAccepting(MOTION)) {
|
||||
else if (motions[ch] && this.isAccepting(MOTION)) {
|
||||
this.currentCmd = MOTION;
|
||||
|
||||
var ctx = {
|
||||
operator: this.operator,
|
||||
motion: {
|
||||
char: char,
|
||||
ch: ch,
|
||||
count: this.getCount()
|
||||
}
|
||||
};
|
||||
|
||||
if (motions[char].param)
|
||||
if (motions[ch].param)
|
||||
this.waitForParam(ctx);
|
||||
else
|
||||
this.exec(editor, ctx);
|
||||
}
|
||||
else if (alias[char] && this.isAccepting(MOTION)) {
|
||||
alias[char].operator.count = this.getCount();
|
||||
this.exec(editor, alias[char]);
|
||||
else if (alias[ch] && this.isAccepting(MOTION)) {
|
||||
alias[ch].operator.count = this.getCount();
|
||||
this.exec(editor, alias[ch]);
|
||||
}
|
||||
else if (actions[char] && this.isAccepting(ACTION)) {
|
||||
else if (actions[ch] && this.isAccepting(ACTION)) {
|
||||
var actionObj = {
|
||||
action: {
|
||||
fn: actions[char].fn,
|
||||
fn: actions[ch].fn,
|
||||
count: this.getCount()
|
||||
}
|
||||
};
|
||||
|
||||
if (actions[char].param) {
|
||||
if (actions[ch].param) {
|
||||
this.waitForParam(actionObj);
|
||||
}
|
||||
else {
|
||||
this.exec(editor, actionObj);
|
||||
}
|
||||
|
||||
if (actions[char].acceptsMotion)
|
||||
if (actions[ch].acceptsMotion)
|
||||
this.idle = false;
|
||||
}
|
||||
else if (this.operator) {
|
||||
this.exec(editor, { operator: this.operator }, char);
|
||||
this.exec(editor, { operator: this.operator }, ch);
|
||||
}
|
||||
else {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
if (this.waitingForParam || this.motion || this.operator) {
|
||||
this.status += char;
|
||||
this.status += ch;
|
||||
} else if (this.currentCount) {
|
||||
this.status = this.currentCount;
|
||||
} else if (this.status) {
|
||||
|
|
@ -410,18 +410,18 @@ var inputBuffer = exports.inputBuffer = {
|
|||
}
|
||||
|
||||
if (o && !editor.selection.isEmpty()) {
|
||||
if (operators[o.char].selFn) {
|
||||
operators[o.char].selFn(editor, editor.getSelectionRange(), o.count, param);
|
||||
if (operators[o.ch].selFn) {
|
||||
operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
|
||||
this.reset();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// There is an operator, but no motion or action. We try to pass the
|
||||
// current char to the operator to see if it responds to it (an example
|
||||
// current ch to the operator to see if it responds to it (an example
|
||||
// of this is the 'dd' operator).
|
||||
else if (!m && !a && o && param) {
|
||||
operators[o.char].fn(editor, null, o.count, param);
|
||||
operators[o.ch].fn(editor, null, o.count, param);
|
||||
this.reset();
|
||||
}
|
||||
else if (m) {
|
||||
|
|
@ -434,7 +434,7 @@ var inputBuffer = exports.inputBuffer = {
|
|||
}
|
||||
};
|
||||
|
||||
var motionObj = motions[m.char];
|
||||
var motionObj = motions[m.ch];
|
||||
var selectable = motionObj.sel;
|
||||
|
||||
if (!o) {
|
||||
|
|
@ -446,7 +446,7 @@ var inputBuffer = exports.inputBuffer = {
|
|||
else if (selectable) {
|
||||
repeat(function() {
|
||||
run(motionObj.sel);
|
||||
operators[o.char].fn(editor, editor.getSelectionRange(), o.count, param);
|
||||
operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param);
|
||||
}, o.count || 1);
|
||||
}
|
||||
this.reset();
|
||||
|
|
|
|||
|
|
@ -34,57 +34,57 @@ define(function(require, exports, module) {
|
|||
module.exports = {
|
||||
"x": {
|
||||
operator: {
|
||||
char: "d",
|
||||
ch: "d",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "l",
|
||||
ch: "l",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"X": {
|
||||
operator: {
|
||||
char: "d",
|
||||
ch: "d",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "h",
|
||||
ch: "h",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"D": {
|
||||
operator: {
|
||||
char: "d",
|
||||
ch: "d",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "$",
|
||||
ch: "$",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"C": {
|
||||
operator: {
|
||||
char: "c",
|
||||
ch: "c",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "$",
|
||||
ch: "$",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"s": {
|
||||
operator: {
|
||||
char: "c",
|
||||
ch: "c",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "l",
|
||||
ch: "l",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"S": {
|
||||
operator: {
|
||||
char: "c",
|
||||
ch: "c",
|
||||
count: 1
|
||||
},
|
||||
param: "c"
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ var StringStream = function(editor, cursor) {
|
|||
};
|
||||
};
|
||||
|
||||
var Search = require("ace/search").Search;
|
||||
var Search = require("../../../search").Search;
|
||||
var search = new Search();
|
||||
|
||||
function find(editor, needle, dir) {
|
||||
|
|
@ -136,7 +136,7 @@ function find(editor, needle, dir) {
|
|||
return search.find(editor.session);
|
||||
}
|
||||
|
||||
var Range = require("ace/range").Range;
|
||||
var Range = require("../../../range").Range;
|
||||
|
||||
module.exports = {
|
||||
"w": new Motion(function(editor) {
|
||||
|
|
@ -580,7 +580,7 @@ module.exports = {
|
|||
sel: function(editor, range, count, param) {
|
||||
keepScrollPosition(editor, editor.selectPageUp);
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.backspace = module.exports.left = module.exports.h;
|
||||
|
|
|
|||
|
|
@ -99,24 +99,24 @@ module.exports = {
|
|||
this.onVisualLineMode = false;
|
||||
}
|
||||
},
|
||||
getRightNthChar: function(editor, cursor, char, n) {
|
||||
getRightNthChar: function(editor, cursor, ch, n) {
|
||||
var line = editor.getSession().getLine(cursor.row);
|
||||
var matches = line.substr(cursor.column + 1).split(char);
|
||||
var matches = line.substr(cursor.column + 1).split(ch);
|
||||
|
||||
return n < matches.length ? matches.slice(0, n).join(char).length : null;
|
||||
return n < matches.length ? matches.slice(0, n).join(ch).length : null;
|
||||
},
|
||||
getLeftNthChar: function(editor, cursor, char, n) {
|
||||
getLeftNthChar: function(editor, cursor, ch, n) {
|
||||
var line = editor.getSession().getLine(cursor.row);
|
||||
var matches = line.substr(0, cursor.column).split(char);
|
||||
var matches = line.substr(0, cursor.column).split(ch);
|
||||
|
||||
return n < matches.length ? matches.slice(-1 * n).join(char).length : null;
|
||||
return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
|
||||
},
|
||||
toRealChar: function(char) {
|
||||
if (char.length === 1)
|
||||
return char;
|
||||
toRealChar: function(ch) {
|
||||
if (ch.length === 1)
|
||||
return ch;
|
||||
|
||||
if (/^shift-./.test(char))
|
||||
return char[char.length - 1].toUpperCase();
|
||||
if (/^shift-./.test(ch))
|
||||
return ch[ch.length - 1].toUpperCase();
|
||||
else
|
||||
return "";
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ define(function(require, exports, module) {
|
|||
|
||||
var dom = require("../lib/dom");
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var EventEmitter = require("../lib/event_emitter").EventEmitter;
|
||||
|
||||
var Gutter = function(parentEl) {
|
||||
|
|
@ -44,14 +45,18 @@ var Gutter = function(parentEl) {
|
|||
this.gutterWidth = 0;
|
||||
|
||||
this.$annotations = [];
|
||||
this.$updateAnnotations = this.$updateAnnotations.bind(this);
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
|
||||
this.setSession = function(session) {
|
||||
if (this.session)
|
||||
this.session.removeEventListener("change", this.$updateAnnotations);
|
||||
this.session = session;
|
||||
session.on("change", this.$updateAnnotations);
|
||||
};
|
||||
|
||||
this.addGutterDecoration = function(row, className){
|
||||
|
|
@ -68,28 +73,46 @@ var Gutter = function(parentEl) {
|
|||
|
||||
this.setAnnotations = function(annotations) {
|
||||
// iterate over sparse array
|
||||
this.$annotations = [];
|
||||
for (var row in annotations) if (annotations.hasOwnProperty(row)) {
|
||||
var rowAnnotations = annotations[row];
|
||||
if (!rowAnnotations)
|
||||
continue;
|
||||
this.$annotations = []
|
||||
var rowInfo, row;
|
||||
for (var i = 0; i < annotations.length; i++) {
|
||||
var annotation = annotations[i];
|
||||
var row = annotation.row;
|
||||
var rowInfo = this.$annotations[row];
|
||||
if (!rowInfo)
|
||||
rowInfo = this.$annotations[row] = {text: []};
|
||||
|
||||
var annoText = annotation.text;
|
||||
annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
|
||||
|
||||
var rowInfo = this.$annotations[row] = {
|
||||
text: []
|
||||
};
|
||||
for (var i=0; i<rowAnnotations.length; i++) {
|
||||
var annotation = rowAnnotations[i];
|
||||
var annoText = annotation.text.replace(/"/g, """).replace(/'/g, "’").replace(/</, "<");
|
||||
if (rowInfo.text.indexOf(annoText) === -1)
|
||||
rowInfo.text.push(annoText);
|
||||
var type = annotation.type;
|
||||
if (type == "error")
|
||||
rowInfo.className = " ace_error";
|
||||
else if (type == "warning" && rowInfo.className != " ace_error")
|
||||
rowInfo.className = " ace_warning";
|
||||
else if (type == "info" && (!rowInfo.className))
|
||||
rowInfo.className = " ace_info";
|
||||
}
|
||||
if (rowInfo.text.indexOf(annoText) === -1)
|
||||
rowInfo.text.push(annoText);
|
||||
|
||||
var type = annotation.type;
|
||||
if (type == "error")
|
||||
rowInfo.className = " ace_error";
|
||||
else if (type == "warning" && rowInfo.className != " ace_error")
|
||||
rowInfo.className = " ace_warning";
|
||||
else if (type == "info" && (!rowInfo.className))
|
||||
rowInfo.className = " ace_info";
|
||||
}
|
||||
};
|
||||
|
||||
this.$updateAnnotations = function (e) {
|
||||
if (!this.$annotations.length)
|
||||
return;
|
||||
var delta = e.data;
|
||||
var range = delta.range;
|
||||
var firstRow = range.start.row;
|
||||
var len = range.end.row - firstRow;
|
||||
if (len === 0) {
|
||||
// do nothing
|
||||
} else if (delta.action == "removeText" || delta.action == "removeLines") {
|
||||
this.$annotations.splice(firstRow, len + 1, null);
|
||||
} else {
|
||||
var args = Array(len + 1);
|
||||
args.unshift(firstRow, 1);
|
||||
this.$annotations.splice.apply(this.$annotations, args);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ var Text = function(parentEl) {
|
|||
this.element.className = "ace_layer ace_text-layer";
|
||||
parentEl.appendChild(this.element);
|
||||
|
||||
this.$characterSize = this.$measureSizes() || {width: 0, height: 0};
|
||||
this.$characterSize = {width: 0, height: 0};
|
||||
this.checkForSizeChanges();
|
||||
this.$pollSizeChanges();
|
||||
};
|
||||
|
||||
|
|
@ -72,7 +73,11 @@ var Text = function(parentEl) {
|
|||
this.checkForSizeChanges = function() {
|
||||
var size = this.$measureSizes();
|
||||
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
|
||||
this.$measureNode.style.fontWeight = "bold";
|
||||
var boldSize = this.$measureSizes();
|
||||
this.$measureNode.style.fontWeight = "";
|
||||
this.$characterSize = size;
|
||||
this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
|
||||
this._emit("changeCharacterSize", {data: size});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -117,6 +117,10 @@ exports.escapeRegExp = function(str) {
|
|||
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
|
||||
};
|
||||
|
||||
exports.escapeHTML = function(str) {
|
||||
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<");
|
||||
};
|
||||
|
||||
exports.getMatchOffsets = function(string, regExp) {
|
||||
var matches = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ function foo(items, nada) {
|
|||
} // Real Tab.
|
||||
}
|
||||
|
||||
regexp = /p|p/ // ends here
|
||||
|
||||
r = /d{1,2}?f{e}++r*?\d+?[]r[^r-o\f\f[\f]?r{7}+r\{7}+rr--rr$^(?:d|s)(?=a|)(?!y)[]|$?|^*/ o
|
||||
a=/a/ jk = / / / / /
|
||||
/************************************/
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
{
|
||||
"state": "start",
|
||||
"data": [
|
||||
[ "keyword", "using" ],
|
||||
[ "keyword.control", "using" ],
|
||||
[ "text", " " ],
|
||||
[ "keyword", "namespace" ],
|
||||
[ "keyword.operator", "namespace" ],
|
||||
[ "text", " " ],
|
||||
[ "identifier", "std" ],
|
||||
[ "punctuation.operator", ";" ]
|
||||
|
|
@ -35,9 +35,9 @@
|
|||
{
|
||||
"state": "start",
|
||||
"data": [
|
||||
[ "keyword", "int" ],
|
||||
[ "storage.type", "int" ],
|
||||
[ "text", " " ],
|
||||
[ "identifier", "main" ],
|
||||
[ "entity.name.function", "main" ],
|
||||
[ "text", " " ],
|
||||
[ "paren.lparen", "(" ],
|
||||
[ "paren.rparen", ")" ]
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
"state": "start",
|
||||
"data": [
|
||||
[ "text", " " ],
|
||||
[ "keyword", "int" ],
|
||||
[ "storage.type", "int" ],
|
||||
[ "text", " " ],
|
||||
[ "identifier", "a" ],
|
||||
[ "punctuation.operator", "," ],
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
"state": "start",
|
||||
"data": [
|
||||
[ "text", " " ],
|
||||
[ "keyword", "return" ],
|
||||
[ "keyword.control", "return" ],
|
||||
[ "text", " " ],
|
||||
[ "constant.numeric", "0" ],
|
||||
[ "punctuation.operator", ";" ]
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
"data": [
|
||||
[ "keyword", "void" ],
|
||||
[ "text", " " ],
|
||||
[ "identifier", "main" ],
|
||||
[ "entity.name.function", "main" ],
|
||||
[ "paren.lparen", "(" ],
|
||||
[ "paren.rparen", ")" ],
|
||||
[ "text", " " ],
|
||||
|
|
|
|||
|
|
@ -81,6 +81,24 @@
|
|||
"state": "start",
|
||||
"data": []
|
||||
},
|
||||
{
|
||||
"state": "start",
|
||||
"data": [
|
||||
[ "identifier", "regexp" ],
|
||||
[ "text", " " ],
|
||||
[ "keyword.operator", "=" ],
|
||||
[ "text", " " ],
|
||||
[ "string.regexp", "/p" ],
|
||||
[ "constant.language.escape", "|" ],
|
||||
[ "string.regexp", "p/" ],
|
||||
[ "text", " " ],
|
||||
[ "comment", "// ends here" ]
|
||||
]
|
||||
},
|
||||
{
|
||||
"state": "start",
|
||||
"data": []
|
||||
},
|
||||
{
|
||||
"state": "start",
|
||||
"data": [
|
||||
|
|
@ -118,10 +136,13 @@
|
|||
[ "constant.language.escape", "$" ],
|
||||
[ "constant.language.escape", "^" ],
|
||||
[ "constant.language.escape", "(?:" ],
|
||||
[ "string.regexp", "d|s" ],
|
||||
[ "string.regexp", "d" ],
|
||||
[ "constant.language.escape", "|" ],
|
||||
[ "string.regexp", "s" ],
|
||||
[ "constant.language.escape", ")" ],
|
||||
[ "constant.language.escape", "(?=" ],
|
||||
[ "string.regexp", "a|" ],
|
||||
[ "string.regexp", "a" ],
|
||||
[ "constant.language.escape", "|" ],
|
||||
[ "constant.language.escape", ")" ],
|
||||
[ "constant.language.escape", "(?!" ],
|
||||
[ "string.regexp", "y" ],
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
|
|
@ -29,20 +29,36 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
// Global variables to hide from the interpreter
|
||||
exports.hiddenHostGlobals = { Narcissus: true };
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var AsciidocHighlightRules = require("./asciidoc_highlight_rules").AsciidocHighlightRules;
|
||||
var AsciidocFoldMode = require("./folding/asciidoc").FoldMode;
|
||||
|
||||
// Desugar SpiderMonkey language extensions?
|
||||
exports.desugarExtensions = false;
|
||||
var Mode = function() {
|
||||
var highlighter = new AsciidocHighlightRules();
|
||||
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.foldingRules = new AsciidocFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
// Allow HTML comments?
|
||||
exports.allowHTMLComments = false;
|
||||
|
||||
// Allow non-standard Mozilla extensions?
|
||||
exports.mozillaMode = true;
|
||||
|
||||
// Allow experimental paren-free mode?
|
||||
exports.parenFreeMode = false;
|
||||
(function() {
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
if (state == "listblock") {
|
||||
var match = /^((?:.+)?)([-+*][ ]+)/.exec(line);
|
||||
if (match) {
|
||||
return new Array(match[1].length + 1).join(" ") + match[2];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
return this.$getIndent(line);
|
||||
}
|
||||
};
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
233
lib/ace/mode/asciidoc_highlight_rules.js
Normal file
233
lib/ace/mode/asciidoc_highlight_rules.js
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var AsciidocHighlightRules = function() {
|
||||
var identifierRe = "[a-zA-Z\u00a1-\uffff]+\\b";
|
||||
|
||||
this.$rules = {
|
||||
"start": [
|
||||
{token: "empty", regex: /$/},
|
||||
{token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock"},
|
||||
{token: "literal", regex: /^-{4,}\s*$/, next: "literalBlock"},
|
||||
{token: "string", regex: /^\+{4,}\s*$/, next: "passthroughBlock"},
|
||||
{token: "keyword", regex: /^={4,}\s*$/},
|
||||
{token: "text", regex: /^\s*$/},
|
||||
// immediately return to the start mode without matching anything
|
||||
{token: "empty", regex: "", next: "dissallowDelimitedBlock"}
|
||||
],
|
||||
|
||||
"dissallowDelimitedBlock": [
|
||||
{include: "paragraphEnd"},
|
||||
{token: "comment", regex: '^//.+$'},
|
||||
{token: "keyword", regex: "^(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION):"},
|
||||
|
||||
{include: "listStart"},
|
||||
{token: "literal", regex: /^\s+.+$/, next: "indentedBlock"},
|
||||
{token: "empty", regex: "", next: "text"}
|
||||
],
|
||||
|
||||
"paragraphEnd": [
|
||||
{token: "doc.comment", regex: /^\/{4,}\s*$/, next: "commentBlock"},
|
||||
{token: "tableBlock", regex: /^\s*[|!]=+\s*$/, next: "tableBlock"},
|
||||
// open block, ruller
|
||||
{token: "keyword", regex: /^(?:--|''')\s*$/, next: "start"},
|
||||
{token: "option", regex: /^\[.*\]\s*$/, next: "start"},
|
||||
{token: "pageBreak", regex: /^>{3,}$/, next: "start"},
|
||||
{token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock"},
|
||||
{token: "titleUnderline", regex: /^(?:={2,}|-{2,}|~{2,}|\^{2,}|\+{2,})\s*$/, next: "start"},
|
||||
{token: "singleLineTitle", regex: /^={1,5}\s+\S.*$/, next: "start"},
|
||||
|
||||
{token: "otherBlock", regex: /^(?:\*{2,}|_{2,})\s*$/, next: "start"},
|
||||
// .optional title
|
||||
{token: "optionalTitle", regex: /^\.[^.\s].+$/, next: "start"}
|
||||
],
|
||||
|
||||
"listStart": [
|
||||
{token: "keyword", regex: /^\s*(?:\d+\.|[a-zA-Z]\.|[ixvmIXVM]+\)|\*{1,5}|-|\.{1,5})\s/, next: "listText"},
|
||||
{token: "meta.tag", regex: /^.+(?::{2,4}|;;)(?: |$)/, next: "listText"},
|
||||
{token: "support.function.list.callout", regex: /^(?:<\d+>|\d+>|>) /, next: "text"},
|
||||
// continuation
|
||||
{token: "keyword", regex: /^\+\s*$/, next: "start"}
|
||||
],
|
||||
|
||||
"text": [
|
||||
{token: ["link", "variable.language"], regex: /((?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+)(\[.*?\])/},
|
||||
{token: "link", regex: /(?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+/},
|
||||
{token: "link", regex: /\b[\w\.\/\-]+@[\w\.\/\-]+\b/},
|
||||
{include: "macros"},
|
||||
{include: "paragraphEnd"},
|
||||
{token: "literal", regex:/\+{3,}/, next:"smallPassthrough"},
|
||||
{token: "escape", regex: /\((?:C|TM|R)\)|\.{3}|->|<-|=>|<=|&#(?:\d+|x[a-fA-F\d]+);|(?: |^)--(?=\s+\S)/},
|
||||
{token: "escape", regex: /\\[_*'`+#]|\\{2}[_*'`+#]{2}/},
|
||||
{token: "keyword", regex: /\s\+$/},
|
||||
// any word
|
||||
{token: "text", regex: identifierRe},
|
||||
{token: ["keyword", "string", "keyword"],
|
||||
regex: /(<<[\w\d\-$]+,)(.*?)(>>|$)/, merge: true},
|
||||
{token: "keyword", regex: /<<[\w\d\-$]+,?|>>/, merge: true},
|
||||
{token: "constant.character", regex: /\({2,3}.*?\){2,3}/, merge: true},
|
||||
// Anchor
|
||||
{token: "keyword", regex: /\[\[.+?\]\]/},
|
||||
// bibliography
|
||||
{token: "support", regex: /^\[{3}[\w\d =\-]+\]{3}/},
|
||||
|
||||
{include: "quotes"},
|
||||
// text block end
|
||||
{token: "empty", regex: /^\s*$/, next: "start"}
|
||||
],
|
||||
|
||||
"listText": [
|
||||
{include: "listStart"},
|
||||
{include: "text"}
|
||||
],
|
||||
|
||||
"indentedBlock": [
|
||||
{token: "literal", regex: /^[\s\w].+$/, next: "indentedBlock"},
|
||||
{token: "literal", regex: "", next: "start"}
|
||||
],
|
||||
|
||||
"listingBlock": [
|
||||
{token: "literal", regex: /^\.{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "constant.numeric", regex: '<\\d+>'},
|
||||
{token: "literal", regex: '[^<]+', merge: true},
|
||||
{token: "literal", regex: '<', merge: true}
|
||||
],
|
||||
"literalBlock": [
|
||||
{token: "literal", regex: /^-{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "constant.numeric", regex: '<\\d+>'},
|
||||
{token: "literal", regex: '[^<]+', merge: true},
|
||||
{token: "literal", regex: '<', merge: true}
|
||||
],
|
||||
"passthroughBlock": [
|
||||
{token: "literal", regex: /^\+{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "literal", regex: identifierRe + "|\\d+", merge: true},
|
||||
{include: "macros"},
|
||||
{token: "literal", regex: ".", merge: true}
|
||||
],
|
||||
|
||||
"smallPassthrough": [
|
||||
{token: "literal", regex: /[+]{3,}/, next: "dissallowDelimitedBlock"},
|
||||
{token: "literal", regex: /^\s*$/, next: "dissallowDelimitedBlock", merge: true},
|
||||
{token: "literal", regex: identifierRe + "|\\d+", merge: true},
|
||||
{include: "macros"}
|
||||
],
|
||||
|
||||
"commentBlock": [
|
||||
{token: "doc.comment", regex: /^\/{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "doc.comment", regex: '^.*$'}
|
||||
],
|
||||
"tableBlock": [
|
||||
{token: "tableBlock", regex: /^\s*\|={3,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "innerTableBlock"},
|
||||
{token: "tableBlock", regex: /\|/},
|
||||
{include: "text", noEscape: true}
|
||||
],
|
||||
"innerTableBlock": [
|
||||
{token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "tableBlock"},
|
||||
{token: "tableBlock", regex: /^\s*|={3,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "tableBlock", regex: /\!/}
|
||||
],
|
||||
"macros": [
|
||||
{token: "macro", regex: /{[\w\-$]+}/},
|
||||
{token: ["text", "string", "text", "constant.character", "text"], regex: /({)([\w\-$]+)(:)?(.+)?(})/},
|
||||
{token: ["markup.list.macro", "keyword", "string"], regex: /([\w\.\/\-]+::?)([^\s\[]+)(\[.*?\])?/},
|
||||
{token: ["markup.list.macro", "keyword"], regex: /([\w\.\/\-]+::?)(\[.*?\])/},
|
||||
{token: "keyword", regex: /^:.+?:(?= |$)/}
|
||||
],
|
||||
|
||||
"quotes": [
|
||||
{token: "string.italic", regex: /__[^_\s].*?__/},
|
||||
{token: "string.italic", regex: quoteRule("_")},
|
||||
|
||||
{token: "keyword.bold", regex: /\*\*[^*\s].*?\*\*/},
|
||||
{token: "keyword.bold", regex: quoteRule("\\*")},
|
||||
|
||||
{token: "literal", regex: quoteRule("\\+")},
|
||||
{token: "literal", regex: /\+\+[^+\s].*?\+\+/},
|
||||
{token: "literal", regex: /\$\$.+?\$\$/},
|
||||
{token: "literal", regex: quoteRule("`")},
|
||||
|
||||
{token: "keyword", regex: quoteRule("^")},
|
||||
{token: "keyword", regex: quoteRule("~")},
|
||||
{token: "keyword", regex: /##?/},
|
||||
{token: "keyword", regex: /(?:\B|^)``|\b''/}
|
||||
]
|
||||
|
||||
};
|
||||
|
||||
function quoteRule(ch) {
|
||||
var prefix = /\w/.test(ch) ? "\\b" : "(?:\\B|^)";
|
||||
return prefix + ch + "[^" + ch + "].*?" + ch + "(?![\\w*])";
|
||||
}
|
||||
|
||||
//addQuoteBlock("text")
|
||||
|
||||
var tokenMap = {
|
||||
macro: "constant.character",
|
||||
tableBlock: "doc.comment",
|
||||
titleUnderline: "markup.heading",
|
||||
singleLineTitle: "markup.heading",
|
||||
pageBreak: "string",
|
||||
option: "string.regexp",
|
||||
otherBlock: "markup.list",
|
||||
literal: "support.function",
|
||||
optionalTitle: "constant.numeric",
|
||||
escape: "constant.language.escape",
|
||||
link: "markup.underline.list"
|
||||
};
|
||||
|
||||
for (var state in this.$rules) {
|
||||
var stateRules = this.$rules[state];
|
||||
for (var i = stateRules.length; i--; ) {
|
||||
var rule = stateRules[i];
|
||||
if (rule.include || typeof rule == "string") {
|
||||
var args = [i, 1].concat(this.$rules[rule.include || rule]);
|
||||
if (rule.noEscape) {
|
||||
args = args.filter(function(x) {
|
||||
return !x.next;
|
||||
});
|
||||
}
|
||||
stateRules.splice.apply(stateRules, args);
|
||||
} else if (rule.token in tokenMap) {
|
||||
rule.token = tokenMap[rule.token];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
oop.inherits(AsciidocHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.AsciidocHighlightRules = AsciidocHighlightRules;
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
/**
|
||||
* Copyright (c) 2009-2012 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -24,9 +24,9 @@
|
|||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
// Generated by CoffeeScript 1.2.1-pre
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
|
||||
var extend, flatten;
|
||||
var extend, flatten, _ref;
|
||||
|
||||
exports.starts = function(string, literal, start) {
|
||||
return literal === string.substr(start, literal.length);
|
||||
|
|
@ -43,7 +43,9 @@ define(function(require, exports, module) {
|
|||
_results = [];
|
||||
for (_i = 0, _len = array.length; _i < _len; _i++) {
|
||||
item = array[_i];
|
||||
if (item) _results.push(item);
|
||||
if (item) {
|
||||
_results.push(item);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
|
@ -51,7 +53,9 @@ define(function(require, exports, module) {
|
|||
exports.count = function(string, substr) {
|
||||
var num, pos;
|
||||
num = pos = 0;
|
||||
if (!substr.length) return 1 / 0;
|
||||
if (!substr.length) {
|
||||
return 1 / 0;
|
||||
}
|
||||
while (pos = 1 + string.indexOf(substr, pos)) {
|
||||
num++;
|
||||
}
|
||||
|
|
@ -96,5 +100,16 @@ define(function(require, exports, module) {
|
|||
return array[array.length - (back || 0) - 1];
|
||||
};
|
||||
|
||||
exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) {
|
||||
var e, _i, _len;
|
||||
for (_i = 0, _len = this.length; _i < _len; _i++) {
|
||||
e = this[_i];
|
||||
if (fn(e)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
/**
|
||||
* Copyright (c) 2009-2012 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
// Generated by CoffeeScript 1.2.1-pre
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
|
||||
var BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref, _ref1,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
|
@ -35,14 +35,16 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.Lexer = Lexer = (function() {
|
||||
|
||||
Lexer.name = 'Lexer';
|
||||
|
||||
function Lexer() {}
|
||||
|
||||
Lexer.prototype.tokenize = function(code, opts) {
|
||||
var i, tag;
|
||||
if (opts == null) opts = {};
|
||||
if (WHITESPACE.test(code)) code = "\n" + code;
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
if (WHITESPACE.test(code)) {
|
||||
code = "\n" + code;
|
||||
}
|
||||
code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
|
||||
this.code = code;
|
||||
this.line = opts.line || 0;
|
||||
|
|
@ -57,14 +59,20 @@ define(function(require, exports, module) {
|
|||
i += this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
|
||||
}
|
||||
this.closeIndentation();
|
||||
if (tag = this.ends.pop()) this.error("missing " + tag);
|
||||
if (opts.rewrite === false) return this.tokens;
|
||||
if (tag = this.ends.pop()) {
|
||||
this.error("missing " + tag);
|
||||
}
|
||||
if (opts.rewrite === false) {
|
||||
return this.tokens;
|
||||
}
|
||||
return (new Rewriter).rewrite(this.tokens);
|
||||
};
|
||||
|
||||
Lexer.prototype.identifierToken = function() {
|
||||
var colon, forcedIdentifier, id, input, match, prev, tag, _ref2, _ref3;
|
||||
if (!(match = IDENTIFIER.exec(this.chunk))) return 0;
|
||||
if (!(match = IDENTIFIER.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
input = match[0], id = match[1], colon = match[2];
|
||||
if (id === 'own' && this.tag() === 'FOR') {
|
||||
this.token('OWN', id);
|
||||
|
|
@ -105,7 +113,9 @@ define(function(require, exports, module) {
|
|||
}
|
||||
}
|
||||
if (!forcedIdentifier) {
|
||||
if (__indexOf.call(COFFEE_ALIASES, id) >= 0) id = COFFEE_ALIAS_MAP[id];
|
||||
if (__indexOf.call(COFFEE_ALIASES, id) >= 0) {
|
||||
id = COFFEE_ALIAS_MAP[id];
|
||||
}
|
||||
tag = (function() {
|
||||
switch (id) {
|
||||
case '!':
|
||||
|
|
@ -118,8 +128,6 @@ define(function(require, exports, module) {
|
|||
return 'LOGIC';
|
||||
case 'true':
|
||||
case 'false':
|
||||
case 'null':
|
||||
case 'undefined':
|
||||
return 'BOOL';
|
||||
case 'break':
|
||||
case 'continue':
|
||||
|
|
@ -130,29 +138,33 @@ define(function(require, exports, module) {
|
|||
})();
|
||||
}
|
||||
this.token(tag, id);
|
||||
if (colon) this.token(':', ':');
|
||||
if (colon) {
|
||||
this.token(':', ':');
|
||||
}
|
||||
return input.length;
|
||||
};
|
||||
|
||||
Lexer.prototype.numberToken = function() {
|
||||
var binaryLiteral, lexedLength, match, number, octalLiteral;
|
||||
if (!(match = NUMBER.exec(this.chunk))) return 0;
|
||||
if (!(match = NUMBER.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
number = match[0];
|
||||
if (/E/.test(number)) {
|
||||
this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'");
|
||||
} else if (/[BOX]/.test(number)) {
|
||||
if (/^0[BOX]/.test(number)) {
|
||||
this.error("radix prefix '" + number + "' must be lowercase");
|
||||
} else if (/^0[89]/.test(number)) {
|
||||
} else if (/E/.test(number) && !/^0x/.test(number)) {
|
||||
this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'");
|
||||
} else if (/^0\d*[89]/.test(number)) {
|
||||
this.error("decimal literal '" + number + "' must not be prefixed with '0'");
|
||||
} else if (/^0[0-7]/.test(number)) {
|
||||
} else if (/^0\d+/.test(number)) {
|
||||
this.error("octal literal '" + number + "' must be prefixed with '0o'");
|
||||
}
|
||||
lexedLength = number.length;
|
||||
if (octalLiteral = /0o([0-7]+)/.exec(number)) {
|
||||
number = (parseInt(octalLiteral[1], 8)).toString();
|
||||
if (octalLiteral = /^0o([0-7]+)/.exec(number)) {
|
||||
number = '0x' + (parseInt(octalLiteral[1], 8)).toString(16);
|
||||
}
|
||||
if (binaryLiteral = /0b([01]+)/.exec(number)) {
|
||||
number = (parseInt(binaryLiteral[1], 2)).toString();
|
||||
if (binaryLiteral = /^0b([01]+)/.exec(number)) {
|
||||
number = '0x' + (parseInt(binaryLiteral[1], 2)).toString(16);
|
||||
}
|
||||
this.token('NUMBER', number);
|
||||
return lexedLength;
|
||||
|
|
@ -162,11 +174,15 @@ define(function(require, exports, module) {
|
|||
var match, octalEsc, string;
|
||||
switch (this.chunk.charAt(0)) {
|
||||
case "'":
|
||||
if (!(match = SIMPLESTR.exec(this.chunk))) return 0;
|
||||
if (!(match = SIMPLESTR.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
this.token('STRING', (string = match[0]).replace(MULTILINER, '\\\n'));
|
||||
break;
|
||||
case '"':
|
||||
if (!(string = this.balancedString(this.chunk, '"'))) return 0;
|
||||
if (!(string = this.balancedString(this.chunk, '"'))) {
|
||||
return 0;
|
||||
}
|
||||
if (0 < string.indexOf('#{', 1)) {
|
||||
this.interpolateString(string.slice(1, -1));
|
||||
} else {
|
||||
|
|
@ -176,7 +192,7 @@ define(function(require, exports, module) {
|
|||
default:
|
||||
return 0;
|
||||
}
|
||||
if (octalEsc = /^(?:\\.|[^\\])*\\[0-7]/.test(string)) {
|
||||
if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) {
|
||||
this.error("octal escape sequences " + string + " are not allowed");
|
||||
}
|
||||
this.line += count(string, '\n');
|
||||
|
|
@ -185,7 +201,9 @@ define(function(require, exports, module) {
|
|||
|
||||
Lexer.prototype.heredocToken = function() {
|
||||
var doc, heredoc, match, quote;
|
||||
if (!(match = HEREDOC.exec(this.chunk))) return 0;
|
||||
if (!(match = HEREDOC.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
heredoc = match[0];
|
||||
quote = heredoc.charAt(0);
|
||||
doc = this.sanitizeHeredoc(match[2], {
|
||||
|
|
@ -205,7 +223,9 @@ define(function(require, exports, module) {
|
|||
|
||||
Lexer.prototype.commentToken = function() {
|
||||
var comment, here, match;
|
||||
if (!(match = this.chunk.match(COMMENT))) return 0;
|
||||
if (!(match = this.chunk.match(COMMENT))) {
|
||||
return 0;
|
||||
}
|
||||
comment = match[0], here = match[1];
|
||||
if (here) {
|
||||
this.token('HERECOMMENT', this.sanitizeHeredoc(here, {
|
||||
|
|
@ -223,12 +243,15 @@ define(function(require, exports, module) {
|
|||
return 0;
|
||||
}
|
||||
this.token('JS', (script = match[0]).slice(1, -1));
|
||||
this.line += count(script, '\n');
|
||||
return script.length;
|
||||
};
|
||||
|
||||
Lexer.prototype.regexToken = function() {
|
||||
var flags, length, match, prev, regex, _ref2, _ref3;
|
||||
if (this.chunk.charAt(0) !== '/') return 0;
|
||||
if (this.chunk.charAt(0) !== '/') {
|
||||
return 0;
|
||||
}
|
||||
if (match = HEREGEX.exec(this.chunk)) {
|
||||
length = this.heregexToken(match);
|
||||
this.line += count(match[0], '\n');
|
||||
|
|
@ -238,12 +261,16 @@ define(function(require, exports, module) {
|
|||
if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) {
|
||||
return 0;
|
||||
}
|
||||
if (!(match = REGEX.exec(this.chunk))) return 0;
|
||||
if (!(match = REGEX.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
_ref3 = match, match = _ref3[0], regex = _ref3[1], flags = _ref3[2];
|
||||
if (regex.slice(0, 2) === '/*') {
|
||||
this.error('regular expressions cannot begin with `*`');
|
||||
}
|
||||
if (regex === '//') regex = '/(?:)/';
|
||||
if (regex === '//') {
|
||||
regex = '/(?:)/';
|
||||
}
|
||||
this.token('REGEX', "" + regex + flags);
|
||||
return match.length;
|
||||
};
|
||||
|
|
@ -270,7 +297,9 @@ define(function(require, exports, module) {
|
|||
if (tag === 'TOKENS') {
|
||||
tokens.push.apply(tokens, value);
|
||||
} else {
|
||||
if (!(value = value.replace(HEREGEX_OMIT, ''))) continue;
|
||||
if (!(value = value.replace(HEREGEX_OMIT, ''))) {
|
||||
continue;
|
||||
}
|
||||
value = value.replace(/\\/g, '\\\\');
|
||||
tokens.push(['STRING', this.makeString(value, '"', true)]);
|
||||
}
|
||||
|
|
@ -281,18 +310,21 @@ define(function(require, exports, module) {
|
|||
this.tokens.push(['STRING', '""'], ['+', '+']);
|
||||
}
|
||||
(_ref5 = this.tokens).push.apply(_ref5, tokens);
|
||||
if (flags) this.tokens.push([',', ','], ['STRING', '"' + flags + '"']);
|
||||
if (flags) {
|
||||
this.tokens.push([',', ','], ['STRING', '"' + flags + '"']);
|
||||
}
|
||||
this.token(')', ')');
|
||||
return heregex.length;
|
||||
};
|
||||
|
||||
Lexer.prototype.lineToken = function() {
|
||||
var diff, indent, match, noNewlines, prev, size;
|
||||
if (!(match = MULTI_DENT.exec(this.chunk))) return 0;
|
||||
var diff, indent, match, noNewlines, size;
|
||||
if (!(match = MULTI_DENT.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
indent = match[0];
|
||||
this.line += count(indent, '\n');
|
||||
this.seenFor = false;
|
||||
prev = last(this.tokens, 1);
|
||||
size = indent.length - 1 - indent.lastIndexOf('\n');
|
||||
noNewlines = this.unfinished();
|
||||
if (size - this.indebt === this.indent) {
|
||||
|
|
@ -342,7 +374,9 @@ define(function(require, exports, module) {
|
|||
this.token('OUTDENT', dent);
|
||||
}
|
||||
}
|
||||
if (dent) this.outdebt -= moveOut;
|
||||
if (dent) {
|
||||
this.outdebt -= moveOut;
|
||||
}
|
||||
while (this.value() === ';') {
|
||||
this.tokens.pop();
|
||||
}
|
||||
|
|
@ -358,7 +392,9 @@ define(function(require, exports, module) {
|
|||
return 0;
|
||||
}
|
||||
prev = last(this.tokens);
|
||||
if (prev) prev[match ? 'spaced' : 'newLine'] = true;
|
||||
if (prev) {
|
||||
prev[match ? 'spaced' : 'newLine'] = true;
|
||||
}
|
||||
if (match) {
|
||||
return match[0].length;
|
||||
} else {
|
||||
|
|
@ -370,12 +406,16 @@ define(function(require, exports, module) {
|
|||
while (this.value() === ';') {
|
||||
this.tokens.pop();
|
||||
}
|
||||
if (this.tag() !== 'TERMINATOR') this.token('TERMINATOR', '\n');
|
||||
if (this.tag() !== 'TERMINATOR') {
|
||||
this.token('TERMINATOR', '\n');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Lexer.prototype.suppressNewlines = function() {
|
||||
if (this.value() === '\\') this.tokens.pop();
|
||||
if (this.value() === '\\') {
|
||||
this.tokens.pop();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
|
@ -383,7 +423,9 @@ define(function(require, exports, module) {
|
|||
var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5;
|
||||
if (match = OPERATOR.exec(this.chunk)) {
|
||||
value = match[0];
|
||||
if (CODE.test(value)) this.tagParameters();
|
||||
if (CODE.test(value)) {
|
||||
this.tagParameters();
|
||||
}
|
||||
} else {
|
||||
value = this.chunk.charAt(0);
|
||||
}
|
||||
|
|
@ -416,7 +458,9 @@ define(function(require, exports, module) {
|
|||
tag = 'LOGIC';
|
||||
} else if (prev && !prev.spaced) {
|
||||
if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) {
|
||||
if (prev[0] === '?') prev[0] = 'FUNC_EXIST';
|
||||
if (prev[0] === '?') {
|
||||
prev[0] = 'FUNC_EXIST';
|
||||
}
|
||||
tag = 'CALL_START';
|
||||
} else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) {
|
||||
tag = 'INDEX_START';
|
||||
|
|
@ -448,7 +492,9 @@ define(function(require, exports, module) {
|
|||
if (HEREDOC_ILLEGAL.test(doc)) {
|
||||
this.error("block comment cannot contain \"*/\", starting");
|
||||
}
|
||||
if (doc.indexOf('\n') <= 0) return doc;
|
||||
if (doc.indexOf('\n') <= 0) {
|
||||
return doc;
|
||||
}
|
||||
} else {
|
||||
while (match = HEREDOC_INDENT.exec(doc)) {
|
||||
attempt = match[1];
|
||||
|
|
@ -457,14 +503,20 @@ define(function(require, exports, module) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (indent) doc = doc.replace(RegExp("\\n" + indent, "g"), '\n');
|
||||
if (!herecomment) doc = doc.replace(/^\n/, '');
|
||||
if (indent) {
|
||||
doc = doc.replace(RegExp("\\n" + indent, "g"), '\n');
|
||||
}
|
||||
if (!herecomment) {
|
||||
doc = doc.replace(/^\n/, '');
|
||||
}
|
||||
return doc;
|
||||
};
|
||||
|
||||
Lexer.prototype.tagParameters = function() {
|
||||
var i, stack, tok, tokens;
|
||||
if (this.tag() !== ')') return this;
|
||||
if (this.tag() !== ')') {
|
||||
return this;
|
||||
}
|
||||
stack = [];
|
||||
tokens = this.tokens;
|
||||
i = tokens.length;
|
||||
|
|
@ -508,7 +560,9 @@ define(function(require, exports, module) {
|
|||
continue;
|
||||
case end:
|
||||
stack.pop();
|
||||
if (!stack.length) return str.slice(0, i + 1 || 9e9);
|
||||
if (!stack.length) {
|
||||
return str.slice(0, +i + 1 || 9e9);
|
||||
}
|
||||
end = stack[stack.length - 1];
|
||||
continue;
|
||||
}
|
||||
|
|
@ -528,7 +582,9 @@ define(function(require, exports, module) {
|
|||
|
||||
Lexer.prototype.interpolateString = function(str, options) {
|
||||
var expr, heredoc, i, inner, interpolated, len, letter, nested, pi, regex, tag, tokens, value, _i, _len, _ref2, _ref3, _ref4;
|
||||
if (options == null) options = {};
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
heredoc = options.heredoc, regex = options.regex;
|
||||
tokens = [];
|
||||
pi = 0;
|
||||
|
|
@ -541,7 +597,9 @@ define(function(require, exports, module) {
|
|||
if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) {
|
||||
continue;
|
||||
}
|
||||
if (pi < i) tokens.push(['NEOSTRING', str.slice(pi, i)]);
|
||||
if (pi < i) {
|
||||
tokens.push(['NEOSTRING', str.slice(pi, i)]);
|
||||
}
|
||||
inner = expr.slice(1, -1);
|
||||
if (inner.length) {
|
||||
nested = new Lexer().tokenize(inner, {
|
||||
|
|
@ -563,28 +621,44 @@ define(function(require, exports, module) {
|
|||
i += expr.length;
|
||||
pi = i + 1;
|
||||
}
|
||||
if ((i > pi && pi < str.length)) tokens.push(['NEOSTRING', str.slice(pi)]);
|
||||
if (regex) return tokens;
|
||||
if (!tokens.length) return this.token('STRING', '""');
|
||||
if (tokens[0][0] !== 'NEOSTRING') tokens.unshift(['', '']);
|
||||
if (interpolated = tokens.length > 1) this.token('(', '(');
|
||||
if ((i > pi && pi < str.length)) {
|
||||
tokens.push(['NEOSTRING', str.slice(pi)]);
|
||||
}
|
||||
if (regex) {
|
||||
return tokens;
|
||||
}
|
||||
if (!tokens.length) {
|
||||
return this.token('STRING', '""');
|
||||
}
|
||||
if (tokens[0][0] !== 'NEOSTRING') {
|
||||
tokens.unshift(['', '']);
|
||||
}
|
||||
if (interpolated = tokens.length > 1) {
|
||||
this.token('(', '(');
|
||||
}
|
||||
for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) {
|
||||
_ref3 = tokens[i], tag = _ref3[0], value = _ref3[1];
|
||||
if (i) this.token('+', '+');
|
||||
if (i) {
|
||||
this.token('+', '+');
|
||||
}
|
||||
if (tag === 'TOKENS') {
|
||||
(_ref4 = this.tokens).push.apply(_ref4, value);
|
||||
} else {
|
||||
this.token('STRING', this.makeString(value, '"', heredoc));
|
||||
}
|
||||
}
|
||||
if (interpolated) this.token(')', ')');
|
||||
if (interpolated) {
|
||||
this.token(')', ')');
|
||||
}
|
||||
return tokens;
|
||||
};
|
||||
|
||||
Lexer.prototype.pair = function(tag) {
|
||||
var size, wanted;
|
||||
if (tag !== (wanted = last(this.ends))) {
|
||||
if ('OUTDENT' !== wanted) this.error("unmatched " + tag);
|
||||
if ('OUTDENT' !== wanted) {
|
||||
this.error("unmatched " + tag);
|
||||
}
|
||||
this.indent -= size = last(this.indents);
|
||||
this.outdentToken(size, true);
|
||||
return this.pair(tag);
|
||||
|
|
@ -616,7 +690,9 @@ define(function(require, exports, module) {
|
|||
};
|
||||
|
||||
Lexer.prototype.makeString = function(body, quote, heredoc) {
|
||||
if (!body) return quote + quote;
|
||||
if (!body) {
|
||||
return quote + quote;
|
||||
}
|
||||
body = body.replace(/\\([\s\S])/g, function(match, contents) {
|
||||
if (contents === '\n' || contents === quote) {
|
||||
return contents;
|
||||
|
|
@ -663,7 +739,7 @@ define(function(require, exports, module) {
|
|||
|
||||
COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat(COFFEE_ALIASES);
|
||||
|
||||
RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'let', 'package', 'private', 'protected', 'public', 'static', 'yield'];
|
||||
RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'yield'];
|
||||
|
||||
STRICT_PROSCRIBED = ['arguments', 'eval'];
|
||||
|
||||
|
|
@ -723,17 +799,17 @@ define(function(require, exports, module) {
|
|||
|
||||
RELATION = ['IN', 'OF', 'INSTANCEOF'];
|
||||
|
||||
BOOL = ['TRUE', 'FALSE', 'NULL', 'UNDEFINED'];
|
||||
BOOL = ['TRUE', 'FALSE'];
|
||||
|
||||
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', '++', '--', ']'];
|
||||
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--', ']'];
|
||||
|
||||
NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING');
|
||||
|
||||
CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER'];
|
||||
|
||||
INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL');
|
||||
INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL', 'NULL', 'UNDEFINED');
|
||||
|
||||
LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR'];
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
/**
|
||||
* Copyright (c) 2009-2012 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
// Generated by CoffeeScript 1.2.1-pre
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
|
||||
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
||||
|
|
@ -32,8 +32,6 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.Rewriter = (function() {
|
||||
|
||||
Rewriter.name = 'Rewriter';
|
||||
|
||||
function Rewriter() {}
|
||||
|
||||
Rewriter.prototype.rewrite = function(tokens) {
|
||||
|
|
@ -67,7 +65,9 @@ define(function(require, exports, module) {
|
|||
if (levels === 0 && condition.call(this, token, i)) {
|
||||
return action.call(this, token, i);
|
||||
}
|
||||
if (!token || levels < 0) return action.call(this, token, i - 1);
|
||||
if (!token || levels < 0) {
|
||||
return action.call(this, token, i - 1);
|
||||
}
|
||||
if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
||||
levels += 1;
|
||||
} else if (_ref1 = token[0], __indexOf.call(EXPRESSION_END, _ref1) >= 0) {
|
||||
|
|
@ -83,9 +83,13 @@ define(function(require, exports, module) {
|
|||
_ref = this.tokens;
|
||||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
||||
tag = _ref[i][0];
|
||||
if (tag !== 'TERMINATOR') break;
|
||||
if (tag !== 'TERMINATOR') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i) {
|
||||
return this.tokens.splice(0, i);
|
||||
}
|
||||
if (i) return this.tokens.splice(0, i);
|
||||
};
|
||||
|
||||
Rewriter.prototype.removeMidExpressionNewlines = function() {
|
||||
|
|
@ -109,7 +113,9 @@ define(function(require, exports, module) {
|
|||
return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END';
|
||||
};
|
||||
return this.scanTokens(function(token, i) {
|
||||
if (token[0] === 'CALL_START') this.detectEnd(i + 1, condition, action);
|
||||
if (token[0] === 'CALL_START') {
|
||||
this.detectEnd(i + 1, condition, action);
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
};
|
||||
|
|
@ -124,25 +130,32 @@ define(function(require, exports, module) {
|
|||
return token[0] = 'INDEX_END';
|
||||
};
|
||||
return this.scanTokens(function(token, i) {
|
||||
if (token[0] === 'INDEX_START') this.detectEnd(i + 1, condition, action);
|
||||
if (token[0] === 'INDEX_START') {
|
||||
this.detectEnd(i + 1, condition, action);
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
};
|
||||
|
||||
Rewriter.prototype.addImplicitBraces = function() {
|
||||
var action, condition, sameLine, stack, start, startIndent, startsLine;
|
||||
var action, condition, sameLine, stack, start, startIndent, startIndex, startsLine;
|
||||
stack = [];
|
||||
start = null;
|
||||
startsLine = null;
|
||||
sameLine = true;
|
||||
startIndent = 0;
|
||||
startIndex = 0;
|
||||
condition = function(token, i) {
|
||||
var one, tag, three, two, _ref, _ref1;
|
||||
_ref = this.tokens.slice(i + 1, (i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
|
||||
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) return false;
|
||||
_ref = this.tokens.slice(i + 1, +(i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
|
||||
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
|
||||
return false;
|
||||
}
|
||||
tag = token[0];
|
||||
if (__indexOf.call(LINEBREAKS, tag) >= 0) sameLine = false;
|
||||
return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine)) && ((!startsLine && this.tag(i - 1) !== ',') || !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':'))) || (tag === ',' && one && ((_ref1 = one[0]) !== 'IDENTIFIER' && _ref1 !== 'NUMBER' && _ref1 !== 'STRING' && _ref1 !== '@' && _ref1 !== 'TERMINATOR' && _ref1 !== 'OUTDENT'));
|
||||
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
|
||||
sameLine = false;
|
||||
}
|
||||
return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine && !(i - startIndex === 1))) && ((!startsLine && this.tag(i - 1) !== ',') || !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':'))) || (tag === ',' && one && ((_ref1 = one[0]) !== 'IDENTIFIER' && _ref1 !== 'NUMBER' && _ref1 !== 'STRING' && _ref1 !== '@' && _ref1 !== 'TERMINATOR' && _ref1 !== 'OUTDENT'));
|
||||
};
|
||||
action = function(token, i) {
|
||||
var tok;
|
||||
|
|
@ -163,6 +176,7 @@ define(function(require, exports, module) {
|
|||
return 1;
|
||||
}
|
||||
sameLine = true;
|
||||
startIndex = i + 1;
|
||||
stack.push(['{']);
|
||||
idx = ago === '@' ? i - 2 : i - 1;
|
||||
while (this.tag(idx - 2) === 'HERECOMMENT') {
|
||||
|
|
@ -185,7 +199,9 @@ define(function(require, exports, module) {
|
|||
condition = function(token, i) {
|
||||
var post, tag, _ref, _ref1;
|
||||
tag = token[0];
|
||||
if (!seenSingle && token.fromThen) return true;
|
||||
if (!seenSingle && token.fromThen) {
|
||||
return true;
|
||||
}
|
||||
if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>' || tag === 'CLASS') {
|
||||
seenSingle = true;
|
||||
}
|
||||
|
|
@ -206,19 +222,27 @@ define(function(require, exports, module) {
|
|||
if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR' || tag === 'WHILE') {
|
||||
noCall = true;
|
||||
}
|
||||
_ref = tokens.slice(i - 1, (i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
||||
_ref = tokens.slice(i - 1, +(i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
||||
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref1 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref1) >= 0);
|
||||
seenSingle = false;
|
||||
seenControl = false;
|
||||
if (__indexOf.call(LINEBREAKS, tag) >= 0) noCall = false;
|
||||
if (prev && !prev.spaced && tag === '?') token.call = true;
|
||||
if (token.fromThen) return 1;
|
||||
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
|
||||
noCall = false;
|
||||
}
|
||||
if (prev && !prev.spaced && tag === '?') {
|
||||
token.call = true;
|
||||
}
|
||||
if (token.fromThen) {
|
||||
return 1;
|
||||
}
|
||||
if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) {
|
||||
return 1;
|
||||
}
|
||||
tokens.splice(i, 0, this.generate('CALL_START', '(', token[2]));
|
||||
this.detectEnd(i + 1, condition, action);
|
||||
if (prev[0] === '?') prev[0] = 'FUNC_EXIST';
|
||||
if (prev[0] === '?') {
|
||||
prev[0] = 'FUNC_EXIST';
|
||||
}
|
||||
return 2;
|
||||
});
|
||||
};
|
||||
|
|
@ -251,10 +275,14 @@ define(function(require, exports, module) {
|
|||
if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) {
|
||||
starter = tag;
|
||||
_ref1 = this.indentation(token, true), indent = _ref1[0], outdent = _ref1[1];
|
||||
if (starter === 'THEN') indent.fromThen = true;
|
||||
if (starter === 'THEN') {
|
||||
indent.fromThen = true;
|
||||
}
|
||||
tokens.splice(i + 1, 0, indent);
|
||||
this.detectEnd(i + 2, condition, action);
|
||||
if (tag === 'THEN') tokens.splice(i, 1);
|
||||
if (tag === 'THEN') {
|
||||
tokens.splice(i, 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
|
|
@ -274,7 +302,9 @@ define(function(require, exports, module) {
|
|||
}
|
||||
};
|
||||
return this.scanTokens(function(token, i) {
|
||||
if (token[0] !== 'IF') return 1;
|
||||
if (token[0] !== 'IF') {
|
||||
return 1;
|
||||
}
|
||||
original = token;
|
||||
this.detectEnd(i + 1, condition, action);
|
||||
return 1;
|
||||
|
|
@ -283,10 +313,14 @@ define(function(require, exports, module) {
|
|||
|
||||
Rewriter.prototype.indentation = function(token, implicit) {
|
||||
var indent, outdent;
|
||||
if (implicit == null) implicit = false;
|
||||
if (implicit == null) {
|
||||
implicit = false;
|
||||
}
|
||||
indent = ['INDENT', 2, token[2]];
|
||||
outdent = ['OUTDENT', 2, token[2]];
|
||||
if (implicit) indent.generated = outdent.generated = true;
|
||||
if (implicit) {
|
||||
indent.generated = outdent.generated = true;
|
||||
}
|
||||
return [indent, outdent];
|
||||
};
|
||||
|
||||
|
|
@ -324,7 +358,7 @@ define(function(require, exports, module) {
|
|||
|
||||
IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS'];
|
||||
|
||||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++'];
|
||||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++'];
|
||||
|
||||
IMPLICIT_UNSPACED_CALL = ['+', '-'];
|
||||
|
||||
|
|
@ -339,4 +373,4 @@ define(function(require, exports, module) {
|
|||
LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT'];
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
/**
|
||||
* Copyright (c) 2009-2012 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
// Generated by CoffeeScript 1.2.1-pre
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
|
||||
var Scope, extend, last, _ref;
|
||||
|
||||
|
|
@ -32,8 +32,6 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.Scope = Scope = (function() {
|
||||
|
||||
Scope.name = 'Scope';
|
||||
|
||||
Scope.root = null;
|
||||
|
||||
function Scope(parent, expressions, method) {
|
||||
|
|
@ -47,11 +45,15 @@ define(function(require, exports, module) {
|
|||
}
|
||||
];
|
||||
this.positions = {};
|
||||
if (!this.parent) Scope.root = this;
|
||||
if (!this.parent) {
|
||||
Scope.root = this;
|
||||
}
|
||||
}
|
||||
|
||||
Scope.prototype.add = function(name, type, immediate) {
|
||||
if (this.shared && !immediate) return this.parent.add(name, type, immediate);
|
||||
if (this.shared && !immediate) {
|
||||
return this.parent.add(name, type, immediate);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(this.positions, name)) {
|
||||
return this.variables[this.positions[name]].type = type;
|
||||
} else {
|
||||
|
|
@ -62,22 +64,31 @@ define(function(require, exports, module) {
|
|||
}
|
||||
};
|
||||
|
||||
Scope.prototype.find = function(name, options) {
|
||||
if (this.check(name, options)) return true;
|
||||
Scope.prototype.namedMethod = function() {
|
||||
if (this.method.name || !this.parent) {
|
||||
return this.method;
|
||||
}
|
||||
return this.parent.namedMethod();
|
||||
};
|
||||
|
||||
Scope.prototype.find = function(name) {
|
||||
if (this.check(name)) {
|
||||
return true;
|
||||
}
|
||||
this.add(name, 'var');
|
||||
return false;
|
||||
};
|
||||
|
||||
Scope.prototype.parameter = function(name) {
|
||||
if (this.shared && this.parent.check(name, true)) return;
|
||||
if (this.shared && this.parent.check(name, true)) {
|
||||
return;
|
||||
}
|
||||
return this.add(name, 'param');
|
||||
};
|
||||
|
||||
Scope.prototype.check = function(name, immediate) {
|
||||
var found, _ref1;
|
||||
found = !!this.type(name);
|
||||
if (found || immediate) return found;
|
||||
return !!((_ref1 = this.parent) != null ? _ref1.check(name) : void 0);
|
||||
Scope.prototype.check = function(name) {
|
||||
var _ref1;
|
||||
return !!(this.type(name) || ((_ref1 = this.parent) != null ? _ref1.check(name) : void 0));
|
||||
};
|
||||
|
||||
Scope.prototype.temporary = function(name, index) {
|
||||
|
|
@ -93,19 +104,25 @@ define(function(require, exports, module) {
|
|||
_ref1 = this.variables;
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
v = _ref1[_i];
|
||||
if (v.name === name) return v.type;
|
||||
if (v.name === name) {
|
||||
return v.type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Scope.prototype.freeVariable = function(name, reserve) {
|
||||
var index, temp;
|
||||
if (reserve == null) reserve = true;
|
||||
if (reserve == null) {
|
||||
reserve = true;
|
||||
}
|
||||
index = 0;
|
||||
while (this.check((temp = this.temporary(name, index)))) {
|
||||
index++;
|
||||
}
|
||||
if (reserve) this.add(temp, 'var', true);
|
||||
if (reserve) {
|
||||
this.add(temp, 'var', true);
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
|
|
@ -141,7 +158,9 @@ define(function(require, exports, module) {
|
|||
_results = [];
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
v = _ref1[_i];
|
||||
if (v.type.assigned) _results.push("" + v.name + " = " + v.type.value);
|
||||
if (v.type.assigned) {
|
||||
_results.push("" + v.name + " = " + v.type.value);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
|
@ -151,4 +170,4 @@ define(function(require, exports, module) {
|
|||
})();
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
@ -143,7 +143,7 @@ define(function(require, exports, module) {
|
|||
next : "heregex"
|
||||
}, {
|
||||
token : "string.regex",
|
||||
regex : "/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)"
|
||||
regex : /(?:\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)(?:[imgy]{0,4})(?!\w)/
|
||||
}, {
|
||||
token : "comment",
|
||||
merge : true,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,13 @@ module.exports = {
|
|||
assert.equal(tokens.length, 1);
|
||||
assert.equal(tokens[0].type, "keyword");
|
||||
},
|
||||
|
||||
|
||||
"test: tokenize regexp": function() {
|
||||
var tokens = this.tokenizer.getLineTokens('/"[a]/', "start").tokens;
|
||||
assert.equal(tokens.length, 1);
|
||||
assert.equal(tokens[0].type, "string.regex");
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo = ({args}) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo = ({args}) ->", "start").tokens;
|
||||
var correct = [
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ var ColdfusionHighlightRules = function() {
|
|||
next : "comment"
|
||||
}, {
|
||||
token : "meta.tag",
|
||||
regex : "<(?=\s*script)",
|
||||
regex : "<(?=script)",
|
||||
next : "script"
|
||||
}, {
|
||||
token : "meta.tag",
|
||||
regex : "<(?=\s*style)",
|
||||
regex : "<(?=style)",
|
||||
next : "style"
|
||||
}, {
|
||||
token : "meta.tag", // opening tag
|
||||
|
|
|
|||
|
|
@ -74,25 +74,19 @@ oop.inherits(Mode, TextMode);
|
|||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
|
||||
this.createWorker = function(session) {
|
||||
var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
|
||||
worker.attachToDocument(session.getDocument());
|
||||
|
||||
|
||||
worker.on("csslint", function(e) {
|
||||
var errors = [];
|
||||
e.data.forEach(function(message) {
|
||||
errors.push({
|
||||
row: message.line - 1,
|
||||
column: message.col - 1,
|
||||
text: message.message,
|
||||
type: message.type,
|
||||
lint: message
|
||||
});
|
||||
});
|
||||
|
||||
session.setAnnotations(errors);
|
||||
session.setAnnotations(e.data);
|
||||
});
|
||||
|
||||
worker.on("terminate", function() {
|
||||
session.clearAnnotations();
|
||||
});
|
||||
|
||||
return worker;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
/* Build time: 2-March-2012 02:47:11 */
|
||||
/* Build time: 14-May-2012 10:24:48 */
|
||||
|
||||
/*!
|
||||
Parser-Lib
|
||||
|
|
@ -47,7 +47,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
/* Version v0.1.6, Build time: 2-March-2012 02:44:32 */
|
||||
/* Version v0.1.7, Build time: 4-May-2012 03:57:04 */
|
||||
var parserlib = {};
|
||||
(function(){
|
||||
|
||||
|
|
@ -957,7 +957,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
/* Version v0.1.6, Build time: 2-March-2012 02:44:32 */
|
||||
/* Version v0.1.7, Build time: 4-May-2012 03:57:04 */
|
||||
(function(){
|
||||
var EventTarget = parserlib.util.EventTarget,
|
||||
TokenStreamBase = parserlib.util.TokenStreamBase,
|
||||
|
|
@ -2171,7 +2171,7 @@ Parser.prototype = function(){
|
|||
|
||||
//there must be a next selector
|
||||
if (nextSelector === null){
|
||||
this._unexpectedToken(this.LT(1));
|
||||
this._unexpectedToken(tokenStream.LT(1));
|
||||
} else {
|
||||
|
||||
//nextSelector is an instance of SelectorPart
|
||||
|
|
@ -2666,7 +2666,8 @@ Parser.prototype = function(){
|
|||
expr = null,
|
||||
prio = null,
|
||||
error = null,
|
||||
invalid = null;
|
||||
invalid = null,
|
||||
propertyName= "";
|
||||
|
||||
property = this._property();
|
||||
if (property !== null){
|
||||
|
|
@ -2683,8 +2684,20 @@ Parser.prototype = function(){
|
|||
|
||||
prio = this._prio();
|
||||
|
||||
/*
|
||||
* If hacks should be allowed, then only check the root
|
||||
* property. If hacks should not be allowed, treat
|
||||
* _property or *property as invalid properties.
|
||||
*/
|
||||
propertyName = property.toString();
|
||||
if (this.options.starHack && property.hack == "*" ||
|
||||
this.options.underscoreHack && property.hack == "_") {
|
||||
|
||||
propertyName = property.text;
|
||||
}
|
||||
|
||||
try {
|
||||
this._validateProperty(property, expr);
|
||||
this._validateProperty(propertyName, expr);
|
||||
} catch (ex) {
|
||||
invalid = ex;
|
||||
}
|
||||
|
|
@ -3525,6 +3538,7 @@ var Properties = {
|
|||
"background-repeat" : { multi: "<repeat-style>" },
|
||||
"background-size" : { multi: "<bg-size>", comma: true },
|
||||
"baseline-shift" : "baseline | sub | super | <percentage> | <length>",
|
||||
"behavior" : 1,
|
||||
"binding" : 1,
|
||||
"bleed" : "<length>",
|
||||
"bookmark-label" : "<content> | <attr> | <string>",
|
||||
|
|
@ -3871,6 +3885,7 @@ var Properties = {
|
|||
"text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
|
||||
"text-outline" : 1,
|
||||
"text-overflow" : 1,
|
||||
"text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit",
|
||||
"text-shadow" : 1,
|
||||
"text-transform" : "capitalize | uppercase | lowercase | none | inherit",
|
||||
"text-wrap" : "normal | none | avoid",
|
||||
|
|
@ -5950,7 +5965,7 @@ var ValidationTypes = {
|
|||
i, len, found = false;
|
||||
|
||||
for (i=0,len=args.length; i < len && !found; i++){
|
||||
if (text == args[i]){
|
||||
if (text == args[i].toLowerCase()){
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -6042,7 +6057,7 @@ var ValidationTypes = {
|
|||
},
|
||||
|
||||
"<gradient>": function(part) {
|
||||
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial|linear)\-gradient/i.test(part);
|
||||
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
|
||||
},
|
||||
|
||||
"<box>": function(part){
|
||||
|
|
@ -6134,6 +6149,18 @@ var ValidationTypes = {
|
|||
part,
|
||||
i, len;
|
||||
|
||||
/*
|
||||
<position> = [
|
||||
[ left | center | right | top | bottom | <percentage> | <length> ]
|
||||
|
|
||||
[ left | center | right | <percentage> | <length> ]
|
||||
[ top | center | bottom | <percentage> | <length> ]
|
||||
|
|
||||
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
|
||||
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
|
||||
]
|
||||
|
||||
*/
|
||||
|
||||
if (ValidationTypes.isAny(expression, "top | bottom")) {
|
||||
result = true;
|
||||
|
|
@ -6306,7 +6333,7 @@ var CSSLint = (function(){
|
|||
formatters = [],
|
||||
api = new parserlib.util.EventTarget();
|
||||
|
||||
api.version = "0.9.7";
|
||||
api.version = "0.9.8";
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Rule Management
|
||||
|
|
@ -7633,7 +7660,7 @@ CSSLint.addRule({
|
|||
parser.addListener("endstylesheet", function(){
|
||||
reporter.stat("important", count);
|
||||
if (count >= 10){
|
||||
reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specifity issues.", rule);
|
||||
reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -8290,8 +8317,35 @@ CSSLint.addRule({
|
|||
|
||||
});
|
||||
/*
|
||||
* Rule: Don't use text-indent for image replacement if you need to support rtl.
|
||||
*
|
||||
* Rule: Don't use properties with a star prefix.
|
||||
*
|
||||
*/
|
||||
/*global CSSLint*/
|
||||
CSSLint.addRule({
|
||||
|
||||
//rule information
|
||||
id: "star-property-hack",
|
||||
name: "Disallow properties with a star prefix",
|
||||
desc: "Checks for the star property hack (targets IE6/7)",
|
||||
browsers: "All",
|
||||
|
||||
//initialization
|
||||
init: function(parser, reporter){
|
||||
var rule = this;
|
||||
|
||||
//check if property name starts with "*"
|
||||
parser.addListener("property", function(event){
|
||||
var property = event.property;
|
||||
|
||||
if (property.hack == "*") {
|
||||
reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
/*
|
||||
* Rule: Don't use text-indent for image replacement if you need to support rtl.
|
||||
*
|
||||
*/
|
||||
/*global CSSLint*/
|
||||
CSSLint.addRule({
|
||||
|
|
@ -8301,27 +8355,29 @@ CSSLint.addRule({
|
|||
name: "Disallow negative text-indent",
|
||||
desc: "Checks for text indent less than -99px",
|
||||
browsers: "All",
|
||||
|
||||
|
||||
//initialization
|
||||
init: function(parser, reporter){
|
||||
var rule = this,
|
||||
textIndent = false;
|
||||
|
||||
|
||||
textIndent,
|
||||
direction;
|
||||
|
||||
|
||||
function startRule(event){
|
||||
textIndent = false;
|
||||
direction = "inherit";
|
||||
}
|
||||
|
||||
|
||||
//event handler for end of rules
|
||||
function endRule(event){
|
||||
if (textIndent){
|
||||
if (textIndent && direction != "ltr"){
|
||||
reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
parser.addListener("startrule", startRule);
|
||||
parser.addListener("startfontface", startRule);
|
||||
|
||||
|
||||
//check for use of "font-size"
|
||||
parser.addListener("property", function(event){
|
||||
var name = event.property.toString().toLowerCase(),
|
||||
|
|
@ -8330,16 +8386,43 @@ CSSLint.addRule({
|
|||
if (name == "text-indent" && value.parts[0].value < -99){
|
||||
textIndent = event.property;
|
||||
} else if (name == "direction" && value == "ltr"){
|
||||
textIndent = false;
|
||||
direction = "ltr";
|
||||
}
|
||||
});
|
||||
|
||||
parser.addListener("endrule", endRule);
|
||||
parser.addListener("endfontface", endRule);
|
||||
parser.addListener("endfontface", endRule);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
/*
|
||||
* Rule: Don't use properties with a underscore prefix.
|
||||
*
|
||||
*/
|
||||
/*global CSSLint*/
|
||||
CSSLint.addRule({
|
||||
|
||||
//rule information
|
||||
id: "underscore-property-hack",
|
||||
name: "Disallow properties with an underscore prefix",
|
||||
desc: "Checks for the underscore property hack (targets IE6)",
|
||||
browsers: "All",
|
||||
|
||||
//initialization
|
||||
init: function(parser, reporter){
|
||||
var rule = this;
|
||||
|
||||
//check if property name starts with "_"
|
||||
parser.addListener("property", function(event){
|
||||
var property = event.property;
|
||||
|
||||
if (property.hack == "_") {
|
||||
reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
/*
|
||||
* Rule: Headings (h1-h6) should be defined only once.
|
||||
*/
|
||||
|
|
@ -8669,343 +8752,6 @@ CSSLint.addRule({
|
|||
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "checkstyle-xml",
|
||||
name: "Checkstyle XML format",
|
||||
|
||||
/**
|
||||
* Return opening root XML tag.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function(){
|
||||
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return closing root XML tag.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function(){
|
||||
return "</checkstyle>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (UNUSED for now) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = [];
|
||||
|
||||
/**
|
||||
* Generate a source string for a rule.
|
||||
* Checkstyle source strings usually resemble Java class names e.g
|
||||
* net.csslint.SomeRuleName
|
||||
* @param {Object} rule
|
||||
* @return rule source as {String}
|
||||
*/
|
||||
var generateSource = function(rule) {
|
||||
if (!rule || !('name' in rule)) {
|
||||
return "";
|
||||
}
|
||||
return 'net.csslint.' + rule.name.replace(/\s/g,'');
|
||||
};
|
||||
|
||||
/**
|
||||
* Replace special characters before write to output.
|
||||
*
|
||||
* Rules:
|
||||
* - single quotes is the escape sequence for double-quotes
|
||||
* - < is the escape sequence for <
|
||||
* - > is the escape sequence for >
|
||||
*
|
||||
* @param {String} message to escape
|
||||
* @return escaped message as {String}
|
||||
*/
|
||||
var escapeSpecialCharacters = function(str) {
|
||||
if (!str || str.constructor !== String) {
|
||||
return "";
|
||||
}
|
||||
return str.replace(/\"/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
||||
};
|
||||
|
||||
if (messages.length > 0) {
|
||||
output.push("<file name=\""+filename+"\">");
|
||||
CSSLint.Util.forEach(messages, function (message, i) {
|
||||
//ignore rollups for now
|
||||
if (!message.rollup) {
|
||||
output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
|
||||
" message=\"" + escapeSpecialCharacters(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
|
||||
}
|
||||
});
|
||||
output.push("</file>");
|
||||
}
|
||||
|
||||
return output.join("");
|
||||
}
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "compact",
|
||||
name: "Compact, 'porcelain' format",
|
||||
|
||||
/**
|
||||
* Return content to be printed before all file results.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return content to be printed after all file results.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (Optional) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = "";
|
||||
options = options || {};
|
||||
|
||||
/**
|
||||
* Capitalize and return given string.
|
||||
* @param str {String} to capitalize
|
||||
* @return {String} capitalized
|
||||
*/
|
||||
var capitalize = function(str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
};
|
||||
|
||||
if (messages.length === 0) {
|
||||
return options.quiet ? "" : filename + ": Lint Free!";
|
||||
}
|
||||
|
||||
CSSLint.Util.forEach(messages, function(message, i) {
|
||||
if (message.rollup) {
|
||||
output += filename + ": " + capitalize(message.type) + " - " + message.message + "\n";
|
||||
} else {
|
||||
output += filename + ": " + "line " + message.line +
|
||||
", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + "\n";
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "csslint-xml",
|
||||
name: "CSSLint XML format",
|
||||
|
||||
/**
|
||||
* Return opening root XML tag.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function(){
|
||||
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return closing root XML tag.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function(){
|
||||
return "</csslint>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (UNUSED for now) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = [];
|
||||
|
||||
/**
|
||||
* Replace special characters before write to output.
|
||||
*
|
||||
* Rules:
|
||||
* - single quotes is the escape sequence for double-quotes
|
||||
* - < is the escape sequence for <
|
||||
* - > is the escape sequence for >
|
||||
*
|
||||
* @param {String} message to escape
|
||||
* @return escaped message as {String}
|
||||
*/
|
||||
var escapeSpecialCharacters = function(str) {
|
||||
if (!str || str.constructor !== String) {
|
||||
return "";
|
||||
}
|
||||
return str.replace(/\"/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
||||
};
|
||||
|
||||
if (messages.length > 0) {
|
||||
output.push("<file name=\""+filename+"\">");
|
||||
CSSLint.Util.forEach(messages, function (message, i) {
|
||||
if (message.rollup) {
|
||||
output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
||||
} else {
|
||||
output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
|
||||
" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
||||
}
|
||||
});
|
||||
output.push("</file>");
|
||||
}
|
||||
|
||||
return output.join("");
|
||||
}
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "lint-xml",
|
||||
name: "Lint XML format",
|
||||
|
||||
/**
|
||||
* Return opening root XML tag.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function(){
|
||||
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return closing root XML tag.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function(){
|
||||
return "</lint>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (UNUSED for now) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = [];
|
||||
|
||||
/**
|
||||
* Replace special characters before write to output.
|
||||
*
|
||||
* Rules:
|
||||
* - single quotes is the escape sequence for double-quotes
|
||||
* - < is the escape sequence for <
|
||||
* - > is the escape sequence for >
|
||||
*
|
||||
* @param {String} message to escape
|
||||
* @return escaped message as {String}
|
||||
*/
|
||||
var escapeSpecialCharacters = function(str) {
|
||||
if (!str || str.constructor !== String) {
|
||||
return "";
|
||||
}
|
||||
return str.replace(/\"/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
||||
};
|
||||
|
||||
if (messages.length > 0) {
|
||||
|
||||
output.push("<file name=\""+filename+"\">");
|
||||
CSSLint.Util.forEach(messages, function (message, i) {
|
||||
if (message.rollup) {
|
||||
output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
||||
} else {
|
||||
output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
|
||||
" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
||||
}
|
||||
});
|
||||
output.push("</file>");
|
||||
}
|
||||
|
||||
return output.join("");
|
||||
}
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "text",
|
||||
name: "Plain Text",
|
||||
|
||||
/**
|
||||
* Return content to be printed before all file results.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return content to be printed after all file results.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (Optional) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = "";
|
||||
options = options || {};
|
||||
|
||||
if (messages.length === 0) {
|
||||
return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
|
||||
}
|
||||
|
||||
output = "\n\ncsslint: There are " + messages.length + " problems in " + filename + ".";
|
||||
var pos = filename.lastIndexOf("/"),
|
||||
shortFilename = filename;
|
||||
|
||||
if (pos === -1){
|
||||
pos = filename.lastIndexOf("\\");
|
||||
}
|
||||
if (pos > -1){
|
||||
shortFilename = filename.substring(pos+1);
|
||||
}
|
||||
|
||||
CSSLint.Util.forEach(messages, function (message, i) {
|
||||
output = output + "\n\n" + shortFilename;
|
||||
if (message.rollup) {
|
||||
output += "\n" + (i+1) + ": " + message.type;
|
||||
output += "\n" + message.message;
|
||||
} else {
|
||||
output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col;
|
||||
output += "\n" + message.message;
|
||||
output += "\n" + message.evidence;
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
exports.CSSLint = CSSLint;
|
||||
|
|
|
|||
|
|
@ -27,33 +27,68 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var Mirror = require("../worker/mirror").Mirror;
|
||||
var CSSLint = require("./css/csslint").CSSLint;
|
||||
|
||||
var Worker = exports.Worker = function(sender) {
|
||||
Mirror.call(this, sender);
|
||||
this.setTimeout(200);
|
||||
this.setTimeout(400);
|
||||
this.ruleset = null;
|
||||
this.setDisabledRules("");
|
||||
this.setInfoRules("adjoining-classes|qualified-headings|zero-units|gradients|import|outline-none");
|
||||
};
|
||||
|
||||
oop.inherits(Worker, Mirror);
|
||||
|
||||
(function() {
|
||||
|
||||
this.setInfoRules = function(ruleNames) {
|
||||
if (typeof ruleNames == "string")
|
||||
ruleNames = ruleNames.split("|");
|
||||
this.infoRules = lang.arrayToMap(ruleNames);
|
||||
this.doc.getValue() && this.deferredUpdate.schedule(100);
|
||||
};
|
||||
|
||||
this.setDisabledRules = function(ruleNames) {
|
||||
if (!ruleNames) {
|
||||
this.ruleset = null;
|
||||
} else {
|
||||
if (typeof ruleNames == "string")
|
||||
ruleNames = ruleNames.split("|");
|
||||
var all = {};
|
||||
|
||||
CSSLint.getRules().forEach(function(x){
|
||||
all[x.id] = true;
|
||||
});
|
||||
ruleNames.forEach(function(x) {
|
||||
delete all[x];
|
||||
});
|
||||
console.log(all)
|
||||
this.ruleset = all;
|
||||
}
|
||||
this.doc.getValue() && this.deferredUpdate.schedule(100);
|
||||
};
|
||||
|
||||
this.onUpdate = function() {
|
||||
var value = this.doc.getValue();
|
||||
|
||||
var result = CSSLint.verify(value);
|
||||
var infoRules = this.infoRules;
|
||||
|
||||
var result = CSSLint.verify(value, this.ruleset);
|
||||
this.sender.emit("csslint", result.messages.map(function(msg) {
|
||||
delete msg.rule;
|
||||
return msg;
|
||||
return {
|
||||
row: msg.line - 1,
|
||||
column: msg.col - 1,
|
||||
text: msg.message,
|
||||
type: infoRules[msg.rule.id] ? "info" : msg.type
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
}).call(Worker.prototype);
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@ var DiffHighlightRules = function() {
|
|||
"support.constant",
|
||||
"text",
|
||||
"invalid"
|
||||
],
|
||||
]
|
||||
}, { // removed
|
||||
"regex": "^([<\\-])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.function",
|
||||
"string",
|
||||
"invalid"
|
||||
],
|
||||
]
|
||||
}, {
|
||||
"regex": "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
|
||||
"token": ["variable", "variable", "keyword", "variable"]
|
||||
|
|
|
|||
142
lib/ace/mode/folding/asciidoc.js
Normal file
142
lib/ace/mode/folding/asciidoc.js
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../../lib/oop");
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
var Range = require("../../range").Range;
|
||||
|
||||
var FoldMode = exports.FoldMode = function() {};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
this.foldingStartMarker = /^(?:\|={10,}|[\.\/=\-~^+]{4,}|={1,5} )/;
|
||||
this.singleLineHeadingRe = /^={1,5}(?=\s+\S)/;
|
||||
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
if (!this.foldingStartMarker.test(line))
|
||||
return ""
|
||||
|
||||
if (line[0] == "=") {
|
||||
if (this.singleLineHeadingRe.test(line))
|
||||
return "start";
|
||||
if (session.getLine(row - 1).length != session.getLine(row).length)
|
||||
return "";
|
||||
return "start";
|
||||
}
|
||||
if (session.bgTokenizer.getState(row) == "dissallowDelimitedBlock")
|
||||
return "end";
|
||||
return "start";
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
var startColumn = line.length;
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
if (!line.match(this.foldingStartMarker))
|
||||
return;
|
||||
|
||||
var token;
|
||||
function getTokenType(row) {
|
||||
token = session.getTokens(row)[0];
|
||||
return token && token.type;
|
||||
}
|
||||
|
||||
var levels = ["=","-","~","^","+"];
|
||||
var heading = "markup.heading";
|
||||
var singleLineHeadingRe = this.singleLineHeadingRe;
|
||||
function getLevel() {
|
||||
var match = token.value.match(singleLineHeadingRe);
|
||||
if (match)
|
||||
return match[0].length;
|
||||
var level = levels.indexOf(token.value[0]) + 1;
|
||||
if (level == 1) {
|
||||
if (session.getLine(row - 1).length != session.getLine(row).length)
|
||||
return Infinity;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
if (getTokenType(row) == heading) {
|
||||
var startHeadingLevel = getLevel();
|
||||
while (++row < maxRow) {
|
||||
if (getTokenType(row) != heading)
|
||||
continue;
|
||||
var level = getLevel();
|
||||
if (level <= startHeadingLevel)
|
||||
break;
|
||||
}
|
||||
|
||||
var isSingleLineHeading = token && token.value.match(this.singleLineHeadingRe);
|
||||
endRow = isSingleLineHeading ? row - 1 : row - 2;
|
||||
|
||||
if (endRow > startRow) {
|
||||
while (endRow > startRow && (!getTokenType(endRow) || token.value[0] == "["))
|
||||
endRow--;
|
||||
}
|
||||
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(endRow).length;
|
||||
return new Range(startRow, startColumn, endRow, endColumn);
|
||||
}
|
||||
} else {
|
||||
var state = session.bgTokenizer.getState(row);
|
||||
if (state == "dissallowDelimitedBlock") {
|
||||
while (row -- > 0) {
|
||||
if (session.bgTokenizer.getState(row).lastIndexOf("Block") == -1)
|
||||
break;
|
||||
}
|
||||
endRow = row + 1;
|
||||
if (endRow < startRow) {
|
||||
var endColumn = session.getLine(row).length;
|
||||
return new Range(endRow, 5, startRow, startColumn - 5);
|
||||
}
|
||||
} else {
|
||||
while (++row < maxRow) {
|
||||
if (session.bgTokenizer.getState(row) == "dissallowDelimitedBlock")
|
||||
break;
|
||||
}
|
||||
endRow = row;
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(row).length;
|
||||
return new Range(startRow, 5, endRow, endColumn - 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
|
@ -47,7 +47,7 @@ module.exports = {
|
|||
']',
|
||||
'[ ',
|
||||
'{ ',
|
||||
'[ #-',
|
||||
'[ #-'
|
||||
]);
|
||||
|
||||
var mode = new PythonMode();
|
||||
|
|
|
|||
|
|
@ -80,11 +80,11 @@ var HtmlHighlightRules = function() {
|
|||
regex : "<\\!.*?>"
|
||||
}, {
|
||||
token : "meta.tag",
|
||||
regex : "<(?=\s*script\\b)",
|
||||
regex : "<(?=script\\b)",
|
||||
next : "script"
|
||||
}, {
|
||||
token : "meta.tag",
|
||||
regex : "<(?=\s*style\\b)",
|
||||
regex : "<(?=style\\b)",
|
||||
next : "style"
|
||||
}, {
|
||||
token : "meta.tag", // opening tag
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ var oop = require("../lib/oop");
|
|||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var JadeHighlightRules = require("./jade_highlight_rules").JadeHighlightRules;
|
||||
// var JavascriptMode = require("ace/mode/javascript").Mode;
|
||||
// var CssMode = require("ace/mode/css").Mode;
|
||||
// var JavascriptMode = require("../mode/javascript").Mode;
|
||||
// var CssMode = require("../mode/css").Mode;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new JadeHighlightRules();
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ var JadeHighlightRules = function() {
|
|||
},
|
||||
{
|
||||
"token" : "punctuation.section.comment",
|
||||
"regex" : "^\\s*\/\/(?:\\s*[^-\\s]|\\s+\\S)(?:.*$)",
|
||||
"regex" : "^\\s*\/\/(?:\\s*[^-\\s]|\\s+\\S)(?:.*$)"
|
||||
},
|
||||
{
|
||||
"token" : function(space, text) {
|
||||
|
|
@ -120,11 +120,11 @@ var JadeHighlightRules = function() {
|
|||
"token": [ "storage.type.function.jade", "entity.name.function.jade"],
|
||||
"regex": "^(\\s*mixin)( [\\w\\-]+)"
|
||||
},
|
||||
/* {
|
||||
{
|
||||
"token": "source.js.embedded.jade",
|
||||
"regex": "^\\s*-|=|!=",
|
||||
"next": "js_code"
|
||||
},*/
|
||||
"regex": "^\\s*(?:-|=|!=)",
|
||||
"next": "js-start"
|
||||
},
|
||||
/*{
|
||||
"token": "entity.name.tag.script.jade",
|
||||
"regex": "^\\s*script",
|
||||
|
|
@ -219,7 +219,21 @@ var JadeHighlightRules = function() {
|
|||
"next": "start"
|
||||
}
|
||||
],
|
||||
"tag_attributes": [
|
||||
"tag_attributes": [
|
||||
{
|
||||
"token" : "string",
|
||||
"regex" : "'(?=.)",
|
||||
"next" : "qstring"
|
||||
},
|
||||
{
|
||||
"token" : "string",
|
||||
"regex" : '"(?=.)',
|
||||
"next" : "qqstring"
|
||||
},
|
||||
{
|
||||
"token": "entity.other.attribute-name.jade",
|
||||
"regex": "\\b[a-zA-Z\\-:]+"
|
||||
},
|
||||
{
|
||||
"token": ["entity.other.attribute-name.jade", "punctuation"],
|
||||
"regex": "\\b([a-zA-Z:\\.-]+)(=)",
|
||||
|
|
@ -284,6 +298,12 @@ var JadeHighlightRules = function() {
|
|||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.embedRules(JavaScriptHighlightRules, "js-", [{
|
||||
token: "text",
|
||||
regex: ".$",
|
||||
next: "start"
|
||||
}]);
|
||||
/*
|
||||
this.embedRules(MarkdownHighlightRules, "markdown-", [{
|
||||
token : "support.function",
|
||||
|
|
@ -324,4 +344,4 @@ var JadeHighlightRules = function() {
|
|||
oop.inherits(JadeHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.JadeHighlightRules = JadeHighlightRules;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ var JavaHighlightRules = function() {
|
|||
"variable.language": "this",
|
||||
"keyword": keywords,
|
||||
"constant.language": buildinConstants,
|
||||
"support.function": langClasses,
|
||||
|
||||
"support.function": langClasses
|
||||
}, "identifier");
|
||||
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
|
|
|
|||
|
|
@ -123,25 +123,9 @@ oop.inherits(Mode, TextMode);
|
|||
this.createWorker = function(session) {
|
||||
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
|
||||
worker.attachToDocument(session.getDocument());
|
||||
|
||||
|
||||
worker.on("jslint", function(results) {
|
||||
var errors = [];
|
||||
for (var i=0; i<results.data.length; i++) {
|
||||
var error = results.data[i];
|
||||
if (error)
|
||||
errors.push({
|
||||
row: error.line-1,
|
||||
column: error.character-1,
|
||||
text: error.reason,
|
||||
type: "warning",
|
||||
lint: error
|
||||
});
|
||||
}
|
||||
session.setAnnotations(errors);
|
||||
});
|
||||
|
||||
worker.on("narcissus", function(e) {
|
||||
session.setAnnotations([e.data]);
|
||||
session.setAnnotations(results.data);
|
||||
});
|
||||
|
||||
worker.on("terminate", function() {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -32,7 +32,6 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var unicode = require("../unicode");
|
||||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
|
|
@ -51,11 +50,11 @@ var JavaScriptHighlightRules = function() {
|
|||
"JSON|Math|" + // Other
|
||||
"this|arguments|prototype|window|document" , // Pseudo
|
||||
"invalid.deprecated":
|
||||
"__parent__|__count__|escape|unescape|with|__proto__|debugger",
|
||||
"__parent__|__count__|escape|unescape|with|__proto__",
|
||||
"keyword":
|
||||
"const|yield|import|get|set" +
|
||||
"const|yield|import|get|set|" +
|
||||
"break|case|catch|continue|default|delete|do|else|finally|for|function|" +
|
||||
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|",
|
||||
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger",
|
||||
"storage.type":
|
||||
"const|let|var|function",
|
||||
"invalid.illegal":
|
||||
|
|
@ -63,9 +62,10 @@ var JavaScriptHighlightRules = function() {
|
|||
"public|interface|package|protected|static",
|
||||
"constant.language":
|
||||
"null|Infinity|NaN|undefined",
|
||||
"support.function":
|
||||
"alert"
|
||||
}, "identifier");
|
||||
|
||||
|
||||
// keywords which can be followed by regular expressions
|
||||
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
|
||||
|
||||
|
|
@ -255,14 +255,14 @@ var JavaScriptHighlightRules = function() {
|
|||
}, {
|
||||
// invalid operators
|
||||
token : "invalid",
|
||||
regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?]
|
||||
regex: /\{\d+,?(?:\d+)?}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
|
||||
}, {
|
||||
// operators
|
||||
token : "constant.language.escape",
|
||||
regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/
|
||||
regex: /\(\?[:=!]|\)|{\d+,?(?:\d+)?}|{,\d+}|[+*]\?|[(|)$^+*?]/
|
||||
}, {
|
||||
token: "string.regexp",
|
||||
regex: /{|[^\[\\{()$^+*?\/]+/,
|
||||
regex: /{|[^{\[\/\\(|)$^+*?]+/,
|
||||
merge: true
|
||||
}, {
|
||||
token: "constant.language.escape",
|
||||
|
|
@ -286,7 +286,7 @@ var JavaScriptHighlightRules = function() {
|
|||
merge: true
|
||||
}, {
|
||||
token: "constant.language.escape",
|
||||
regex: "-",
|
||||
regex: "-"
|
||||
}, {
|
||||
token: "string.regexp.charachterclass",
|
||||
regex: /[^\]\-\\]+/,
|
||||
|
|
|
|||
|
|
@ -27,55 +27,160 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var Mirror = require("../worker/mirror").Mirror;
|
||||
var lint = require("../worker/jshint").JSHINT;
|
||||
var parser = require("../narcissus/parser");
|
||||
|
||||
var lint = require("./javascript/jshint").JSHINT;
|
||||
|
||||
function startRegex(arr) {
|
||||
return RegExp("^(" + arr.join("|") + ")");
|
||||
}
|
||||
|
||||
var disabledWarningsRe = startRegex([
|
||||
"Bad for in variable '(.+)'.",
|
||||
'Missing "use strict"'
|
||||
]);
|
||||
var errorsRe = startRegex([
|
||||
"Unexpected",
|
||||
"Expected ",
|
||||
"Confusing (plus|minus)",
|
||||
"\\{a\\} unterminated regular expression",
|
||||
"Unclosed ",
|
||||
"Unmatched ",
|
||||
"Unbegun comment",
|
||||
"Bad invocation",
|
||||
"Missing space after",
|
||||
"Missing operator at"
|
||||
]);
|
||||
var infoRe = startRegex([
|
||||
"Expected an assignment",
|
||||
"Bad escapement of EOL",
|
||||
"Unexpected comma",
|
||||
"Unexpected space",
|
||||
"Missing radix parameter.",
|
||||
"A leading decimal point can",
|
||||
"\\['\\{a\\}'\\] is better written in dot notation."
|
||||
]);
|
||||
|
||||
var JavaScriptWorker = exports.JavaScriptWorker = function(sender) {
|
||||
Mirror.call(this, sender);
|
||||
this.setTimeout(500);
|
||||
this.setOptions();
|
||||
};
|
||||
|
||||
oop.inherits(JavaScriptWorker, Mirror);
|
||||
|
||||
(function() {
|
||||
|
||||
this.setOptions = function(options) {
|
||||
this.options = options || {
|
||||
// undef: true,
|
||||
// unused: true,
|
||||
es5: true,
|
||||
esnext: true,
|
||||
devel: true,
|
||||
browser: true,
|
||||
node: true,
|
||||
laxcomma: true,
|
||||
laxbreak: true,
|
||||
lastsemic: true,
|
||||
onevar: false,
|
||||
passfail: false,
|
||||
maxerr: 100,
|
||||
expr: true,
|
||||
multistr: true,
|
||||
globalstrict: true
|
||||
};
|
||||
this.doc.getValue() && this.deferredUpdate.schedule(100);
|
||||
};
|
||||
|
||||
this.changeOptions = function(newOptions) {
|
||||
oop.mixin(this.options, newOptions);
|
||||
this.doc.getValue() && this.deferredUpdate.schedule(100);
|
||||
};
|
||||
|
||||
this.isValidJS = function(str) {
|
||||
try {
|
||||
// evaluated code can only create variables in this function
|
||||
eval("throw 0;" + str);
|
||||
} catch(e) {
|
||||
if (e === 0)
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
};
|
||||
|
||||
this.onUpdate = function() {
|
||||
var value = this.doc.getValue();
|
||||
value = value.replace(/^#!.*\n/, "\n");
|
||||
|
||||
// var start = new Date();
|
||||
try {
|
||||
parser.parse(value);
|
||||
} catch(e) {
|
||||
// console.log("narcissus")
|
||||
// console.log(e);
|
||||
var chunks = e.message.split(":")
|
||||
var message = chunks.pop().trim();
|
||||
var lineNumber = parseInt(chunks.pop().trim()) - 1;
|
||||
this.sender.emit("narcissus", {
|
||||
row: lineNumber,
|
||||
column: null, // TODO convert e.cursor
|
||||
text: message,
|
||||
type: "error"
|
||||
});
|
||||
if (!value) {
|
||||
this.sender.emit("jslint", []);
|
||||
return;
|
||||
} finally {
|
||||
// console.log("parse time: " + (new Date() - start));
|
||||
}
|
||||
|
||||
// var start = new Date();
|
||||
// console.log("jslint")
|
||||
lint(value, {undef: false, onevar: false, passfail: false});
|
||||
this.sender.emit("jslint", lint.errors);
|
||||
// console.log("lint time: " + (new Date() - start));
|
||||
}
|
||||
|
||||
var errors = [];
|
||||
|
||||
// jshint reports many false errors
|
||||
// report them as error only if code is actually invalid
|
||||
var maxErrorLevel = this.isValidJS(value) ? "warning" : "error";
|
||||
|
||||
// var start = new Date();
|
||||
lint(value, this.options);
|
||||
var results = lint.errors;
|
||||
|
||||
var errorAdded = false
|
||||
for (var i = 0; i < results.length; i++) {
|
||||
var error = results[i];
|
||||
if (!error)
|
||||
continue;
|
||||
var raw = error.raw;
|
||||
var type = "warning";
|
||||
|
||||
if (raw == "Missing semicolon.") {
|
||||
var str = error.evidence.substr(error.character);
|
||||
str = str.charAt(str.search(/\S/));
|
||||
if (maxErrorLevel == "error" && str && /[\w\d{(['"]/.test(str)) {
|
||||
error.reason = 'Missing ";" before statement';
|
||||
type = "error";
|
||||
} else {
|
||||
type = "info";
|
||||
}
|
||||
}
|
||||
else if (disabledWarningsRe.test(raw)) {
|
||||
continue;
|
||||
}
|
||||
else if (infoRe.test(raw)) {
|
||||
type = "info"
|
||||
}
|
||||
else if (errorsRe.test(raw)) {
|
||||
errorAdded = true;
|
||||
type = maxErrorLevel;
|
||||
}
|
||||
else if (raw == "'{a}' is not defined.") {
|
||||
type = "warning";
|
||||
}
|
||||
else if (raw == "'{a}' is defined but never used.") {
|
||||
type = "info";
|
||||
}
|
||||
|
||||
errors.push({
|
||||
row: error.line-1,
|
||||
column: error.character-1,
|
||||
text: error.reason,
|
||||
type: type,
|
||||
raw: raw
|
||||
});
|
||||
|
||||
if (errorAdded) {
|
||||
// break;
|
||||
}
|
||||
}
|
||||
// console.log("lint time: " + (new Date() - start));
|
||||
|
||||
this.sender.emit("jslint", errors);
|
||||
};
|
||||
|
||||
}).call(JavaScriptWorker.prototype);
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ module.exports = {
|
|||
worker.setValue("Juhu Kinners");
|
||||
worker.deferredUpdate.call();
|
||||
|
||||
var error = this.sender.events[0][1];
|
||||
assert.equal(error.text, "missing ; before statement");
|
||||
var error = this.sender.events[0][1][0];
|
||||
assert.equal(error.text, 'Missing ";" before statement');
|
||||
assert.equal(error.type, "error");
|
||||
assert.equal(error.row, 0);
|
||||
assert.equal(error.column, null);
|
||||
assert.equal(error.column, 4);
|
||||
},
|
||||
|
||||
"test invalid multi line string": function() {
|
||||
|
|
@ -70,18 +70,23 @@ module.exports = {
|
|||
worker.setValue('"a\n\\nn"');
|
||||
worker.deferredUpdate.call();
|
||||
|
||||
var error = this.sender.events[0][1];
|
||||
assert.equal(error.text, "Unterminated string literal");
|
||||
var error = this.sender.events[0][1][0];
|
||||
assert.equal(error.text, "Unclosed string.");
|
||||
assert.equal(error.type, "error");
|
||||
assert.equal(error.row, 0);
|
||||
assert.equal(error.column, null);
|
||||
assert.equal(error.column, 0);
|
||||
},
|
||||
|
||||
"test check for narcissus bug": function() {
|
||||
"test another invalid string": function() {
|
||||
var worker = new JavaScriptWorker(this.sender);
|
||||
worker.setValue("if('");
|
||||
worker.deferredUpdate.call();
|
||||
assert.equal(this.sender.events[0][1].type, "error");
|
||||
|
||||
var error = this.sender.events[0][1][0];
|
||||
assert.equal(error.text, "Unclosed string.");
|
||||
assert.equal(error.type, "error");
|
||||
assert.equal(error.row, 0);
|
||||
assert.equal(error.column, 3);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -36,14 +36,9 @@ var TextMode = require("./text").Mode;
|
|||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var JspHighlightRules = require("./jsp_highlight_rules").JspHighlightRules;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var Range = require("../range").Range;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
|
||||
var JavaScriptMode = require("./javascript").Mode;
|
||||
var CssMode = require("./css").Mode;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new JspHighlightRules();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ var LatexHighlightRules = function() {
|
|||
"start" : [{
|
||||
// A tex command e.g. \foo
|
||||
token : "keyword",
|
||||
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)",
|
||||
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
|
||||
}, {
|
||||
// Curly and square braces
|
||||
token : "lparen",
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ oop.inherits(Mode, TextMode);
|
|||
"elseif": 1,
|
||||
"repeat": 1,
|
||||
"end": -1,
|
||||
"until": -1,
|
||||
"until": -1
|
||||
};
|
||||
var outdentKeywords = [
|
||||
"else",
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ var PgsqlHighlightRules = function() {
|
|||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"support.function": builtinFunctions,
|
||||
"keyword": keywords,
|
||||
"keyword": keywords
|
||||
}, "identifier", true);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd
|
|||
var Range = require("../range").Range;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
var unicode = require("../unicode");
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new PhpHighlightRules().getRules());
|
||||
|
|
@ -50,6 +51,20 @@ oop.inherits(Mode, TextMode);
|
|||
|
||||
(function() {
|
||||
|
||||
this.tokenRe = new RegExp("^["
|
||||
+ unicode.packages.L
|
||||
+ unicode.packages.Mn + unicode.packages.Mc
|
||||
+ unicode.packages.Nd
|
||||
+ unicode.packages.Pc + "\_]+", "g"
|
||||
);
|
||||
|
||||
this.nonTokenRe = new RegExp("^(?:[^"
|
||||
+ unicode.packages.L
|
||||
+ unicode.packages.Mn + unicode.packages.Mc
|
||||
+ unicode.packages.Nd
|
||||
+ unicode.packages.Pc + "\_]|\s])+", "g"
|
||||
);
|
||||
|
||||
this.toggleCommentLines = function(state, doc, startRow, endRow) {
|
||||
var outdent = true;
|
||||
var re = /^(\s*)#/;
|
||||
|
|
|
|||
|
|
@ -1045,7 +1045,7 @@ var PhpHighlightRules = function() {
|
|||
for (var i in this.$rules) {
|
||||
this.$rules[i].unshift({
|
||||
token : "support.php_tag", // php open tag
|
||||
regex : "<\\?(?:php|\\=)",
|
||||
regex : "<\\?(?:php|\\=)?",
|
||||
next : "php-start"
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,11 +122,11 @@ var RubyHighlightRules = function() {
|
|||
token : "text", // namespaces aren't symbols
|
||||
regex : "::"
|
||||
}, {
|
||||
token : "variable.instancce", // instance variable
|
||||
regex : "@{1,2}(?:[a-zA-Z_]|\d)+"
|
||||
token : "variable.instance", // instance variable
|
||||
regex : "@{1,2}[a-zA-Z_\\d]+"
|
||||
}, {
|
||||
token : "variable.class", // class name
|
||||
regex : "[A-Z](?:[a-zA-Z_]|\d)+"
|
||||
regex : "[A-Z][a-zA-Z_\\d]+"
|
||||
}, {
|
||||
token : "string", // symbol
|
||||
regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?"
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ var scadHighlightRules = function() {
|
|||
var keywordMapper = this.createKeywordMapper({
|
||||
"variable.language": "this",
|
||||
"keyword": "module|if|else|for",
|
||||
"constant.language": "NULL",
|
||||
"constant.language": "NULL"
|
||||
}, "identifier");
|
||||
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ var ScalaHighlightRules = function() {
|
|||
"string" : [
|
||||
{
|
||||
token : "escape",
|
||||
regex : '\\\\"',
|
||||
regex : '\\\\"'
|
||||
}, {
|
||||
token : "string",
|
||||
merge : true,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ var ShHighlightRules = function() {
|
|||
regex : variable
|
||||
}, {
|
||||
token : "support.function",
|
||||
regex : func,
|
||||
regex : func
|
||||
}, {
|
||||
token : "support.function",
|
||||
regex : fileDescriptor
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
|||
var SqlHighlightRules = function() {
|
||||
|
||||
var keywords = (
|
||||
"select|from|where|and|or|group|by|order|limit|offset|having|as|case|" +
|
||||
"select|insert|update|delete|from|where|and|or|group|by|order|limit|offset|having|as|case|" +
|
||||
"when|else|end|type|left|right|join|on|outer|desc|asc"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ var SvgHighlightRules = function() {
|
|||
|
||||
this.$rules.start.splice(3, 0, {
|
||||
token : "meta.tag",
|
||||
regex : "<(?=\s*script)",
|
||||
regex : "<(?=script)",
|
||||
next : "script"
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -150,16 +150,16 @@ var TclHighlightRules = function() {
|
|||
}],
|
||||
"variable" : [
|
||||
{
|
||||
token : "variable.instancce", // variable xotcl with braces
|
||||
regex : "(?:[:][:])?(?:[a-zA-Z_]|\d)+(?:(?:[:][:])?(?:[a-zA-Z_]|\d)+)?(?:[(](?:[a-zA-Z_]|\d)+[)])?",
|
||||
token : "variable.instance", // variable xotcl with braces
|
||||
regex : "(?:[:][:])?[a-zA-Z_\\d]+(?:(?:[:][:])?[a-zA-Z_\\d]+)?(?:[(][a-zA-Z_\\d]+[)])?",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "variable.instancce", // variable tcl
|
||||
regex : "(?:[a-zA-Z_]|\d)+(?:[(](?:[a-zA-Z_]|\d)+[)])?",
|
||||
token : "variable.instance", // variable tcl
|
||||
regex : "[a-zA-Z_\\d]+(?:[(][a-zA-Z_\\d]+[)])?",
|
||||
next : "start"
|
||||
}, {
|
||||
token : "variable.instancce", // variable tcl with braces
|
||||
regex : "{?(?:[a-zA-Z_]|\d)+}?",
|
||||
token : "variable.instance", // variable tcl with braces
|
||||
regex : "{?[a-zA-Z_\\d]+}?",
|
||||
next : "start"
|
||||
}],
|
||||
"qqstring" : [ {
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
define(function(require, exports, module){
|
||||
var Position = exports.Position = function(line, offset, length)
|
||||
{
|
||||
this.line = line;
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
|
||||
this.getLine = function()
|
||||
{
|
||||
return this.line;
|
||||
};
|
||||
|
||||
this.getOffset = function()
|
||||
{
|
||||
return this.offset;
|
||||
};
|
||||
|
||||
this.getLength = function()
|
||||
{
|
||||
return this.length;
|
||||
};
|
||||
};
|
||||
|
||||
});
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,63 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
define(function(require, exports, module){
|
||||
|
||||
var org = require("./antlr3-all").org;
|
||||
|
||||
var XQDTLexer = exports.XQDTLexer = function(input, state)
|
||||
{
|
||||
XQDTLexer.superclass.constructor.call(this, input, state);
|
||||
};
|
||||
|
||||
org.antlr.lang.extend(XQDTLexer, org.antlr.runtime.Lexer, {
|
||||
|
||||
comments: [],
|
||||
|
||||
addComment: function(start, stop){ this.comments.push({ start: start, stop: stop }); },
|
||||
|
||||
isWsExplicit: false,
|
||||
|
||||
setIsWsExplicit: function (wsExplicit) {
|
||||
//console.log("A WS: " + wsExplicit);
|
||||
this.isWsExplicit = wsExplicit;
|
||||
//console.log("B WS: " + wsExplicit);
|
||||
},
|
||||
|
||||
addToStack: function (stack) {
|
||||
stack.push(this);
|
||||
},
|
||||
|
||||
rewindToIndex: function(index) {
|
||||
var stream = this.input;
|
||||
stream.seek(index);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
define(function(require, exports, module){
|
||||
|
||||
var org = require("./antlr3-all").org;
|
||||
var XQuerySemanticHighlighter = require("./XQuerySemanticHighlighter").XQuerySemanticHighlighter;
|
||||
|
||||
var XQDTParser = exports.XQDTParser = function(input, state)
|
||||
{
|
||||
this.highlighter = new XQuerySemanticHighlighter();
|
||||
var that = this;
|
||||
|
||||
input.getTokenSource().addComment = function(start, stop) {
|
||||
var comments = input.getTokenSource().comments;
|
||||
for(var i in comments)
|
||||
{
|
||||
var c = comments[i];
|
||||
that.highlighter.addToken(c.start, c.stop, "comment");
|
||||
}
|
||||
input.getTokenSource().comments = [];
|
||||
that.highlighter.addToken(start, stop, "comment")
|
||||
};
|
||||
XQDTParser.superclass.constructor.call(this, input, state);
|
||||
};
|
||||
|
||||
org.antlr.lang.extend(XQDTParser, org.antlr.runtime.Parser, {
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,161 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
define(function(require, exports, module){
|
||||
|
||||
var Position = require("./Position").Position;
|
||||
var XQuerySemanticHighlighter = exports.XQuerySemanticHighlighter = function() {
|
||||
this.tokenizer = null;
|
||||
this.plain = null;
|
||||
this.source = [];
|
||||
this.lines = [];
|
||||
|
||||
this.getTokens = function() {
|
||||
var resultLines = new Array(this.source.length);
|
||||
var resultStates = new Array(this.source.length);
|
||||
var previousState = "start";
|
||||
var i = 0;
|
||||
for(i in this.source){
|
||||
var lineTokens = [];
|
||||
var tokens = [];
|
||||
if(this.lines[i]) {
|
||||
tokens = this.lines[i].sort(function(a, b){ return a.position.getOffset() - b.position.getOffset(); });
|
||||
}
|
||||
var sourceLine = this.source[i];
|
||||
var tokenizedLine = "";
|
||||
var cursor = 0;
|
||||
var j = 0;
|
||||
for(j in tokens)
|
||||
{
|
||||
var token = tokens[j];
|
||||
var position = token.position;
|
||||
if(position.getOffset() > cursor) {
|
||||
var value = sourceLine.substring(cursor, position.getOffset());
|
||||
tokenizedLine += value;
|
||||
lineTokens.push({
|
||||
type: "text",
|
||||
value: value
|
||||
});
|
||||
}
|
||||
cursor = position.getOffset() + position.getLength();
|
||||
value = sourceLine.substring(position.getOffset(), cursor);
|
||||
tokenizedLine += value;
|
||||
lineTokens.push({
|
||||
type: token.type,
|
||||
value: value
|
||||
});
|
||||
}
|
||||
|
||||
var nextState = "start";
|
||||
if(lineTokens.length > 0) {
|
||||
lineTokens[lineTokens.length - 1].type;
|
||||
}
|
||||
nextState = (nextState != "comment" && nextState != "string" && nextState != "cdata" && nextState != "tag") ? "start" : nextState;
|
||||
|
||||
if(cursor < (sourceLine.length )) {
|
||||
value = sourceLine.substring(cursor);
|
||||
lineTokens.push({
|
||||
type: "text",
|
||||
value: value
|
||||
});
|
||||
tokenizedLine += value;
|
||||
}
|
||||
//Check if the tokenized line is equal to the original one:
|
||||
if(sourceLine == tokenizedLine) {
|
||||
resultLines[i] = lineTokens;
|
||||
resultStates[i] = nextState;
|
||||
//result[i] = { line: sourceLine, startState: previousState, tokens: { tokens: lineTokens, state: nextState } };
|
||||
} else {
|
||||
//console.log("sourceLine: " + sourceLine);
|
||||
//console.log("tokenizedLine: " + tokenizedLine);
|
||||
resultLines[i] = [{ type: "text", value: sourceLine }];
|
||||
resultStates[i] = nextState;
|
||||
//result[i] = { tokens: [ { type: "text", value: sourceLine } ], state: nextState };
|
||||
}
|
||||
|
||||
if(resultLines[i].length === 1 && resultLines[i][0].type === "text" && this.tokenizer instanceof Object) {
|
||||
var prev = resultStates[i - 1] ? resultStates[i - 1] : "start";
|
||||
var result = this.tokenizer.getLineTokens(resultLines[i][0].value, prev);
|
||||
resultLines[i] = result.tokens;
|
||||
resultStates[i] = result.state;
|
||||
}
|
||||
}
|
||||
return {states: resultStates, lines: resultLines};
|
||||
};
|
||||
|
||||
this.addToken = function(start, stop, type) {
|
||||
var before = this.plain.substring(0, start);
|
||||
var startLine = this.plain.substring(0, start).split("\n").length;
|
||||
startLine = startLine == 0 ? 0 : startLine - 1;
|
||||
|
||||
var offset = before.lastIndexOf("\n");
|
||||
offset = offset == -1 ? start : start - before.lastIndexOf("\n") - 1;
|
||||
|
||||
var cursor = start;
|
||||
|
||||
var text = this.plain.substring(start, stop);
|
||||
|
||||
var currentLine = startLine;
|
||||
for(var i in text)
|
||||
{
|
||||
var c = text[i];
|
||||
if(c == "\n") {
|
||||
var s = i;
|
||||
s = s < stop ? s : stop;
|
||||
this.addPosition(new Position(currentLine, offset, s), type);
|
||||
currentLine++;
|
||||
offset = 0;
|
||||
cursor = i;
|
||||
}
|
||||
};
|
||||
this.addPosition(new Position(currentLine, offset, stop - cursor + 1), type);
|
||||
};
|
||||
|
||||
this.addPosition = function(position, type)
|
||||
{
|
||||
var line = position.getLine();
|
||||
if(!this.lines[line]) {
|
||||
this.lines[line] = [];
|
||||
}
|
||||
this.lines[line].push({
|
||||
type: type,
|
||||
position: position
|
||||
});
|
||||
};
|
||||
|
||||
this.setSource = function(source)
|
||||
{
|
||||
this.plain = source.data;
|
||||
this.source = this.plain.split("\n");
|
||||
};
|
||||
//console.log("Line: " + token.getLine());
|
||||
//console.log(token.getText());
|
||||
//console.log(type);
|
||||
};
|
||||
});
|
||||
File diff suppressed because it is too large
Load diff
345
lib/ace/mode/xquery/visitors/SyntaxHighlighter.js
Normal file
345
lib/ace/mode/xquery/visitors/SyntaxHighlighter.js
Normal file
|
|
@ -0,0 +1,345 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module){
|
||||
|
||||
var SyntaxHighlighter = exports.SyntaxHighlighter = function(source, tree)
|
||||
{
|
||||
var keywords = ['after', 'ancestor', 'ancestor-or-self', 'and', 'as', 'ascending', 'attribute', 'before', 'case', 'cast', 'castable', 'child', 'collation', 'comment', 'copy', 'count', 'declare', 'default', 'delete', 'descendant', 'descendant-or-self', 'descending', 'div', 'document', 'document-node', 'element', 'else', 'empty', 'empty-sequence', 'end', 'eq', 'every', 'except', 'first', 'following', 'following-sibling', 'for', 'function', 'ge', 'group', 'gt', 'idiv', 'if', 'then', 'import', 'insert', 'instance', 'intersect', 'into', 'is', 'item', 'last', 'le', 'let', 'lt', 'mod', 'modify', 'module', 'namespace', 'namespace-node', 'ne', 'node', 'only', 'or', 'order', 'ordered', 'parent', 'preceding', 'preceding-sibling', 'processing-instruction', 'rename', 'replace', 'return', 'satisfies', 'schema-attribute', 'schema-element', 'self', 'some', 'stable', 'start', 'switch', 'text', 'to', 'treat', 'try', 'typeswitch', 'union', 'unordered', 'validate', 'where', 'with', 'xquery', 'contains', 'paragraphs', 'sentences', 'times', 'words', 'by', 'collection', 'allowing', 'at', 'base-uri', 'boundary-space', 'break', 'catch', 'construction', 'context', 'continue', 'copy-namespaces', 'decimal-format', 'encoding', 'exit', 'external', 'ft-option', 'in', 'index', 'integrity', 'lax', 'nodes', 'option', 'ordering', 'revalidation', 'schema', 'score', 'sliding', 'strict', 'tumbling', 'type', 'updating', 'value', 'variable', 'version', 'while', 'constraint', 'loop', 'returning', 'append', 'array', 'json-item', 'object', 'structured-item', 'when', 'next', 'previous'];
|
||||
var states = ["cdata", "comment", "tag"];
|
||||
var info = { lines: [ [] ], states: [] };
|
||||
var inName = false;
|
||||
|
||||
this.getTokens = function() {
|
||||
this.visit(tree);
|
||||
return info;
|
||||
};
|
||||
|
||||
this.addTokens = function(value, type)
|
||||
{
|
||||
var tokens = value.split("\n");
|
||||
var lastState = "start";
|
||||
for(var i in tokens)
|
||||
{
|
||||
if(i > 0) {
|
||||
info.lines.push([]);
|
||||
info.states.push(lastState);
|
||||
}
|
||||
var value = tokens[i];
|
||||
var linesLength = info.lines.length - 1;
|
||||
var linesIdx = info.lines[linesLength];
|
||||
linesIdx.push({ value: value, type: type });
|
||||
lastState = states.indexOf(type) != -1 ? type : "start";
|
||||
}
|
||||
};
|
||||
|
||||
this.getNodeValue = function(node)
|
||||
{
|
||||
return source.substring(node.begin, node.end);
|
||||
};
|
||||
|
||||
this.DirPIConstructor = function(node)
|
||||
{
|
||||
var value = this.getNodeValue(node);
|
||||
this.addTokens(value, "xml_pe");
|
||||
return true;
|
||||
};
|
||||
|
||||
this.DirElemConstructor = function(node)
|
||||
{
|
||||
for(var i in node.children)
|
||||
{
|
||||
var child = node.children[i];
|
||||
if(child.name === "TOKEN" || child.name === "QName") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "meta.tag");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
this.DirAttributeList = function(node)
|
||||
{
|
||||
for(var i in node.children)
|
||||
{
|
||||
var child = node.children[i];
|
||||
if(child.name === "QName") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "meta.tag");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
this.DirAttributeValue = function(node)
|
||||
{
|
||||
for(var i in node.children)
|
||||
{
|
||||
var child = node.children[i];
|
||||
if(child.name === "TOKEN") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "string");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
this.QuotAttrContentChar = function(node)
|
||||
{
|
||||
var value = this.getNodeValue(node);
|
||||
this.addTokens(value, "string");
|
||||
return true;
|
||||
};
|
||||
|
||||
//this.EQName = function(node)
|
||||
//{
|
||||
// var value = source.substring(node.begin, node.end);
|
||||
// this.addTokens(value, "support.function");
|
||||
// return true;
|
||||
//};
|
||||
|
||||
this.FunctionName = function(node)
|
||||
{
|
||||
for(var i in node.children) {
|
||||
var child = node.children[i];
|
||||
if(child.name === "EQName" || child.name === "TOKEN") {
|
||||
var value = child.children[0].value;
|
||||
this.addTokens(value, "support.function");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
this.StringConcatExpr = function(node)
|
||||
{
|
||||
for(var i in node.children) {
|
||||
var child = node.children[i];
|
||||
if(child.name === "TOKEN") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "keyword.operator");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
this.AdditiveExpr = function(node)
|
||||
{
|
||||
for(var i in node.children) {
|
||||
var child = node.children[i];
|
||||
if(child.name === "TOKEN") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "keyword.operator");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
this.MultiplicativeExpr = function(node)
|
||||
{
|
||||
for(var i in node.children) {
|
||||
var child = node.children[i];
|
||||
if(child.name === "TOKEN") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "keyword.operator");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
this.UnaryExpr = function(node)
|
||||
{
|
||||
for(var i in node.children) {
|
||||
var child = node.children[i];
|
||||
if(child.name === "TOKEN") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "keyword.operator");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
this.GeneralComp = function(node)
|
||||
{
|
||||
for(var i in node.children) {
|
||||
var child = node.children[i];
|
||||
if(child.name === "TOKEN") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "keyword.operator");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
this.NumericLiteral = function(node)
|
||||
{
|
||||
for(var i in node.children) {
|
||||
var child = node.children[i];
|
||||
if(child.name != "TEXT") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "constant");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}return true;
|
||||
}
|
||||
|
||||
this.DirCommentConstructor = function(node)
|
||||
{
|
||||
for(var i in node.children) {
|
||||
var child = node.children[i];
|
||||
if(child.name != "TEXT") {
|
||||
var value = this.getNodeValue(child);
|
||||
this.addTokens(value, "comment");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}return true;
|
||||
}
|
||||
|
||||
this.Comment = function(node)
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
||||
this.URILiteral = function(node)
|
||||
{
|
||||
var value = this.getNodeValue(node);
|
||||
this.addTokens(value, "string");
|
||||
return true;
|
||||
};
|
||||
|
||||
this.StringLiteral = function(node)
|
||||
{
|
||||
var value = this.getNodeValue(node);
|
||||
this.addTokens(value, "string");
|
||||
return true;
|
||||
};
|
||||
|
||||
this.NCName = function(node)
|
||||
{
|
||||
inName = true;
|
||||
for(var i in node.children)
|
||||
{
|
||||
var child = node.children[i];
|
||||
this.visit(child);
|
||||
}
|
||||
inName = false;
|
||||
return true;
|
||||
};
|
||||
|
||||
this.EQName = function(node)
|
||||
{
|
||||
inName = true;
|
||||
for(var i in node.children)
|
||||
{
|
||||
var child = node.children[i];
|
||||
this.visit(child);
|
||||
}
|
||||
inName = false;
|
||||
return true;
|
||||
};
|
||||
|
||||
this.TOKEN = function(node)
|
||||
{
|
||||
value = node.children[0].value;
|
||||
if(keywords.indexOf(value) > -1 && !inName) {
|
||||
this.addTokens(value, "keyword");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
this.EverythingElse = function(node)
|
||||
{
|
||||
if(typeof node["pos"] === "object")
|
||||
{
|
||||
var value = node.value;
|
||||
var openingIdx = value.indexOf("(:");
|
||||
while(openingIdx > -1) {
|
||||
var text = value.substring(0, openingIdx);
|
||||
this.addTokens(text, "text");
|
||||
var closingIdx = value.substring(openingIdx).indexOf(":)") + 3;
|
||||
var comment = value.substring(openingIdx, closingIdx);
|
||||
this.addTokens(comment, "comment");
|
||||
value = value.substring(closingIdx);
|
||||
openingIdx = value.indexOf("(:");
|
||||
}
|
||||
this.addTokens(value, "text");
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
this.visit = function(node){
|
||||
var name = node.name;
|
||||
var skip = false;
|
||||
|
||||
if(typeof this[name] === "function")
|
||||
skip = this[name](node) === true ? true : false ;
|
||||
else
|
||||
skip = this.EverythingElse(node) === true ? true : false;
|
||||
|
||||
if(!skip && typeof node.children === "object")
|
||||
{
|
||||
for(var i = 0; i < node.children.length; i++)
|
||||
{
|
||||
var child = node.children[i];
|
||||
if(child.name === "TOKEN" && child.children[0].value === "$") {
|
||||
i++;
|
||||
var next = node.children[i];
|
||||
var value = source.substring(child.children[0].pos.begin, next.end);
|
||||
this.addTokens(value, "variable");
|
||||
} else {
|
||||
this.visit(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var antlr = require("./antlr3-all");
|
||||
var org = antlr.org;
|
||||
var NewLazyTokenStream = antlr.NewLazyTokenStream;
|
||||
var XQueryLexer = require("./XQueryLexer").XQueryLexer;
|
||||
var XQueryParser = require("./XQueryParser").XQueryParser;
|
||||
|
||||
exports.getParser = function(code) {
|
||||
var cstream = new org.antlr.runtime.ANTLRStringStream(code);
|
||||
var lexer = new XQueryLexer(cstream);
|
||||
var tstream = new NewLazyTokenStream(lexer);
|
||||
tstream.jumpToFirstValidToken();
|
||||
var parser = new XQueryParser(tstream);
|
||||
parser.setSource(cstream);
|
||||
return parser;
|
||||
};
|
||||
});
|
||||
|
|
@ -33,10 +33,8 @@ define(function(require, exports, module) {
|
|||
|
||||
var oop = require("../lib/oop");
|
||||
var Mirror = require("../worker/mirror").Mirror;
|
||||
var xquery = require("../mode/xquery/xquery");
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
|
||||
|
||||
var XQueryParser = require("./xquery/XQueryParser").XQueryParser;
|
||||
var SyntaxHighlighter = require("../mode/xquery/visitors/SyntaxHighlighter").SyntaxHighlighter;
|
||||
window.addEventListener = function() {};
|
||||
|
||||
|
||||
|
|
@ -52,26 +50,26 @@ oop.inherits(XQueryWorker, Mirror);
|
|||
this.onUpdate = function() {
|
||||
this.sender.emit("start");
|
||||
var value = this.doc.getValue();
|
||||
var parser = xquery.getParser(value);
|
||||
var ast = parser.p_Module();
|
||||
if(parser.hasErrors()) {
|
||||
var errors = parser.getErrors();
|
||||
var i = 0;
|
||||
for(i in errors) {
|
||||
var error = errors[i];
|
||||
this.sender.emit("error", {
|
||||
row: error.line,
|
||||
column: error.column,
|
||||
text: error.message,
|
||||
type: "error"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.sender.emit("ok");
|
||||
var parser = new XQueryParser(value);
|
||||
try {
|
||||
parser.parse_XQuery();
|
||||
var ast = parser.getAST();
|
||||
this.sender.emit("ok");
|
||||
var highlighter = new SyntaxHighlighter(value, ast);
|
||||
var tokens = highlighter.getTokens();
|
||||
this.sender.emit("highlight", tokens);
|
||||
} catch(e) {
|
||||
var prefix = value.substring(0, e.getBegin());
|
||||
var line = prefix.split("\n").length;
|
||||
var column = e.getBegin() - prefix.lastIndexOf("\n");
|
||||
var message = parser.getErrorMessage(e);
|
||||
this.sender.emit("error", {
|
||||
row: line - 1,
|
||||
column: column,
|
||||
text: message,
|
||||
type: "error"
|
||||
});
|
||||
}
|
||||
parser.highlighter.tokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
|
||||
var tokens = parser.highlighter.getTokens();
|
||||
this.sender.emit("highlight", tokens);
|
||||
};
|
||||
|
||||
}).call(XQueryWorker.prototype);
|
||||
|
|
|
|||
|
|
@ -44,14 +44,23 @@ var YamlHighlightRules = function() {
|
|||
token : "comment",
|
||||
regex : "#.*$"
|
||||
}, {
|
||||
token : "comment",
|
||||
regex : "^---"
|
||||
token : "list.markup",
|
||||
regex : /^(?:-{3}|\.{3})\s*(?=#|$)/
|
||||
}, {
|
||||
token : "list.markup",
|
||||
regex : /^\s*[\-?](?:$|\s)/
|
||||
}, {
|
||||
token: "variable",
|
||||
token: "constant",
|
||||
regex: "!![\\w//]+"
|
||||
}, {
|
||||
token: "constant.language",
|
||||
regex: "[&\\*][a-zA-Z0-9-_]+"
|
||||
}, {
|
||||
token: ["identifier", "text"],
|
||||
regex: "(\\w+\\s*:)(\\w*)"
|
||||
token: ["meta.tag", "keyword"],
|
||||
regex: /^(\s*\w.*?)(\:(?:\s+|$))/
|
||||
},{
|
||||
token: ["meta.tag", "keyword"],
|
||||
regex: /(\w+?)(\s*\:(?:\s+|$))/
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "<<\\w*:\\w*"
|
||||
|
|
@ -71,10 +80,13 @@ var YamlHighlightRules = function() {
|
|||
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
|
||||
}, {
|
||||
token : "constant.numeric", // float
|
||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||
regex : /[+\-]?[\d_]+(?:(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?\b/
|
||||
}, {
|
||||
token : "constant.numeric", // other number
|
||||
regex : /[+\-]?\.inf\b|NaN\b|0x[\dA-Fa-f_]+|0b[10_]+/
|
||||
}, {
|
||||
token : "constant.language.boolean",
|
||||
regex : "(?:true|false|yes|no)\\b"
|
||||
regex : "(?:true|false|TRUE|FALSE|True|False|yes|no)\\b"
|
||||
}, {
|
||||
token : "invalid.illegal", // comments are not allowed
|
||||
regex : "\\/\\/.*$"
|
||||
|
|
@ -87,6 +99,9 @@ var YamlHighlightRules = function() {
|
|||
}, {
|
||||
token : "text",
|
||||
regex : "\\s+"
|
||||
}, {
|
||||
token : "text",
|
||||
regex : "\\w+"
|
||||
}
|
||||
],
|
||||
"qqstring" : [
|
||||
|
|
@ -99,7 +114,7 @@ var YamlHighlightRules = function() {
|
|||
merge : true,
|
||||
regex : '.+'
|
||||
}
|
||||
]}
|
||||
]};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ function GutterHandler(mouseHandler) {
|
|||
|
||||
if (tooltipAnnotation == annotation)
|
||||
return;
|
||||
tooltipAnnotation = annotation.text.join("\n");
|
||||
tooltipAnnotation = annotation.text.join("<br/>");
|
||||
|
||||
tooltip.style.display = "block";
|
||||
tooltip.innerHTML = tooltipAnnotation;
|
||||
|
|
@ -134,7 +134,7 @@ function GutterHandler(mouseHandler) {
|
|||
return;
|
||||
tooltipTimeout = setTimeout(function() {
|
||||
tooltipTimeout = null;
|
||||
if (mouseEvent)
|
||||
if (mouseEvent && !mouseHandler.isMousePressed)
|
||||
showTooltip();
|
||||
else
|
||||
hideTooltip();
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ var MouseHandler = function(editor) {
|
|||
|
||||
this.x = ev.x;
|
||||
this.y = ev.y;
|
||||
|
||||
this.isMousePressed = true;
|
||||
|
||||
// do not move textarea during selection
|
||||
var renderer = this.editor.renderer;
|
||||
|
|
@ -135,6 +137,7 @@ var MouseHandler = function(editor) {
|
|||
renderer.$keepTextAreaAtCursor = true;
|
||||
renderer.$moveTextAreaToCursor();
|
||||
}
|
||||
self.isMousePressed = false;
|
||||
};
|
||||
|
||||
var onCaptureInterval = function() {
|
||||
|
|
|
|||
|
|
@ -1,683 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Narcissus - JS implemented in JS.
|
||||
*
|
||||
* Well-known constants and lookup tables. Many consts are generated from the
|
||||
* tokens table via eval to minimize redundancy, so consumers must be compiled
|
||||
* separately to take advantage of the simple switch-case constant propagation
|
||||
* done by SpiderMonkey.
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var tokens = [
|
||||
// End of source.
|
||||
"END",
|
||||
|
||||
// Operators and punctuators. Some pair-wise order matters, e.g. (+, -)
|
||||
// and (UNARY_PLUS, UNARY_MINUS).
|
||||
"\n", ";",
|
||||
",",
|
||||
"=",
|
||||
"?", ":", "CONDITIONAL",
|
||||
"||",
|
||||
"&&",
|
||||
"|",
|
||||
"^",
|
||||
"&",
|
||||
"==", "!=", "===", "!==",
|
||||
"<", "<=", ">=", ">",
|
||||
"<<", ">>", ">>>",
|
||||
"+", "-",
|
||||
"*", "/", "%",
|
||||
"!", "~", "UNARY_PLUS", "UNARY_MINUS",
|
||||
"++", "--",
|
||||
".",
|
||||
"[", "]",
|
||||
"{", "}",
|
||||
"(", ")",
|
||||
|
||||
// Nonterminal tree node type codes.
|
||||
"SCRIPT", "BLOCK", "LABEL", "FOR_IN", "CALL", "NEW_WITH_ARGS", "INDEX",
|
||||
"ARRAY_INIT", "OBJECT_INIT", "PROPERTY_INIT", "GETTER", "SETTER",
|
||||
"GROUP", "LIST", "LET_BLOCK", "ARRAY_COMP", "GENERATOR", "COMP_TAIL",
|
||||
|
||||
// Contextual keywords.
|
||||
"IMPLEMENTS", "INTERFACE", "LET", "MODULE", "PACKAGE", "PRIVATE",
|
||||
"PROTECTED", "PUBLIC", "STATIC", "USE", "YIELD",
|
||||
|
||||
// Terminals.
|
||||
"IDENTIFIER", "NUMBER", "STRING", "REGEXP",
|
||||
|
||||
// Keywords.
|
||||
"break",
|
||||
"case", "catch", "const", "continue",
|
||||
"debugger", "default", "delete", "do",
|
||||
"else", "export",
|
||||
"false", "finally", "for", "function",
|
||||
"if", "import", "in", "instanceof",
|
||||
"new", "null",
|
||||
"return",
|
||||
"switch",
|
||||
"this", "throw", "true", "try", "typeof",
|
||||
"var", "void",
|
||||
"while", "with",
|
||||
];
|
||||
|
||||
var strictKeywords = {
|
||||
__proto__: null,
|
||||
"implements": true,
|
||||
"interface": true,
|
||||
"let": true,
|
||||
//"module": true,
|
||||
"package": true,
|
||||
"private": true,
|
||||
"protected": true,
|
||||
"public": true,
|
||||
"static": true,
|
||||
"use": true,
|
||||
"yield": true
|
||||
};
|
||||
|
||||
var statementStartTokens = [
|
||||
"break",
|
||||
"const", "continue",
|
||||
"debugger", "do",
|
||||
"for",
|
||||
"if",
|
||||
"let",
|
||||
"return",
|
||||
"switch",
|
||||
"throw", "try",
|
||||
"var",
|
||||
"yield",
|
||||
"while", "with",
|
||||
];
|
||||
|
||||
// Whitespace characters (see ECMA-262 7.2)
|
||||
var whitespaceChars = [
|
||||
// normal whitespace:
|
||||
"\u0009", "\u000B", "\u000C", "\u0020", "\u00A0", "\uFEFF",
|
||||
|
||||
// high-Unicode whitespace:
|
||||
"\u1680", "\u180E",
|
||||
"\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006",
|
||||
"\u2007", "\u2008", "\u2009", "\u200A",
|
||||
"\u202F", "\u205F", "\u3000"
|
||||
];
|
||||
|
||||
var whitespace = {};
|
||||
for (var i = 0; i < whitespaceChars.length; i++) {
|
||||
whitespace[whitespaceChars[i]] = true;
|
||||
}
|
||||
|
||||
// Operator and punctuator mapping from token to tree node type name.
|
||||
// NB: because the lexer doesn't backtrack, all token prefixes must themselves
|
||||
// be valid tokens (e.g. !== is acceptable because its prefixes are the valid
|
||||
// tokens != and !).
|
||||
var opTypeNames = {
|
||||
'\n': "NEWLINE",
|
||||
';': "SEMICOLON",
|
||||
',': "COMMA",
|
||||
'?': "HOOK",
|
||||
':': "COLON",
|
||||
'||': "OR",
|
||||
'&&': "AND",
|
||||
'|': "BITWISE_OR",
|
||||
'^': "BITWISE_XOR",
|
||||
'&': "BITWISE_AND",
|
||||
'===': "STRICT_EQ",
|
||||
'==': "EQ",
|
||||
'=': "ASSIGN",
|
||||
'!==': "STRICT_NE",
|
||||
'!=': "NE",
|
||||
'<<': "LSH",
|
||||
'<=': "LE",
|
||||
'<': "LT",
|
||||
'>>>': "URSH",
|
||||
'>>': "RSH",
|
||||
'>=': "GE",
|
||||
'>': "GT",
|
||||
'++': "INCREMENT",
|
||||
'--': "DECREMENT",
|
||||
'+': "PLUS",
|
||||
'-': "MINUS",
|
||||
'*': "MUL",
|
||||
'/': "DIV",
|
||||
'%': "MOD",
|
||||
'!': "NOT",
|
||||
'~': "BITWISE_NOT",
|
||||
'.': "DOT",
|
||||
'[': "LEFT_BRACKET",
|
||||
']': "RIGHT_BRACKET",
|
||||
'{': "LEFT_CURLY",
|
||||
'}': "RIGHT_CURLY",
|
||||
'(': "LEFT_PAREN",
|
||||
')': "RIGHT_PAREN"
|
||||
};
|
||||
|
||||
// Hash of keyword identifier to tokens index. NB: we must null __proto__ to
|
||||
// avoid toString, etc. namespace pollution.
|
||||
var keywords = {__proto__: null};
|
||||
var mozillaKeywords = {__proto__: null};
|
||||
|
||||
// Define const END, etc., based on the token names. Also map name to index.
|
||||
var tokenIds = {};
|
||||
|
||||
var hostSupportsEvalConst = (function() {
|
||||
try {
|
||||
return eval("(function(s) { eval(s); return x })('const x = true;')");
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
// Building up a string to be eval'd in different contexts.
|
||||
var consts = hostSupportsEvalConst ? "const " : "var ";
|
||||
for (var i = 0, j = tokens.length; i < j; i++) {
|
||||
if (i > 0)
|
||||
consts += ", ";
|
||||
var t = tokens[i];
|
||||
var name;
|
||||
if (/^[a-z]/.test(t)) {
|
||||
name = t.toUpperCase();
|
||||
if (name === "LET" || name === "YIELD")
|
||||
mozillaKeywords[name] = i;
|
||||
if (strictKeywords[name])
|
||||
strictKeywords[name] = i;
|
||||
keywords[t] = i;
|
||||
} else {
|
||||
name = (/^\W/.test(t) ? opTypeNames[t] : t);
|
||||
}
|
||||
consts += name + " = " + i;
|
||||
tokenIds[name] = i;
|
||||
tokens[t] = i;
|
||||
}
|
||||
consts += ";";
|
||||
|
||||
var isStatementStartCode = {__proto__: null};
|
||||
for (i = 0, j = statementStartTokens.length; i < j; i++)
|
||||
isStatementStartCode[keywords[statementStartTokens[i]]] = true;
|
||||
|
||||
// Map assignment operators to their indexes in the tokens array.
|
||||
var assignOps = ['|', '^', '&', '<<', '>>', '>>>', '+', '-', '*', '/', '%'];
|
||||
|
||||
for (i = 0, j = assignOps.length; i < j; i++) {
|
||||
t = assignOps[i];
|
||||
assignOps[t] = tokens[t];
|
||||
}
|
||||
|
||||
function defineGetter(obj, prop, fn, dontDelete, dontEnum) {
|
||||
Object.defineProperty(obj, prop,
|
||||
{ get: fn, configurable: !dontDelete, enumerable: !dontEnum });
|
||||
}
|
||||
|
||||
function defineGetterSetter(obj, prop, getter, setter, dontDelete, dontEnum) {
|
||||
Object.defineProperty(obj, prop, {
|
||||
get: getter,
|
||||
set: setter,
|
||||
configurable: !dontDelete,
|
||||
enumerable: !dontEnum
|
||||
});
|
||||
}
|
||||
|
||||
function defineMemoGetter(obj, prop, fn, dontDelete, dontEnum) {
|
||||
Object.defineProperty(obj, prop, {
|
||||
get: function() {
|
||||
var val = fn();
|
||||
defineProperty(obj, prop, val, dontDelete, true, dontEnum);
|
||||
return val;
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: !dontEnum
|
||||
});
|
||||
}
|
||||
|
||||
function defineProperty(obj, prop, val, dontDelete, readOnly, dontEnum) {
|
||||
Object.defineProperty(obj, prop,
|
||||
{ value: val, writable: !readOnly, configurable: !dontDelete,
|
||||
enumerable: !dontEnum });
|
||||
}
|
||||
|
||||
// Returns true if fn is a native function. (Note: SpiderMonkey specific.)
|
||||
function isNativeCode(fn) {
|
||||
// Relies on the toString method to identify native code.
|
||||
return ((typeof fn) === "function") && fn.toString().match(/\[native code\]/);
|
||||
}
|
||||
|
||||
var Fpapply = Function.prototype.apply;
|
||||
|
||||
function apply(f, o, a) {
|
||||
return Fpapply.call(f, [o].concat(a));
|
||||
}
|
||||
|
||||
var applyNew;
|
||||
|
||||
// ES5's bind is a simpler way to implement applyNew
|
||||
if (Function.prototype.bind) {
|
||||
applyNew = function applyNew(f, a) {
|
||||
return new (f.bind.apply(f, [,].concat(Array.prototype.slice.call(a))))();
|
||||
};
|
||||
} else {
|
||||
applyNew = function applyNew(f, a) {
|
||||
switch (a.length) {
|
||||
case 0:
|
||||
return new f();
|
||||
case 1:
|
||||
return new f(a[0]);
|
||||
case 2:
|
||||
return new f(a[0], a[1]);
|
||||
case 3:
|
||||
return new f(a[0], a[1], a[2]);
|
||||
default:
|
||||
var argStr = "a[0]";
|
||||
for (var i = 1, n = a.length; i < n; i++)
|
||||
argStr += ",a[" + i + "]";
|
||||
return eval("new f(" + argStr + ")");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getPropertyDescriptor(obj, name) {
|
||||
while (obj) {
|
||||
if (({}).hasOwnProperty.call(obj, name))
|
||||
return Object.getOwnPropertyDescriptor(obj, name);
|
||||
obj = Object.getPrototypeOf(obj);
|
||||
}
|
||||
}
|
||||
|
||||
function getPropertyNames(obj) {
|
||||
var table = Object.create(null, {});
|
||||
while (obj) {
|
||||
var names = Object.getOwnPropertyNames(obj);
|
||||
for (var i = 0, n = names.length; i < n; i++)
|
||||
table[names[i]] = true;
|
||||
obj = Object.getPrototypeOf(obj);
|
||||
}
|
||||
return Object.keys(table);
|
||||
}
|
||||
|
||||
function getOwnProperties(obj) {
|
||||
var map = {};
|
||||
for (var name in Object.getOwnPropertyNames(obj))
|
||||
map[name] = Object.getOwnPropertyDescriptor(obj, name);
|
||||
return map;
|
||||
}
|
||||
|
||||
function blacklistHandler(target, blacklist) {
|
||||
var mask = Object.create(null, {});
|
||||
var redirect = Dict.create(blacklist).mapObject(function(name) { return mask; });
|
||||
return mixinHandler(redirect, target);
|
||||
}
|
||||
|
||||
function whitelistHandler(target, whitelist) {
|
||||
var catchall = Object.create(null, {});
|
||||
var redirect = Dict.create(whitelist).mapObject(function(name) { return target; });
|
||||
return mixinHandler(redirect, catchall);
|
||||
}
|
||||
|
||||
/*
|
||||
* Mixin proxies break the single-inheritance model of prototypes, so
|
||||
* the handler treats all properties as own-properties:
|
||||
*
|
||||
* X
|
||||
* |
|
||||
* +------------+------------+
|
||||
* | O |
|
||||
* | | |
|
||||
* | O O O |
|
||||
* | | | | |
|
||||
* | O O O O |
|
||||
* | | | | | |
|
||||
* | O O O O O |
|
||||
* | | | | | | |
|
||||
* +-(*)--(w)--(x)--(y)--(z)-+
|
||||
*/
|
||||
|
||||
function mixinHandler(redirect, catchall) {
|
||||
function targetFor(name) {
|
||||
return hasOwn(redirect, name) ? redirect[name] : catchall;
|
||||
}
|
||||
|
||||
function getMuxPropertyDescriptor(name) {
|
||||
var desc = getPropertyDescriptor(targetFor(name), name);
|
||||
if (desc)
|
||||
desc.configurable = true;
|
||||
return desc;
|
||||
}
|
||||
|
||||
function getMuxPropertyNames() {
|
||||
var names1 = Object.getOwnPropertyNames(redirect).filter(function(name) {
|
||||
return name in redirect[name];
|
||||
});
|
||||
var names2 = getPropertyNames(catchall).filter(function(name) {
|
||||
return !hasOwn(redirect, name);
|
||||
});
|
||||
return names1.concat(names2);
|
||||
}
|
||||
|
||||
function enumerateMux() {
|
||||
var result = Object.getOwnPropertyNames(redirect).filter(function(name) {
|
||||
return name in redirect[name];
|
||||
});
|
||||
for (name in catchall) {
|
||||
if (!hasOwn(redirect, name))
|
||||
result.push(name);
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
function hasMux(name) {
|
||||
return name in targetFor(name);
|
||||
}
|
||||
|
||||
return {
|
||||
getOwnPropertyDescriptor: getMuxPropertyDescriptor,
|
||||
getPropertyDescriptor: getMuxPropertyDescriptor,
|
||||
getOwnPropertyNames: getMuxPropertyNames,
|
||||
defineProperty: function(name, desc) {
|
||||
Object.defineProperty(targetFor(name), name, desc);
|
||||
},
|
||||
"delete": function(name) {
|
||||
var target = targetFor(name);
|
||||
return delete target[name];
|
||||
},
|
||||
// FIXME: ha ha ha
|
||||
fix: function() { },
|
||||
has: hasMux,
|
||||
hasOwn: hasMux,
|
||||
get: function(receiver, name) {
|
||||
var target = targetFor(name);
|
||||
return target[name];
|
||||
},
|
||||
set: function(receiver, name, val) {
|
||||
var target = targetFor(name);
|
||||
target[name] = val;
|
||||
return true;
|
||||
},
|
||||
enumerate: enumerateMux,
|
||||
keys: enumerateMux
|
||||
};
|
||||
}
|
||||
|
||||
function makePassthruHandler(obj) {
|
||||
// Handler copied from
|
||||
// http://wiki.ecmascript.org/doku.php?id=harmony:proxies&s=proxy%20object#examplea_no-op_forwarding_proxy
|
||||
return {
|
||||
getOwnPropertyDescriptor: function(name) {
|
||||
var desc = Object.getOwnPropertyDescriptor(obj, name);
|
||||
|
||||
// a trapping proxy's properties must always be configurable
|
||||
desc.configurable = true;
|
||||
return desc;
|
||||
},
|
||||
getPropertyDescriptor: function(name) {
|
||||
var desc = getPropertyDescriptor(obj, name);
|
||||
|
||||
// a trapping proxy's properties must always be configurable
|
||||
desc.configurable = true;
|
||||
return desc;
|
||||
},
|
||||
getOwnPropertyNames: function() {
|
||||
return Object.getOwnPropertyNames(obj);
|
||||
},
|
||||
defineProperty: function(name, desc) {
|
||||
Object.defineProperty(obj, name, desc);
|
||||
},
|
||||
"delete": function(name) { return delete obj[name]; },
|
||||
fix: function() {
|
||||
if (Object.isFrozen(obj)) {
|
||||
return getOwnProperties(obj);
|
||||
}
|
||||
|
||||
// As long as obj is not frozen, the proxy won't allow itself to be fixed.
|
||||
return undefined; // will cause a TypeError to be thrown
|
||||
},
|
||||
|
||||
has: function(name) { return name in obj; },
|
||||
hasOwn: function(name) { return ({}).hasOwnProperty.call(obj, name); },
|
||||
get: function(receiver, name) { return obj[name]; },
|
||||
|
||||
// bad behavior when set fails in non-strict mode
|
||||
set: function(receiver, name, val) { obj[name] = val; return true; },
|
||||
enumerate: function() {
|
||||
var result = [];
|
||||
for (name in obj) { result.push(name); };
|
||||
return result;
|
||||
},
|
||||
keys: function() { return Object.keys(obj); }
|
||||
};
|
||||
}
|
||||
|
||||
var hasOwnProperty = ({}).hasOwnProperty;
|
||||
|
||||
function hasOwn(obj, name) {
|
||||
return hasOwnProperty.call(obj, name);
|
||||
}
|
||||
|
||||
function Dict(table, size) {
|
||||
this.table = table || Object.create(null, {});
|
||||
this.size = size || 0;
|
||||
}
|
||||
|
||||
Dict.create = function(table) {
|
||||
var init = Object.create(null, {});
|
||||
var size = 0;
|
||||
var names = Object.getOwnPropertyNames(table);
|
||||
for (var i = 0, n = names.length; i < n; i++) {
|
||||
var name = names[i];
|
||||
init[name] = table[name];
|
||||
size++;
|
||||
}
|
||||
return new Dict(init, size);
|
||||
};
|
||||
|
||||
Dict.prototype = {
|
||||
has: function(x) { return hasOwnProperty.call(this.table, x); },
|
||||
set: function(x, v) {
|
||||
if (!hasOwnProperty.call(this.table, x))
|
||||
this.size++;
|
||||
this.table[x] = v;
|
||||
},
|
||||
get: function(x) { return this.table[x]; },
|
||||
getDef: function(x, thunk) {
|
||||
if (!hasOwnProperty.call(this.table, x)) {
|
||||
this.size++;
|
||||
this.table[x] = thunk();
|
||||
}
|
||||
return this.table[x];
|
||||
},
|
||||
forEach: function(f) {
|
||||
var table = this.table;
|
||||
for (var key in table)
|
||||
f.call(this, key, table[key]);
|
||||
},
|
||||
map: function(f) {
|
||||
var table1 = this.table;
|
||||
var table2 = Object.create(null, {});
|
||||
this.forEach(function(key, val) {
|
||||
table2[key] = f.call(this, val, key);
|
||||
});
|
||||
return new Dict(table2, this.size);
|
||||
},
|
||||
mapObject: function(f) {
|
||||
var table1 = this.table;
|
||||
var table2 = Object.create(null, {});
|
||||
this.forEach(function(key, val) {
|
||||
table2[key] = f.call(this, val, key);
|
||||
});
|
||||
return table2;
|
||||
},
|
||||
toObject: function() {
|
||||
return this.mapObject(function(val) { return val; });
|
||||
},
|
||||
choose: function() {
|
||||
return Object.getOwnPropertyNames(this.table)[0];
|
||||
},
|
||||
remove: function(x) {
|
||||
if (hasOwnProperty.call(this.table, x)) {
|
||||
this.size--;
|
||||
delete this.table[x];
|
||||
}
|
||||
},
|
||||
copy: function() {
|
||||
var table = Object.create(null, {});
|
||||
for (var key in this.table)
|
||||
table[key] = this.table[key];
|
||||
return new Dict(table, this.size);
|
||||
},
|
||||
keys: function() {
|
||||
return Object.keys(this.table);
|
||||
},
|
||||
toString: function() { return "[object Dict]" }
|
||||
};
|
||||
|
||||
var _WeakMap = typeof WeakMap === "function" ? WeakMap : (function() {
|
||||
// shim for ES6 WeakMap with poor asymptotics
|
||||
function WeakMap(array) {
|
||||
this.array = array || [];
|
||||
}
|
||||
|
||||
function searchMap(map, key, found, notFound) {
|
||||
var a = map.array;
|
||||
for (var i = 0, n = a.length; i < n; i++) {
|
||||
var pair = a[i];
|
||||
if (pair.key === key)
|
||||
return found(pair, i);
|
||||
}
|
||||
return notFound();
|
||||
}
|
||||
|
||||
WeakMap.prototype = {
|
||||
has: function(x) {
|
||||
return searchMap(this, x, function() { return true }, function() { return false });
|
||||
},
|
||||
set: function(x, v) {
|
||||
var a = this.array;
|
||||
searchMap(this, x,
|
||||
function(pair) { pair.value = v },
|
||||
function() { a.push({ key: x, value: v }) });
|
||||
},
|
||||
get: function(x) {
|
||||
return searchMap(this, x,
|
||||
function(pair) { return pair.value },
|
||||
function() { return null });
|
||||
},
|
||||
"delete": function(x) {
|
||||
var a = this.array;
|
||||
searchMap(this, x,
|
||||
function(pair, i) { a.splice(i, 1) },
|
||||
function() { });
|
||||
},
|
||||
toString: function() { return "[object WeakMap]" }
|
||||
};
|
||||
|
||||
return WeakMap;
|
||||
})();
|
||||
|
||||
// non-destructive stack
|
||||
function Stack(elts) {
|
||||
this.elts = elts || null;
|
||||
}
|
||||
|
||||
Stack.prototype = {
|
||||
push: function(x) {
|
||||
return new Stack({ top: x, rest: this.elts });
|
||||
},
|
||||
top: function() {
|
||||
if (!this.elts)
|
||||
throw new Error("empty stack");
|
||||
return this.elts.top;
|
||||
},
|
||||
isEmpty: function() {
|
||||
return this.top === null;
|
||||
},
|
||||
find: function(test) {
|
||||
for (var elts = this.elts; elts; elts = elts.rest) {
|
||||
if (test(elts.top))
|
||||
return elts.top;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
has: function(x) {
|
||||
return Boolean(this.find(function(elt) { return elt === x }));
|
||||
},
|
||||
forEach: function(f) {
|
||||
for (var elts = this.elts; elts; elts = elts.rest) {
|
||||
f(elts.top);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (!Array.prototype.copy) {
|
||||
defineProperty(Array.prototype, "copy",
|
||||
function() {
|
||||
var result = [];
|
||||
for (var i = 0, n = this.length; i < n; i++)
|
||||
result[i] = this[i];
|
||||
return result;
|
||||
}, false, false, true);
|
||||
}
|
||||
|
||||
if (!Array.prototype.top) {
|
||||
defineProperty(Array.prototype, "top",
|
||||
function() {
|
||||
return this.length && this[this.length-1];
|
||||
}, false, false, true);
|
||||
}
|
||||
|
||||
exports.tokens = tokens;
|
||||
exports.whitespace = whitespace;
|
||||
exports.opTypeNames = opTypeNames;
|
||||
exports.keywords = keywords;
|
||||
exports.mozillaKeywords = mozillaKeywords;
|
||||
exports.strictKeywords = strictKeywords;
|
||||
exports.isStatementStartCode = isStatementStartCode;
|
||||
exports.tokenIds = tokenIds;
|
||||
exports.consts = consts;
|
||||
exports.assignOps = assignOps;
|
||||
exports.defineGetter = defineGetter;
|
||||
exports.defineGetterSetter = defineGetterSetter;
|
||||
exports.defineMemoGetter = defineMemoGetter;
|
||||
exports.defineProperty = defineProperty;
|
||||
exports.isNativeCode = isNativeCode;
|
||||
exports.apply = apply;
|
||||
exports.applyNew = applyNew;
|
||||
exports.mixinHandler = mixinHandler;
|
||||
exports.whitelistHandler = whitelistHandler;
|
||||
exports.blacklistHandler = blacklistHandler;
|
||||
exports.makePassthruHandler = makePassthruHandler;
|
||||
exports.Dict = Dict;
|
||||
exports.WeakMap = _WeakMap;
|
||||
exports.Stack = Stack;
|
||||
|
||||
});
|
||||
|
|
@ -1,584 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2010, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* Narcissus - JS implemented in JS.
|
||||
*
|
||||
* Lexical scanner.
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var definitions = require('./definitions');
|
||||
|
||||
// Set constants in the local scope.
|
||||
eval(definitions.consts);
|
||||
|
||||
// Build up a trie of operator tokens.
|
||||
var opTokens = {};
|
||||
for (var op in definitions.opTypeNames) {
|
||||
if (op === '\n' || op === '.')
|
||||
continue;
|
||||
|
||||
var node = opTokens;
|
||||
for (var i = 0; i < op.length; i++) {
|
||||
var ch = op[i];
|
||||
if (!(ch in node))
|
||||
node[ch] = {};
|
||||
node = node[ch];
|
||||
node.op = op;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Since JavaScript provides no convenient way to determine if a
|
||||
* character is in a particular Unicode category, we use
|
||||
* metacircularity to accomplish this (oh yeaaaah!)
|
||||
*/
|
||||
function isValidIdentifierChar(ch, first) {
|
||||
// check directly for ASCII
|
||||
if (ch <= "\u007F") {
|
||||
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch === '$' || ch === '_' ||
|
||||
(!first && (ch >= '0' && ch <= '9'))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// create an object to test this in
|
||||
var x = {};
|
||||
x["x"+ch] = true;
|
||||
x[ch] = true;
|
||||
|
||||
// then use eval to determine if it's a valid character
|
||||
var valid = false;
|
||||
try {
|
||||
valid = (Function("x", "return (x." + (first?"":"x") + ch + ");")(x) === true);
|
||||
} catch (ex) {}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
function isIdentifier(str) {
|
||||
if (typeof str !== "string")
|
||||
return false;
|
||||
|
||||
if (str.length === 0)
|
||||
return false;
|
||||
|
||||
if (!isValidIdentifierChar(str[0], true))
|
||||
return false;
|
||||
|
||||
for (var i = 1; i < str.length; i++) {
|
||||
if (!isValidIdentifierChar(str[i], false))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tokenizer :: (source, filename, line number, boolean) -> Tokenizer
|
||||
*/
|
||||
function Tokenizer(s, f, l, allowHTMLComments) {
|
||||
this.cursor = 0;
|
||||
this.source = String(s);
|
||||
this.tokens = [];
|
||||
this.tokenIndex = 0;
|
||||
this.lookahead = 0;
|
||||
this.scanNewlines = false;
|
||||
this.filename = f || "";
|
||||
this.lineno = l || 1;
|
||||
this.allowHTMLComments = allowHTMLComments;
|
||||
this.blockComments = null;
|
||||
}
|
||||
|
||||
Tokenizer.prototype = {
|
||||
get done() {
|
||||
// We need to set scanOperand to true here because the first thing
|
||||
// might be a regexp.
|
||||
return this.peek(true) === END;
|
||||
},
|
||||
|
||||
get token() {
|
||||
return this.tokens[this.tokenIndex];
|
||||
},
|
||||
|
||||
match: function (tt, scanOperand, keywordIsName) {
|
||||
return this.get(scanOperand, keywordIsName) === tt || this.unget();
|
||||
},
|
||||
|
||||
mustMatch: function (tt, keywordIsName) {
|
||||
if (!this.match(tt, false, keywordIsName)) {
|
||||
throw this.newSyntaxError("Missing " +
|
||||
definitions.tokens[tt].toLowerCase());
|
||||
}
|
||||
return this.token;
|
||||
},
|
||||
|
||||
peek: function (scanOperand) {
|
||||
var tt, next;
|
||||
if (this.lookahead) {
|
||||
next = this.tokens[(this.tokenIndex + this.lookahead) & 3];
|
||||
tt = (this.scanNewlines && next.lineno !== this.lineno)
|
||||
? NEWLINE
|
||||
: next.type;
|
||||
} else {
|
||||
tt = this.get(scanOperand);
|
||||
this.unget();
|
||||
}
|
||||
return tt;
|
||||
},
|
||||
|
||||
peekOnSameLine: function (scanOperand) {
|
||||
this.scanNewlines = true;
|
||||
var tt = this.peek(scanOperand);
|
||||
this.scanNewlines = false;
|
||||
return tt;
|
||||
},
|
||||
|
||||
lastBlockComment: function() {
|
||||
var length = this.blockComments.length;
|
||||
return length ? this.blockComments[length - 1] : null;
|
||||
},
|
||||
|
||||
// Eat comments and whitespace.
|
||||
skip: function () {
|
||||
var input = this.source;
|
||||
this.blockComments = [];
|
||||
for (;;) {
|
||||
var ch = input[this.cursor++];
|
||||
var next = input[this.cursor];
|
||||
// handle \r, \r\n and (always preferable) \n
|
||||
if (ch === '\r') {
|
||||
// if the next character is \n, we don't care about this at all
|
||||
if (next === '\n') continue;
|
||||
|
||||
// otherwise, we want to consider this as a newline
|
||||
ch = '\n';
|
||||
}
|
||||
|
||||
if (ch === '\n' && !this.scanNewlines) {
|
||||
this.lineno++;
|
||||
} else if (ch === '/' && next === '*') {
|
||||
var commentStart = ++this.cursor;
|
||||
for (;;) {
|
||||
ch = input[this.cursor++];
|
||||
if (ch === undefined)
|
||||
throw this.newSyntaxError("Unterminated comment");
|
||||
|
||||
if (ch === '*') {
|
||||
next = input[this.cursor];
|
||||
if (next === '/') {
|
||||
var commentEnd = this.cursor - 1;
|
||||
this.cursor++;
|
||||
break;
|
||||
}
|
||||
} else if (ch === '\n') {
|
||||
this.lineno++;
|
||||
}
|
||||
}
|
||||
this.blockComments.push(input.substring(commentStart, commentEnd));
|
||||
} else if ((ch === '/' && next === '/') ||
|
||||
(this.allowHTMLComments && ch === '<' && next === '!' &&
|
||||
input[this.cursor + 1] === '-' && input[this.cursor + 2] === '-' &&
|
||||
(this.cursor += 2))) {
|
||||
this.cursor++;
|
||||
for (;;) {
|
||||
ch = input[this.cursor++];
|
||||
next = input[this.cursor];
|
||||
if (ch === undefined)
|
||||
return;
|
||||
|
||||
if (ch === '\r') {
|
||||
// check for \r\n
|
||||
if (next !== '\n') ch = '\n';
|
||||
}
|
||||
|
||||
if (ch === '\n') {
|
||||
if (this.scanNewlines) {
|
||||
this.cursor--;
|
||||
} else {
|
||||
this.lineno++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (!(ch in definitions.whitespace)) {
|
||||
this.cursor--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Lex the exponential part of a number, if present. Return true iff an
|
||||
// exponential part was found.
|
||||
lexExponent: function() {
|
||||
var input = this.source;
|
||||
var next = input[this.cursor];
|
||||
if (next === 'e' || next === 'E') {
|
||||
this.cursor++;
|
||||
ch = input[this.cursor++];
|
||||
if (ch === '+' || ch === '-')
|
||||
ch = input[this.cursor++];
|
||||
|
||||
if (ch < '0' || ch > '9')
|
||||
throw this.newSyntaxError("Missing exponent");
|
||||
|
||||
do {
|
||||
ch = input[this.cursor++];
|
||||
} while (ch >= '0' && ch <= '9');
|
||||
this.cursor--;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
lexZeroNumber: function (ch) {
|
||||
var token = this.token, input = this.source;
|
||||
token.type = NUMBER;
|
||||
|
||||
ch = input[this.cursor++];
|
||||
if (ch === '.') {
|
||||
do {
|
||||
ch = input[this.cursor++];
|
||||
} while (ch >= '0' && ch <= '9');
|
||||
this.cursor--;
|
||||
|
||||
this.lexExponent();
|
||||
token.value = parseFloat(
|
||||
input.substring(token.start, this.cursor));
|
||||
} else if (ch === 'x' || ch === 'X') {
|
||||
do {
|
||||
ch = input[this.cursor++];
|
||||
} while ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') ||
|
||||
(ch >= 'A' && ch <= 'F'));
|
||||
this.cursor--;
|
||||
|
||||
token.value = parseInt(input.substring(token.start, this.cursor));
|
||||
} else if (ch >= '0' && ch <= '7') {
|
||||
do {
|
||||
ch = input[this.cursor++];
|
||||
} while (ch >= '0' && ch <= '7');
|
||||
this.cursor--;
|
||||
|
||||
token.value = parseInt(input.substring(token.start, this.cursor));
|
||||
} else {
|
||||
this.cursor--;
|
||||
this.lexExponent(); // 0E1, &c.
|
||||
token.value = 0;
|
||||
}
|
||||
},
|
||||
|
||||
lexNumber: function (ch) {
|
||||
var token = this.token, input = this.source;
|
||||
token.type = NUMBER;
|
||||
|
||||
var floating = false;
|
||||
do {
|
||||
ch = input[this.cursor++];
|
||||
if (ch === '.' && !floating) {
|
||||
floating = true;
|
||||
ch = input[this.cursor++];
|
||||
}
|
||||
} while (ch >= '0' && ch <= '9');
|
||||
|
||||
this.cursor--;
|
||||
|
||||
var exponent = this.lexExponent();
|
||||
floating = floating || exponent;
|
||||
|
||||
var str = input.substring(token.start, this.cursor);
|
||||
token.value = floating ? parseFloat(str) : parseInt(str);
|
||||
},
|
||||
|
||||
lexDot: function (ch) {
|
||||
var token = this.token, input = this.source;
|
||||
var next = input[this.cursor];
|
||||
if (next >= '0' && next <= '9') {
|
||||
do {
|
||||
ch = input[this.cursor++];
|
||||
} while (ch >= '0' && ch <= '9');
|
||||
this.cursor--;
|
||||
|
||||
this.lexExponent();
|
||||
|
||||
token.type = NUMBER;
|
||||
token.value = parseFloat(
|
||||
input.substring(token.start, this.cursor));
|
||||
} else {
|
||||
token.type = DOT;
|
||||
token.assignOp = null;
|
||||
token.value = '.';
|
||||
}
|
||||
},
|
||||
|
||||
lexString: function (ch) {
|
||||
var token = this.token, input = this.source;
|
||||
token.type = STRING;
|
||||
|
||||
var hasEscapes = false;
|
||||
var delim = ch;
|
||||
if (input.length <= this.cursor)
|
||||
throw this.newSyntaxError("Unterminated string literal");
|
||||
while ((ch = input[this.cursor++]) !== delim) {
|
||||
if (ch == '\n' || ch == '\r')
|
||||
throw this.newSyntaxError("Unterminated string literal");
|
||||
if (this.cursor == input.length)
|
||||
throw this.newSyntaxError("Unterminated string literal");
|
||||
if (ch === '\\') {
|
||||
hasEscapes = true;
|
||||
if (++this.cursor == input.length)
|
||||
throw this.newSyntaxError("Unterminated string literal");
|
||||
}
|
||||
}
|
||||
|
||||
token.value = hasEscapes
|
||||
? eval(input.substring(token.start, this.cursor))
|
||||
: input.substring(token.start + 1, this.cursor - 1);
|
||||
},
|
||||
|
||||
lexRegExp: function (ch) {
|
||||
var token = this.token, input = this.source;
|
||||
token.type = REGEXP;
|
||||
|
||||
do {
|
||||
ch = input[this.cursor++];
|
||||
if (ch === '\\') {
|
||||
this.cursor++;
|
||||
} else if (ch === '[') {
|
||||
do {
|
||||
if (ch === undefined)
|
||||
throw this.newSyntaxError("Unterminated character class");
|
||||
|
||||
if (ch === '\\')
|
||||
this.cursor++;
|
||||
|
||||
ch = input[this.cursor++];
|
||||
} while (ch !== ']');
|
||||
} else if (ch === undefined) {
|
||||
throw this.newSyntaxError("Unterminated regex");
|
||||
}
|
||||
} while (ch !== '/');
|
||||
|
||||
do {
|
||||
ch = input[this.cursor++];
|
||||
} while (ch >= 'a' && ch <= 'z');
|
||||
|
||||
this.cursor--;
|
||||
|
||||
token.value = eval(input.substring(token.start, this.cursor));
|
||||
},
|
||||
|
||||
lexOp: function (ch) {
|
||||
var token = this.token, input = this.source;
|
||||
|
||||
// A bit ugly, but it seems wasteful to write a trie lookup routine
|
||||
// for only 3 characters...
|
||||
var node = opTokens[ch];
|
||||
var next = input[this.cursor];
|
||||
if (next in node) {
|
||||
node = node[next];
|
||||
this.cursor++;
|
||||
next = input[this.cursor];
|
||||
if (next in node) {
|
||||
node = node[next];
|
||||
this.cursor++;
|
||||
next = input[this.cursor];
|
||||
}
|
||||
}
|
||||
|
||||
var op = node.op;
|
||||
if (definitions.assignOps[op] && input[this.cursor] === '=') {
|
||||
this.cursor++;
|
||||
token.type = ASSIGN;
|
||||
token.assignOp = definitions.tokenIds[definitions.opTypeNames[op]];
|
||||
op += '=';
|
||||
} else {
|
||||
token.type = definitions.tokenIds[definitions.opTypeNames[op]];
|
||||
token.assignOp = null;
|
||||
}
|
||||
|
||||
token.value = op;
|
||||
},
|
||||
|
||||
// FIXME: Unicode escape sequences
|
||||
lexIdent: function (ch, keywordIsName) {
|
||||
var token = this.token;
|
||||
var id = ch;
|
||||
|
||||
while ((ch = this.getValidIdentifierChar(false)) !== null) {
|
||||
id += ch;
|
||||
}
|
||||
|
||||
token.type = IDENTIFIER;
|
||||
token.value = id;
|
||||
|
||||
if (keywordIsName)
|
||||
return;
|
||||
|
||||
var kw;
|
||||
|
||||
if (this.parser.mozillaMode) {
|
||||
kw = definitions.mozillaKeywords[id];
|
||||
if (kw) {
|
||||
token.type = kw;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.parser.x.strictMode) {
|
||||
kw = definitions.strictKeywords[id];
|
||||
if (kw) {
|
||||
token.type = kw;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
kw = definitions.keywords[id];
|
||||
if (kw)
|
||||
token.type = kw;
|
||||
},
|
||||
|
||||
/*
|
||||
* Tokenizer.get :: ([boolean[, boolean]]) -> token type
|
||||
*
|
||||
* Consume input *only* if there is no lookahead.
|
||||
* Dispatch to the appropriate lexing function depending on the input.
|
||||
*/
|
||||
get: function (scanOperand, keywordIsName) {
|
||||
var token;
|
||||
while (this.lookahead) {
|
||||
--this.lookahead;
|
||||
this.tokenIndex = (this.tokenIndex + 1) & 3;
|
||||
token = this.tokens[this.tokenIndex];
|
||||
if (token.type !== NEWLINE || this.scanNewlines)
|
||||
return token.type;
|
||||
}
|
||||
|
||||
this.skip();
|
||||
|
||||
this.tokenIndex = (this.tokenIndex + 1) & 3;
|
||||
token = this.tokens[this.tokenIndex];
|
||||
if (!token)
|
||||
this.tokens[this.tokenIndex] = token = {};
|
||||
|
||||
var input = this.source;
|
||||
if (this.cursor >= input.length)
|
||||
return token.type = END;
|
||||
|
||||
token.start = this.cursor;
|
||||
token.lineno = this.lineno;
|
||||
|
||||
var ich = this.getValidIdentifierChar(true);
|
||||
var ch = (ich === null) ? input[this.cursor++] : null;
|
||||
if (ich !== null) {
|
||||
this.lexIdent(ich, keywordIsName);
|
||||
} else if (scanOperand && ch === '/') {
|
||||
this.lexRegExp(ch);
|
||||
} else if (ch in opTokens) {
|
||||
this.lexOp(ch);
|
||||
} else if (ch === '.') {
|
||||
this.lexDot(ch);
|
||||
} else if (ch >= '1' && ch <= '9') {
|
||||
this.lexNumber(ch);
|
||||
} else if (ch === '0') {
|
||||
this.lexZeroNumber(ch);
|
||||
} else if (ch === '"' || ch === "'") {
|
||||
this.lexString(ch);
|
||||
} else if (this.scanNewlines && (ch === '\n' || ch === '\r')) {
|
||||
// if this was a \r, look for \r\n
|
||||
if (ch === '\r' && input[this.cursor] === '\n') this.cursor++;
|
||||
token.type = NEWLINE;
|
||||
token.value = '\n';
|
||||
this.lineno++;
|
||||
} else {
|
||||
throw this.newSyntaxError("Illegal token");
|
||||
}
|
||||
|
||||
token.end = this.cursor;
|
||||
return token.type;
|
||||
},
|
||||
|
||||
/*
|
||||
* Tokenizer.unget :: void -> undefined
|
||||
*
|
||||
* Match depends on unget returning undefined.
|
||||
*/
|
||||
unget: function () {
|
||||
if (++this.lookahead === 4) throw "PANIC: too much lookahead!";
|
||||
this.tokenIndex = (this.tokenIndex - 1) & 3;
|
||||
},
|
||||
|
||||
newSyntaxError: function (m) {
|
||||
m = (this.filename ? this.filename + ":" : "") + this.lineno + ": " + m;
|
||||
var e = new SyntaxError(m, this.filename, this.lineno);
|
||||
e.source = this.source;
|
||||
e.cursor = this.lookahead
|
||||
? this.tokens[(this.tokenIndex + this.lookahead) & 3].start
|
||||
: this.cursor;
|
||||
return e;
|
||||
},
|
||||
|
||||
|
||||
/* Gets a single valid identifier char from the input stream, or null
|
||||
* if there is none.
|
||||
*/
|
||||
getValidIdentifierChar: function(first) {
|
||||
var input = this.source;
|
||||
if (this.cursor >= input.length) return null;
|
||||
var ch = input[this.cursor];
|
||||
|
||||
// first check for \u escapes
|
||||
if (ch === '\\' && input[this.cursor+1] === 'u') {
|
||||
// get the character value
|
||||
try {
|
||||
ch = String.fromCharCode(parseInt(
|
||||
input.substring(this.cursor + 2, this.cursor + 6),
|
||||
16));
|
||||
} catch (ex) {
|
||||
return null;
|
||||
}
|
||||
this.cursor += 5;
|
||||
}
|
||||
|
||||
var valid = isValidIdentifierChar(ch, first);
|
||||
if (valid) this.cursor++;
|
||||
return (valid ? ch : null);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
exports.isIdentifier = isIdentifier;
|
||||
exports.Tokenizer = Tokenizer;
|
||||
|
||||
});
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -30,7 +30,7 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var Range = require('./range').Range;
|
||||
var Range = require("./range").Range;
|
||||
var EventEmitter = require("./lib/event_emitter").EventEmitter;
|
||||
var oop = require("./lib/oop");
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ var Editor = require("./editor").Editor;
|
|||
var MockRenderer = require("./test/mockrenderer").MockRenderer;
|
||||
var assert = require("./test/assertions");
|
||||
var JavaScriptMode = require("./mode/javascript").Mode;
|
||||
var PlaceHolder = require('./placeholder').PlaceHolder;
|
||||
var UndoManager = require('./undomanager').UndoManager;
|
||||
var PlaceHolder = require("./placeholder").PlaceHolder;
|
||||
var UndoManager = require("./undomanager").UndoManager;
|
||||
|
||||
module.exports = {
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ define(function (require, exports, module) {
|
|||
if (globalRequire && globalRequire.nodeRequire)
|
||||
onLoad(globalRequire.nodeRequire('fs').readFileSync(req.toUrl(name), 'utf8'));
|
||||
else
|
||||
require("ace/lib/net").get(req.toUrl(name), onLoad);
|
||||
require("../lib/net").get(req.toUrl(name), onLoad);
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ module.exports = {
|
|||
"test: configure the search object" : function() {
|
||||
var search = new Search();
|
||||
search.set({
|
||||
needle: "juhu",
|
||||
needle: "juhu"
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ module.exports = {
|
|||
var search = new Search().set({
|
||||
needle: "[ ]+$",
|
||||
regExp: true,
|
||||
wrap: true,
|
||||
wrap: true
|
||||
});
|
||||
|
||||
session.getSelection().moveCursorTo(1, 2);
|
||||
|
|
@ -414,7 +414,7 @@ module.exports = {
|
|||
var search = new Search().set({
|
||||
needle: "foo",
|
||||
wrap: true,
|
||||
wholeWord: true,
|
||||
wholeWord: true
|
||||
});
|
||||
|
||||
session.getSelection().moveCursorTo(0, 4);
|
||||
|
|
@ -437,7 +437,7 @@ module.exports = {
|
|||
needle: "foo",
|
||||
wrap: true,
|
||||
wholeWord: true,
|
||||
backwards: true,
|
||||
backwards: true
|
||||
});
|
||||
|
||||
session.getSelection().moveCursorTo(0, 13);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = true;
|
||||
exports.cssClass = "ace-ambiance";
|
||||
exports.cssText = require("ace/requirejs/text!./ambiance.css");
|
||||
exports.cssText = require("../requirejs/text!./ambiance.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -22,41 +22,41 @@
|
|||
border-bottom: 1px solid black;
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_invisible {
|
||||
.ace-chrome .ace_invisible {
|
||||
color: rgb(191, 191, 191);
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_constant.ace_buildin {
|
||||
.ace-chrome .ace_constant.ace_buildin {
|
||||
color: rgb(88, 72, 246);
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_constant.ace_language {
|
||||
.ace-chrome .ace_constant.ace_language {
|
||||
color: rgb(88, 92, 246);
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_constant.ace_library {
|
||||
.ace-chrome .ace_constant.ace_library {
|
||||
color: rgb(6, 150, 14);
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_invalid {
|
||||
.ace-chrome .ace_invalid {
|
||||
background-color: rgb(153, 0, 0);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_fold {
|
||||
.ace-chrome .ace_fold {
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_support.ace_function {
|
||||
.ace-chrome .ace_support.ace_function {
|
||||
color: rgb(60, 76, 114);
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_support.ace_constant {
|
||||
.ace-chrome .ace_support.ace_constant {
|
||||
color: rgb(6, 150, 14);
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_support.ace_type,
|
||||
.ace-chrome .ace_line .ace_support.ace_class
|
||||
.ace-chrome .ace_line .ace_support.ace_other {
|
||||
.ace-chrome .ace_support.ace_type,
|
||||
.ace-chrome .ace_support.ace_class
|
||||
.ace-chrome .ace_support.ace_other {
|
||||
color: rgb(109, 121, 222);
|
||||
}
|
||||
|
||||
|
|
@ -64,31 +64,31 @@
|
|||
font-style:italic;
|
||||
color:#FD971F;
|
||||
}
|
||||
.ace-chrome .ace_line .ace_keyword.ace_operator {
|
||||
.ace-chrome .ace_keyword.ace_operator {
|
||||
color: rgb(104, 118, 135);
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_comment {
|
||||
.ace-chrome .ace_comment {
|
||||
color: #236e24;
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_comment.ace_doc {
|
||||
.ace-chrome .ace_comment.ace_doc {
|
||||
color: #236e24;
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_comment.ace_doc.ace_tag {
|
||||
.ace-chrome .ace_comment.ace_doc.ace_tag {
|
||||
color: #236e24;
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_constant.ace_numeric {
|
||||
.ace-chrome .ace_constant.ace_numeric {
|
||||
color: rgb(0, 0, 205);
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_variable {
|
||||
.ace-chrome .ace_variable {
|
||||
color: rgb(49, 132, 149);
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_xml-pe {
|
||||
.ace-chrome .ace_xml-pe {
|
||||
color: rgb(104, 104, 91);
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +136,7 @@
|
|||
}
|
||||
|
||||
.ace-chrome .ace_storage,
|
||||
.ace-chrome .ace_line .ace_keyword,
|
||||
.ace-chrome .ace_keyword,
|
||||
.ace-chrome .ace_meta.ace_tag {
|
||||
color: rgb(147, 15, 128);
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@
|
|||
color: rgb(255, 0, 0)
|
||||
}
|
||||
|
||||
.ace-chrome .ace_line .ace_string {
|
||||
.ace-chrome .ace_string {
|
||||
color: #1A1AA6;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = false;
|
||||
exports.cssClass = "ace-chrome";
|
||||
exports.cssText = require('ace/requirejs/text!./chrome.css');
|
||||
exports.cssText = require("../requirejs/text!./chrome.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = false;
|
||||
exports.cssClass = "ace-clouds";
|
||||
exports.cssText = require('ace/requirejs/text!./clouds.css');
|
||||
exports.cssText = require("../requirejs/text!./clouds.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = true;
|
||||
exports.cssClass = "ace-clouds-midnight";
|
||||
exports.cssText = require('ace/requirejs/text!./clouds_midnight.css');
|
||||
exports.cssText = require("../requirejs/text!./clouds_midnight.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -97,6 +97,14 @@
|
|||
color: #FFEE80
|
||||
}
|
||||
|
||||
.ace-cobalt .ace_entity {
|
||||
color: #FFDD00
|
||||
}
|
||||
|
||||
.ace-cobalt .ace_string {
|
||||
color: #3AD900
|
||||
}
|
||||
|
||||
.ace-cobalt .ace_string.ace_regexp {
|
||||
color: #80FFC2
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = true;
|
||||
exports.cssClass = "ace-cobalt";
|
||||
exports.cssText = require('ace/requirejs/text!./cobalt.css');
|
||||
exports.cssText = require("../requirejs/text!./cobalt.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -31,80 +31,80 @@
|
|||
border-bottom: 1px solid black;
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_invisible {
|
||||
.ace-crimson-editor .ace_invisible {
|
||||
color: rgb(191, 191, 191);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_identifier {
|
||||
.ace-crimson-editor .ace_identifier {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_keyword {
|
||||
.ace-crimson-editor .ace_keyword {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_constant.ace_buildin {
|
||||
.ace-crimson-editor .ace_constant.ace_buildin {
|
||||
color: rgb(88, 72, 246);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_constant.ace_language {
|
||||
.ace-crimson-editor .ace_constant.ace_language {
|
||||
color: rgb(255, 156, 0);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_constant.ace_library {
|
||||
.ace-crimson-editor .ace_constant.ace_library {
|
||||
color: rgb(6, 150, 14);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_invalid {
|
||||
.ace-crimson-editor .ace_invalid {
|
||||
text-decoration: line-through;
|
||||
color: rgb(224, 0, 0);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_fold {
|
||||
.ace-crimson-editor .ace_fold {
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_support.ace_function {
|
||||
.ace-crimson-editor .ace_support.ace_function {
|
||||
color: rgb(192, 0, 0);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_support.ace_constant {
|
||||
.ace-crimson-editor .ace_support.ace_constant {
|
||||
color: rgb(6, 150, 14);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_support.ace_type,
|
||||
.ace-crimson-editor .ace_line .ace_support.ace_class {
|
||||
.ace-crimson-editor .ace_support.ace_type,
|
||||
.ace-crimson-editor .ace_support.ace_class {
|
||||
color: rgb(109, 121, 222);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_keyword.ace_operator {
|
||||
.ace-crimson-editor .ace_keyword.ace_operator {
|
||||
color: rgb(49, 132, 149);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_string {
|
||||
.ace-crimson-editor .ace_string {
|
||||
color: rgb(128, 0, 128);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_comment {
|
||||
.ace-crimson-editor .ace_comment {
|
||||
color: rgb(76, 136, 107);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_comment.ace_doc {
|
||||
.ace-crimson-editor .ace_comment.ace_doc {
|
||||
color: rgb(0, 102, 255);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_comment.ace_doc.ace_tag {
|
||||
.ace-crimson-editor .ace_comment.ace_doc.ace_tag {
|
||||
color: rgb(128, 159, 191);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_constant.ace_numeric {
|
||||
.ace-crimson-editor .ace_constant.ace_numeric {
|
||||
color: rgb(0, 0, 64);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_variable {
|
||||
.ace-crimson-editor .ace_variable {
|
||||
color: rgb(0, 64, 128);
|
||||
}
|
||||
|
||||
.ace-crimson-editor .ace_line .ace_xml-pe {
|
||||
.ace-crimson-editor .ace_xml-pe {
|
||||
color: rgb(104, 104, 91);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
exports.isDark = false;
|
||||
exports.cssText = require('ace/requirejs/text!./crimson_editor.css');
|
||||
exports.cssText = require("../requirejs/text!./crimson_editor.css");
|
||||
|
||||
exports.cssClass = "ace-crimson-editor";
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = false;
|
||||
exports.cssClass = "ace-dawn";
|
||||
exports.cssText = require('ace/requirejs/text!./dawn.css');
|
||||
exports.cssText = require("../requirejs/text!./dawn.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -28,78 +28,78 @@
|
|||
border-bottom: 1px solid black;
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_invisible {
|
||||
.ace-dreamweaver .ace_invisible {
|
||||
color: rgb(191, 191, 191);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_storage,
|
||||
.ace-dreamweaver .ace_line .ace_keyword {
|
||||
.ace-dreamweaver .ace_storage,
|
||||
.ace-dreamweaver .ace_keyword {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_constant.ace_buildin {
|
||||
.ace-dreamweaver .ace_constant.ace_buildin {
|
||||
color: rgb(88, 72, 246);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_constant.ace_language {
|
||||
.ace-dreamweaver .ace_constant.ace_language {
|
||||
color: rgb(88, 92, 246);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_constant.ace_library {
|
||||
.ace-dreamweaver .ace_constant.ace_library {
|
||||
color: rgb(6, 150, 14);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_invalid {
|
||||
.ace-dreamweaver .ace_invalid {
|
||||
background-color: rgb(153, 0, 0);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_support.ace_function {
|
||||
.ace-dreamweaver .ace_support.ace_function {
|
||||
color: rgb(60, 76, 114);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_support.ace_constant {
|
||||
.ace-dreamweaver .ace_support.ace_constant {
|
||||
color: rgb(6, 150, 14);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_support.ace_type,
|
||||
.ace-dreamweaver .ace_line .ace_support.ace_class {
|
||||
.ace-dreamweaver .ace_support.ace_type,
|
||||
.ace-dreamweaver .ace_support.ace_class {
|
||||
color: #009;
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_support.ace_php_tag {
|
||||
.ace-dreamweaver .ace_support.ace_php_tag {
|
||||
color: #f00;
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_keyword.ace_operator {
|
||||
.ace-dreamweaver .ace_keyword.ace_operator {
|
||||
color: rgb(104, 118, 135);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_string {
|
||||
.ace-dreamweaver .ace_string {
|
||||
color: #00F;
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_comment {
|
||||
.ace-dreamweaver .ace_comment {
|
||||
color: rgb(76, 136, 107);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_comment.ace_doc {
|
||||
.ace-dreamweaver .ace_comment.ace_doc {
|
||||
color: rgb(0, 102, 255);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_comment.ace_doc.ace_tag {
|
||||
.ace-dreamweaver .ace_comment.ace_doc.ace_tag {
|
||||
color: rgb(128, 159, 191);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_constant.ace_numeric {
|
||||
.ace-dreamweaver .ace_constant.ace_numeric {
|
||||
color: rgb(0, 0, 205);
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_variable {
|
||||
.ace-dreamweaver .ace_variable {
|
||||
color: #06F
|
||||
}
|
||||
|
||||
.ace-dreamweaver .ace_line .ace_xml-pe {
|
||||
.ace-dreamweaver .ace_xml-pe {
|
||||
color: rgb(104, 104, 91);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
define(function(require, exports, module) {
|
||||
exports.isDark = false;
|
||||
exports.cssClass = "ace-dreamweaver";
|
||||
exports.cssText = require('ace/requirejs/text!./dreamweaver.css');
|
||||
exports.cssText = require("../requirejs/text!./dreamweaver.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -24,52 +24,52 @@
|
|||
border-left: 2px solid black;
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_storage,
|
||||
.ace-eclipse .ace_line .ace_keyword,
|
||||
.ace-eclipse .ace_line .ace_variable {
|
||||
.ace-eclipse .ace_storage,
|
||||
.ace-eclipse .ace_keyword,
|
||||
.ace-eclipse .ace_variable {
|
||||
color: rgb(127, 0, 85);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_constant.ace_buildin {
|
||||
.ace-eclipse .ace_constant.ace_buildin {
|
||||
color: rgb(88, 72, 246);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_constant.ace_library {
|
||||
.ace-eclipse .ace_constant.ace_library {
|
||||
color: rgb(6, 150, 14);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_function {
|
||||
.ace-eclipse .ace_function {
|
||||
color: rgb(60, 76, 114);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_string {
|
||||
.ace-eclipse .ace_string {
|
||||
color: rgb(42, 0, 255);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_comment {
|
||||
.ace-eclipse .ace_comment {
|
||||
color: rgb(63, 127, 95);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_comment.ace_doc {
|
||||
.ace-eclipse .ace_comment.ace_doc {
|
||||
color: rgb(63, 95, 191);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_comment.ace_doc.ace_tag {
|
||||
.ace-eclipse .ace_comment.ace_doc.ace_tag {
|
||||
color: rgb(127, 159, 191);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_constant.ace_numeric {
|
||||
.ace-eclipse .ace_constant.ace_numeric {
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_tag {
|
||||
.ace-eclipse .ace_tag {
|
||||
color: rgb(63, 127, 127);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_type {
|
||||
.ace-eclipse .ace_type {
|
||||
color: rgb(127, 0, 127);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_xml-pe {
|
||||
.ace-eclipse .ace_xml-pe {
|
||||
color: rgb(104, 104, 91);
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
border: 1px solid rgb(192, 192, 192);
|
||||
}
|
||||
|
||||
.ace-eclipse .ace_line .ace_meta.ace_tag {
|
||||
.ace-eclipse .ace_meta.ace_tag {
|
||||
color:rgb(63, 127, 127);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
exports.isDark = false;
|
||||
exports.cssText = require('ace/requirejs/text!./eclipse.css');
|
||||
exports.cssText = require("../requirejs/text!./eclipse.css");
|
||||
|
||||
exports.cssClass = "ace-eclipse";
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,11 @@
|
|||
box-shadow: 0 0 3px 0px white;
|
||||
border-radius: 2px;
|
||||
}
|
||||
/* bold keywords cause cursor issues for some fonts */
|
||||
/* this disables bold style for editor and keeps for static highlighter */
|
||||
.ace-github.ace_nobold .ace_line > span {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
|
||||
.ace-github .ace_marker-layer .ace_step {
|
||||
background: rgb(252, 255, 0);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = false;
|
||||
exports.cssClass = "ace-github";
|
||||
exports.cssText = require('ace/requirejs/text!./github.css');
|
||||
exports.cssText = require("../requirejs/text!./github.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = true;
|
||||
exports.cssClass = "ace-idle-fingers";
|
||||
exports.cssText = require('ace/requirejs/text!./idle_fingers.css');
|
||||
exports.cssText = require("../requirejs/text!./idle_fingers.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -97,6 +97,10 @@
|
|||
color: #FFEE80
|
||||
}
|
||||
|
||||
.ace-kr-theme .ace_string {
|
||||
color: rgba(164, 161, 181, 0.8)
|
||||
}
|
||||
|
||||
.ace-kr-theme .ace_string.ace_regexp {
|
||||
color: rgba(125, 255, 192, 0.65)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = true;
|
||||
exports.cssClass = "ace-kr-theme";
|
||||
exports.cssText = require('ace/requirejs/text!./kr_theme.css');
|
||||
exports.cssText = require("../requirejs/text!./kr_theme.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = true;
|
||||
exports.cssClass = "ace-merbivore";
|
||||
exports.cssText = require('ace/requirejs/text!./merbivore.css');
|
||||
exports.cssText = require("../requirejs/text!./merbivore.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.isDark = true;
|
||||
exports.cssClass = "ace-merbivore-soft";
|
||||
exports.cssText = require('ace/requirejs/text!./merbivore_soft.css');
|
||||
exports.cssText = require("../requirejs/text!./merbivore_soft.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
dom.importCssString(exports.cssText, exports.cssClass);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue