|
Lines 33-40
Link Here
|
| 33 |
|
33 |
|
| 34 |
var eolRegex = /$/; |
34 |
var eolRegex = /$/; |
| 35 |
var captureReferenceRegex = /\\(\d)/g; |
35 |
var captureReferenceRegex = /\\(\d)/g; |
|
|
36 |
var ignoreCaseRegex = /^\(\?i\)\s*/; |
| 36 |
var linebreakRegex = /(.*)(?:[\r\n]|$)/g; |
37 |
var linebreakRegex = /(.*)(?:[\r\n]|$)/g; |
| 37 |
var spacePattern = {regex: / /g, style: {styleClass: "punctuation separator space", unmergeable: true}}; //$NON-NLS-0$ |
38 |
var spacePattern = {regex: /[ ]/g, style: {styleClass: "punctuation separator space", unmergeable: true}}; //$NON-NLS-0$ |
| 38 |
var tabPattern = {regex: /\t/g, style: {styleClass: "punctuation separator tab", unmergeable: true}}; //$NON-NLS-0$ |
39 |
var tabPattern = {regex: /\t/g, style: {styleClass: "punctuation separator tab", unmergeable: true}}; //$NON-NLS-0$ |
| 39 |
|
40 |
|
| 40 |
var _findMatch = function(regex, text, startIndex, testBeforeMatch) { |
41 |
var _findMatch = function(regex, text, startIndex, testBeforeMatch) { |
|
Lines 297-306
Link Here
|
| 297 |
var contentStart = current.result.index; |
298 |
var contentStart = current.result.index; |
| 298 |
var resultEnd = null; |
299 |
var resultEnd = null; |
| 299 |
|
300 |
|
| 300 |
/* |
|
|
| 301 |
* If the end match contains a capture reference (eg.- "\1") then update |
| 302 |
* its regex with the resolved capture values from the begin match. |
| 303 |
*/ |
| 304 |
var endRegex = current.pattern.regexEnd; |
301 |
var endRegex = current.pattern.regexEnd; |
| 305 |
if (!endRegex) { |
302 |
if (!endRegex) { |
| 306 |
resultEnd = new Block( |
303 |
resultEnd = new Block( |
|
Lines 316-322
Link Here
|
| 316 |
block); |
313 |
block); |
| 317 |
} else { |
314 |
} else { |
| 318 |
contentStart += current.result[0].length; |
315 |
contentStart += current.result[0].length; |
| 319 |
endRegex = substituteCaptureValues(endRegex, current.result); |
316 |
var testPattern = current.pattern; |
|
|
317 |
/* |
| 318 |
* If the end regex contains a capture reference (eg.- "\1") then substitute |
| 319 |
* the resolved capture values from the begin match. |
| 320 |
*/ |
| 321 |
var resolvedEndRegex = substituteCaptureValues(endRegex, current.result); |
| 322 |
if (resolvedEndRegex !== endRegex) { |
| 323 |
/* |
| 324 |
* A substitution was made, so make a copy of the test pattern and set its |
| 325 |
* end regex to the resolved one. This will cause end-match detection to be |
| 326 |
* performed with this concrete end regex value, but the original pattern |
| 327 |
* definition containing the capture reference will not be affected. |
| 328 |
*/ |
| 329 |
testPattern = { |
| 330 |
pattern: testPattern.pattern, |
| 331 |
regexBegin: testPattern.regexBegin, |
| 332 |
regexEnd: resolvedEndRegex |
| 333 |
}; |
| 334 |
endRegex = resolvedEndRegex; |
| 335 |
} |
| 320 |
|
336 |
|
| 321 |
var lastIndex = contentStart; |
337 |
var lastIndex = contentStart; |
| 322 |
while (!resultEnd) { |
338 |
while (!resultEnd) { |
|
Lines 333-339
Link Here
|
| 333 |
contentStart: offset + contentStart, |
349 |
contentStart: offset + contentStart, |
| 334 |
contentEnd: offset + result.index |
350 |
contentEnd: offset + result.index |
| 335 |
}, |
351 |
}, |
| 336 |
current.pattern, |
352 |
testPattern, |
| 337 |
block.getStyler(), |
353 |
block.getStyler(), |
| 338 |
model, |
354 |
model, |
| 339 |
block); |
355 |
block); |
|
Lines 390-407
Link Here
|
| 390 |
getPatterns: function(pattern) { |
406 |
getPatterns: function(pattern) { |
| 391 |
var parentId; |
407 |
var parentId; |
| 392 |
if (!pattern) { |
408 |
if (!pattern) { |
| 393 |
parentId = this._rootId; |
409 |
parentId = this._rootId + "#" + this._NO_ID; |
| 394 |
} else { |
410 |
} else { |
| 395 |
if (typeof(pattern) === "string") { //$NON-NLS-0$ |
411 |
if (typeof(pattern) === "string") { //$NON-NLS-0$ |
| 396 |
parentId = pattern; |
412 |
parentId = pattern; |
| 397 |
} else { |
413 |
} else { |
| 398 |
parentId = pattern.qualifiedId; |
414 |
parentId = pattern.qualifiedId; |
| 399 |
} |
415 |
} |
|
|
416 |
parentId += "#"; |
| 400 |
} |
417 |
} |
| 401 |
/* indexes on patterns are used to break ties when multiple patterns match the same start text */ |
418 |
/* indexes on patterns are used to break ties when multiple patterns match the same start text */ |
| 402 |
var indexCounter = [0]; |
419 |
var indexCounter = [0]; |
| 403 |
var resultObject = {}; |
420 |
var resultObject = {}; |
| 404 |
var regEx = new RegExp("^" + parentId + "#[^#]+$"); //$NON-NLS-0$ |
421 |
var regEx = new RegExp("^" + parentId + "[^#]+$"); //$NON-NLS-0$ |
| 405 |
var includes = []; |
422 |
var includes = []; |
| 406 |
this._patterns.forEach(function(current) { |
423 |
this._patterns.forEach(function(current) { |
| 407 |
if (regEx.test(current.qualifiedId)) { |
424 |
if (regEx.test(current.qualifiedId)) { |
|
Lines 598-604
Link Here
|
| 598 |
_initPatterns: function() { |
615 |
_initPatterns: function() { |
| 599 |
var patterns = this.getPatternManager().getPatterns(this.pattern ? this.pattern.pattern : null); |
616 |
var patterns = this.getPatternManager().getPatterns(this.pattern ? this.pattern.pattern : null); |
| 600 |
var processIgnore = function(matchString) { |
617 |
var processIgnore = function(matchString) { |
| 601 |
var result = /^\(\?i\)\s*/.exec(matchString); |
618 |
var result = ignoreCaseRegex.exec(matchString); |
| 602 |
if (result) { |
619 |
if (result) { |
| 603 |
matchString = matchString.substring(result[0].length); |
620 |
matchString = matchString.substring(result[0].length); |
| 604 |
} |
621 |
} |