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.regExps = {};
|
||||
this.matchMappings = {};
|
||||
for ( var key in this.rules) {
|
||||
var rule = this.rules[key];
|
||||
var state = rule;
|
||||
var ruleRegExps = [];
|
||||
|
||||
for ( var i = 0; i < state.length; i++)
|
||||
ruleRegExps.push(state[i].regex);
|
||||
var matchTotal = 0;
|
||||
var mapping = this.matchMappings[key] = {};
|
||||
|
||||
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");
|
||||
|
||||
|
|
@ -10216,34 +10235,40 @@ var Tokenizer = function(rules) {
|
|||
this.getLineTokens = function(line, startState) {
|
||||
var currentState = startState;
|
||||
var state = this.rules[currentState];
|
||||
var mapping = this.matchMappings[currentState];
|
||||
var re = this.regExps[currentState];
|
||||
re.lastIndex = 0;
|
||||
|
||||
|
||||
var match, tokens = [];
|
||||
|
||||
|
||||
var lastIndex = 0;
|
||||
|
||||
|
||||
var token = {
|
||||
type: null,
|
||||
value: ""
|
||||
};
|
||||
|
||||
|
||||
while (match = re.exec(line)) {
|
||||
var type = "text";
|
||||
var value = match[0];
|
||||
var value = [match[0]];
|
||||
|
||||
for ( var i = 0; i < state.length; i++) {
|
||||
if (match[i + 1]) {
|
||||
var rule = state[i];
|
||||
for ( var i = 0; i < match.length-2; i++) {
|
||||
if (match[i + 1] !== undefined) {
|
||||
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")
|
||||
type = rule.token(match[0]);
|
||||
type = rule.token.apply(this, value);
|
||||
else
|
||||
type = rule.token;
|
||||
|
||||
if (rule.next && rule.next !== currentState) {
|
||||
currentState = rule.next;
|
||||
state = this.rules[currentState];
|
||||
mapping = this.matchMappings[currentState];
|
||||
lastIndex = re.lastIndex;
|
||||
|
||||
re = this.regExps[currentState];
|
||||
|
|
@ -10253,17 +10278,26 @@ var Tokenizer = function(rules) {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
if (token.type !== type) {
|
||||
if (token.type)
|
||||
tokens.push(token);
|
||||
if (typeof type == "string") {
|
||||
if (typeof value != "string") {
|
||||
value = [value.join("")];
|
||||
}
|
||||
type = [type];
|
||||
}
|
||||
|
||||
for ( var i = 0; i < value.length; i++) {
|
||||
if (token.type !== type[i]) {
|
||||
if (token.type) {
|
||||
tokens.push(token);
|
||||
}
|
||||
|
||||
token = {
|
||||
type: type,
|
||||
value: value
|
||||
};
|
||||
} else {
|
||||
token.value += value;
|
||||
token = {
|
||||
type: type[i],
|
||||
value: value[i]
|
||||
}
|
||||
} else {
|
||||
token.value += value[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex == line.length)
|
||||
|
|
@ -11466,7 +11500,7 @@ function Folding() {
|
|||
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.";
|
||||
}
|
||||
|
||||
|
|
@ -11642,7 +11676,7 @@ function Folding() {
|
|||
|
||||
// Build the textline using the FoldLine walker.
|
||||
var line = "";
|
||||
var lines = this.doc.$lines;
|
||||
var doc = this.doc;
|
||||
var textLine = "";
|
||||
|
||||
foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
|
||||
|
|
@ -11657,7 +11691,7 @@ function Folding() {
|
|||
if (placeholder) {
|
||||
textLine += placeholder;
|
||||
} else {
|
||||
textLine += lines[row].substring(lastColumn, column);
|
||||
textLine += doc.getLine(row).substring(lastColumn, column);
|
||||
}
|
||||
}.bind(this), endRow, endColumn);
|
||||
return textLine;
|
||||
|
|
@ -11668,7 +11702,7 @@ function Folding() {
|
|||
|
||||
if (!foldLine) {
|
||||
var line;
|
||||
line = this.doc.$lines[row];
|
||||
line = this.doc.getLine(row);
|
||||
return line.substring(startColumn || 0, endColumn || line.length);
|
||||
} else {
|
||||
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