|
Lines 34-40
Link Here
|
| 34 |
|
34 |
|
| 35 |
var eolRegex = /$/; |
35 |
var eolRegex = /$/; |
| 36 |
var captureReferenceRegex = /\\(\d)/g; |
36 |
var captureReferenceRegex = /\\(\d)/g; |
| 37 |
var ignoreCaseRegex = /^\(\?i\)\s*/; |
37 |
var flagsRegex = /^\(\?([im]*)\)\s*/; |
| 38 |
var linebreakRegex = /(.*)(?:[\r\n]|$)/g; |
38 |
var linebreakRegex = /(.*)(?:[\r\n]|$)/g; |
| 39 |
var spacePattern = {regex: /[ ]/g, style: {styleClass: "punctuation separator space", unmergeable: true}}; //$NON-NLS-0$ |
39 |
var spacePattern = {regex: /[ ]/g, style: {styleClass: "punctuation separator space", unmergeable: true}}; //$NON-NLS-0$ |
| 40 |
var tabPattern = {regex: /\t/g, style: {styleClass: "punctuation separator tab", unmergeable: true}}; //$NON-NLS-0$ |
40 |
var tabPattern = {regex: /\t/g, style: {styleClass: "punctuation separator tab", unmergeable: true}}; //$NON-NLS-0$ |
|
Lines 47-54
Link Here
|
| 47 |
* its pre-test() value, and exec() is then invoked on it in order to get the match details. |
47 |
* its pre-test() value, and exec() is then invoked on it in order to get the match details. |
| 48 |
*/ |
48 |
*/ |
| 49 |
|
49 |
|
| 50 |
var index = startIndex; |
|
|
| 51 |
var initialLastIndex = regex.lastIndex; |
50 |
var initialLastIndex = regex.lastIndex; |
|
|
51 |
var result, revertIndex; |
| 52 |
|
| 53 |
/* no line-delimited parsing is needed for multi-line regexes */ |
| 54 |
if (regex.multiline) { |
| 55 |
regex.lastIndex = startIndex; |
| 56 |
if (testBeforeMatch) { |
| 57 |
revertIndex = regex.lastIndex; |
| 58 |
if (regex.test(text)) { |
| 59 |
regex.lastIndex = revertIndex; |
| 60 |
result = regex.exec(text); |
| 61 |
} |
| 62 |
} else { |
| 63 |
result = regex.exec(text); |
| 64 |
} |
| 65 |
regex.lastIndex = initialLastIndex; |
| 66 |
return result; |
| 67 |
} |
| 68 |
|
| 69 |
/* not a multi-line regex */ |
| 70 |
|
| 71 |
var index = startIndex; |
| 52 |
linebreakRegex.lastIndex = startIndex; |
72 |
linebreakRegex.lastIndex = startIndex; |
| 53 |
|
73 |
|
| 54 |
var currentLine = linebreakRegex.exec(text); |
74 |
var currentLine = linebreakRegex.exec(text); |
|
Lines 72-80
Link Here
|
| 72 |
regex.lastIndex = indexAdjustment = currentLine.index - lineStart - 1; |
92 |
regex.lastIndex = indexAdjustment = currentLine.index - lineStart - 1; |
| 73 |
} |
93 |
} |
| 74 |
while (currentLine && currentLine.index < text.length) { |
94 |
while (currentLine && currentLine.index < text.length) { |
| 75 |
var result; |
|
|
| 76 |
if (testBeforeMatch) { |
95 |
if (testBeforeMatch) { |
| 77 |
var revertIndex = regex.lastIndex; |
96 |
revertIndex = regex.lastIndex; |
| 78 |
if (regex.test(lineString)) { |
97 |
if (regex.test(lineString)) { |
| 79 |
regex.lastIndex = revertIndex; |
98 |
regex.lastIndex = revertIndex; |
| 80 |
result = regex.exec(lineString); |
99 |
result = regex.exec(lineString); |
|
Lines 595-635
Link Here
|
| 595 |
return; |
614 |
return; |
| 596 |
} |
615 |
} |
| 597 |
var patterns = this.getPatternManager().getPatterns(this.pattern ? this.pattern.pattern : null); |
616 |
var patterns = this.getPatternManager().getPatterns(this.pattern ? this.pattern.pattern : null); |
| 598 |
var processIgnore = function(matchString) { |
617 |
var initRegex = function(matchString) { |
| 599 |
var result = ignoreCaseRegex.exec(matchString); |
618 |
var result = flagsRegex.exec(matchString); |
|
|
619 |
var flags = FLAGS; |
| 600 |
if (result) { |
620 |
if (result) { |
| 601 |
matchString = matchString.substring(result[0].length); |
621 |
matchString = matchString.substring(result[0].length); |
|
|
622 |
if (result[1].indexOf("i") !== -1) { |
| 623 |
flags += "i"; |
| 624 |
} |
| 625 |
if (result[1].indexOf("m") !== -1) { |
| 626 |
flags += "m"; |
| 627 |
} |
| 602 |
} |
628 |
} |
| 603 |
return matchString; |
629 |
return new RegExp(matchString, flags); |
| 604 |
}; |
630 |
}; |
| 605 |
var lastBlock = -1; |
631 |
var lastBlock = -1; |
| 606 |
var index = 0; |
632 |
var index = 0; |
| 607 |
patterns.forEach(function(current) { |
633 |
patterns.forEach(function(current) { |
| 608 |
var pattern; |
634 |
var pattern; |
| 609 |
if (current.match && !current.begin && !current.end) { |
635 |
if (current.match && !current.begin && !current.end) { |
| 610 |
var flags = FLAGS; |
636 |
pattern = {regex: initRegex(current.match), pattern: current}; |
| 611 |
var match = processIgnore(current.match); |
|
|
| 612 |
if (match !== current.match) { |
| 613 |
flags += "i"; //$NON-NLS-0$ |
| 614 |
} |
| 615 |
pattern = {regex: new RegExp(match, flags), pattern: current}; |
| 616 |
this._linePatterns.push(pattern); |
637 |
this._linePatterns.push(pattern); |
| 617 |
if (current.name && current.name.indexOf("punctuation.section") === 0 && (current.name.indexOf(PUNCTUATION_SECTION_BEGIN) !== -1 || current.name.indexOf(PUNCTUATION_SECTION_END) !== -1)) { //$NON-NLS-0$ |
638 |
if (current.name && current.name.indexOf("punctuation.section") === 0 && (current.name.indexOf(PUNCTUATION_SECTION_BEGIN) !== -1 || current.name.indexOf(PUNCTUATION_SECTION_END) !== -1)) { //$NON-NLS-0$ |
| 618 |
this._enclosurePatterns[current.name] = pattern; |
639 |
this._enclosurePatterns[current.name] = pattern; |
| 619 |
} |
640 |
} |
| 620 |
} else if (!current.match && current.begin && current.end) { |
641 |
} else if (!current.match && current.begin && current.end) { |
| 621 |
lastBlock = index; |
642 |
lastBlock = index; |
| 622 |
var beginFlags = FLAGS; |
643 |
pattern = {regexBegin: initRegex(current.begin), regexEnd: initRegex(current.end), pattern: current}; |
| 623 |
var begin = processIgnore(current.begin); |
|
|
| 624 |
if (begin !== current.begin) { |
| 625 |
beginFlags += "i"; //$NON-NLS-0$ |
| 626 |
} |
| 627 |
var endFlags = FLAGS; |
| 628 |
var end = processIgnore(current.end); |
| 629 |
if (end !== current.end) { |
| 630 |
endFlags += "i"; //$NON-NLS-0$ |
| 631 |
} |
| 632 |
pattern = {regexBegin: new RegExp(begin, beginFlags), regexEnd: new RegExp(end, endFlags), pattern: current}; |
| 633 |
this._linePatterns.push(pattern); |
644 |
this._linePatterns.push(pattern); |
| 634 |
} |
645 |
} |
| 635 |
index++; |
646 |
index++; |