update packaged ace
This commit is contained in:
parent
51d2a348c7
commit
6de1e4f5f5
2 changed files with 61 additions and 27 deletions
|
|
@ -10198,13 +10198,32 @@ var Tokenizer = function(rules) {
|
||||||
this.rules = rules;
|
this.rules = rules;
|
||||||
|
|
||||||
this.regExps = {};
|
this.regExps = {};
|
||||||
|
this.matchMappings = {};
|
||||||
for ( var key in this.rules) {
|
for ( var key in this.rules) {
|
||||||
var rule = this.rules[key];
|
var rule = this.rules[key];
|
||||||
var state = rule;
|
var state = rule;
|
||||||
var ruleRegExps = [];
|
var ruleRegExps = [];
|
||||||
|
var matchTotal = 0;
|
||||||
for ( var i = 0; i < state.length; i++)
|
var mapping = this.matchMappings[key] = {};
|
||||||
ruleRegExps.push(state[i].regex);
|
|
||||||
|
for ( var i = 0; i < state.length; i++) {
|
||||||
|
// Count number of matching groups. 2 extra groups from the full match
|
||||||
|
// And the catch-all on the end (used to force a match);
|
||||||
|
var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2;
|
||||||
|
|
||||||
|
// Replace any backreferences and offset appropriately.
|
||||||
|
var adjustedregex = state[i].regex.replace(/\\([0-9]+)/g, function (match, digit) {
|
||||||
|
return "\\" + (parseInt(digit, 10) + matchTotal + 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
mapping[matchTotal] = {
|
||||||
|
rule: i,
|
||||||
|
len: matchcount
|
||||||
|
};
|
||||||
|
matchTotal += matchcount;
|
||||||
|
|
||||||
|
ruleRegExps.push(adjustedregex);
|
||||||
|
}
|
||||||
|
|
||||||
this.regExps[key] = new RegExp("(?:(" + ruleRegExps.join(")|(") + ")|(.))", "g");
|
this.regExps[key] = new RegExp("(?:(" + ruleRegExps.join(")|(") + ")|(.))", "g");
|
||||||
|
|
||||||
|
|
@ -10216,34 +10235,40 @@ var Tokenizer = function(rules) {
|
||||||
this.getLineTokens = function(line, startState) {
|
this.getLineTokens = function(line, startState) {
|
||||||
var currentState = startState;
|
var currentState = startState;
|
||||||
var state = this.rules[currentState];
|
var state = this.rules[currentState];
|
||||||
|
var mapping = this.matchMappings[currentState];
|
||||||
var re = this.regExps[currentState];
|
var re = this.regExps[currentState];
|
||||||
re.lastIndex = 0;
|
re.lastIndex = 0;
|
||||||
|
|
||||||
var match, tokens = [];
|
var match, tokens = [];
|
||||||
|
|
||||||
var lastIndex = 0;
|
var lastIndex = 0;
|
||||||
|
|
||||||
var token = {
|
var token = {
|
||||||
type: null,
|
type: null,
|
||||||
value: ""
|
value: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
while (match = re.exec(line)) {
|
while (match = re.exec(line)) {
|
||||||
var type = "text";
|
var type = "text";
|
||||||
var value = match[0];
|
var value = [match[0]];
|
||||||
|
|
||||||
for ( var i = 0; i < state.length; i++) {
|
for ( var i = 0; i < match.length-2; i++) {
|
||||||
if (match[i + 1]) {
|
if (match[i + 1] !== undefined) {
|
||||||
var rule = state[i];
|
var rule = state[mapping[i].rule];
|
||||||
|
|
||||||
|
if (mapping[i].len > 1) {
|
||||||
|
value = match.slice(i+2, i+1+mapping[i].len);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof rule.token == "function")
|
if (typeof rule.token == "function")
|
||||||
type = rule.token(match[0]);
|
type = rule.token.apply(this, value);
|
||||||
else
|
else
|
||||||
type = rule.token;
|
type = rule.token;
|
||||||
|
|
||||||
if (rule.next && rule.next !== currentState) {
|
if (rule.next && rule.next !== currentState) {
|
||||||
currentState = rule.next;
|
currentState = rule.next;
|
||||||
state = this.rules[currentState];
|
state = this.rules[currentState];
|
||||||
|
mapping = this.matchMappings[currentState];
|
||||||
lastIndex = re.lastIndex;
|
lastIndex = re.lastIndex;
|
||||||
|
|
||||||
re = this.regExps[currentState];
|
re = this.regExps[currentState];
|
||||||
|
|
@ -10253,17 +10278,26 @@ var Tokenizer = function(rules) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (typeof type == "string") {
|
||||||
if (token.type !== type) {
|
if (typeof value != "string") {
|
||||||
if (token.type)
|
value = [value.join("")];
|
||||||
tokens.push(token);
|
}
|
||||||
|
type = [type];
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( var i = 0; i < value.length; i++) {
|
||||||
|
if (token.type !== type[i]) {
|
||||||
|
if (token.type) {
|
||||||
|
tokens.push(token);
|
||||||
|
}
|
||||||
|
|
||||||
token = {
|
token = {
|
||||||
type: type,
|
type: type[i],
|
||||||
value: value
|
value: value[i]
|
||||||
};
|
}
|
||||||
} else {
|
} else {
|
||||||
token.value += value;
|
token.value += value[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastIndex == line.length)
|
if (lastIndex == line.length)
|
||||||
|
|
@ -11466,7 +11500,7 @@ function Folding() {
|
||||||
throw "A fold can't end inside of an already existing fold";
|
throw "A fold can't end inside of an already existing fold";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endRow >= this.doc.$lines.length) {
|
if (endRow >= this.doc.getLength()) {
|
||||||
throw "End of fold is outside of the document.";
|
throw "End of fold is outside of the document.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -11642,7 +11676,7 @@ function Folding() {
|
||||||
|
|
||||||
// Build the textline using the FoldLine walker.
|
// Build the textline using the FoldLine walker.
|
||||||
var line = "";
|
var line = "";
|
||||||
var lines = this.doc.$lines;
|
var doc = this.doc;
|
||||||
var textLine = "";
|
var textLine = "";
|
||||||
|
|
||||||
foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
|
foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
|
||||||
|
|
@ -11657,7 +11691,7 @@ function Folding() {
|
||||||
if (placeholder) {
|
if (placeholder) {
|
||||||
textLine += placeholder;
|
textLine += placeholder;
|
||||||
} else {
|
} else {
|
||||||
textLine += lines[row].substring(lastColumn, column);
|
textLine += doc.getLine(row).substring(lastColumn, column);
|
||||||
}
|
}
|
||||||
}.bind(this), endRow, endColumn);
|
}.bind(this), endRow, endColumn);
|
||||||
return textLine;
|
return textLine;
|
||||||
|
|
@ -11668,7 +11702,7 @@ function Folding() {
|
||||||
|
|
||||||
if (!foldLine) {
|
if (!foldLine) {
|
||||||
var line;
|
var line;
|
||||||
line = this.doc.$lines[row];
|
line = this.doc.getLine(row);
|
||||||
return line.substring(startColumn || 0, endColumn || line.length);
|
return line.substring(startColumn || 0, endColumn || line.length);
|
||||||
} else {
|
} else {
|
||||||
return this.getFoldDisplayLine(
|
return this.getFoldDisplayLine(
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue