Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 241071 Details for
Bug 430833
editor content styling: investigate allowing multi-line regex matches (?m)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
multilineMatches.patch (text/plain), 4.80 KB, created by
Grant Gayed
on 2014-03-20 16:10:12 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Grant Gayed
Created:
2014-03-20 16:10:12 EDT
Size:
4.80 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/stylers/application_javascript/syntax.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/stylers/application_javascript/syntax.js >index dce93df..8109fdd 100644 >--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/stylers/application_javascript/syntax.js >+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/stylers/application_javascript/syntax.js >@@ -53,6 +53,10 @@ > name: "string.regexp.js" //$NON-NLS-0$ > }, > {include: "orion.lib#doc_block"}, //$NON-NLS-0$ >+ { >+ match: "(?m)^[^\\r\\n]*\\r?\\n=+$", >+ name: "keyword.control.js" >+ }, > {include: "orion.c-like#comment_block"}, //$NON-NLS-0$ > {include: "orion.lib#brace_open"}, //$NON-NLS-0$ > {include: "orion.lib#brace_close"}, //$NON-NLS-0$ >diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textStyler.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textStyler.js >index 38ca2a7..64baafa 100644 >--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textStyler.js >+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textStyler.js >@@ -34,7 +34,7 @@ > > var eolRegex = /$/; > var captureReferenceRegex = /\\(\d)/g; >- var ignoreCaseRegex = /^\(\?i\)\s*/; >+ var flagsRegex = /^\(\?([im]*)\)\s*/; > var linebreakRegex = /(.*)(?:[\r\n]|$)/g; > var spacePattern = {regex: /[ ]/g, style: {styleClass: "punctuation separator space", unmergeable: true}}; //$NON-NLS-0$ > var tabPattern = {regex: /\t/g, style: {styleClass: "punctuation separator tab", unmergeable: true}}; //$NON-NLS-0$ >@@ -47,8 +47,28 @@ > * its pre-test() value, and exec() is then invoked on it in order to get the match details. > */ > >- var index = startIndex; > var initialLastIndex = regex.lastIndex; >+ var result, revertIndex; >+ >+ /* no line-delimited parsing is needed for multi-line regexes */ >+ if (regex.multiline) { >+ regex.lastIndex = startIndex; >+ if (testBeforeMatch) { >+ revertIndex = regex.lastIndex; >+ if (regex.test(text)) { >+ regex.lastIndex = revertIndex; >+ result = regex.exec(text); >+ } >+ } else { >+ result = regex.exec(text); >+ } >+ regex.lastIndex = initialLastIndex; >+ return result; >+ } >+ >+ /* not a multi-line regex */ >+ >+ var index = startIndex; > linebreakRegex.lastIndex = startIndex; > > var currentLine = linebreakRegex.exec(text); >@@ -72,9 +92,8 @@ > regex.lastIndex = indexAdjustment = currentLine.index - lineStart - 1; > } > while (currentLine && currentLine.index < text.length) { >- var result; > if (testBeforeMatch) { >- var revertIndex = regex.lastIndex; >+ revertIndex = regex.lastIndex; > if (regex.test(lineString)) { > regex.lastIndex = revertIndex; > result = regex.exec(lineString); >@@ -595,41 +614,33 @@ > return; > } > var patterns = this.getPatternManager().getPatterns(this.pattern ? this.pattern.pattern : null); >- var processIgnore = function(matchString) { >- var result = ignoreCaseRegex.exec(matchString); >+ var initRegex = function(matchString) { >+ var result = flagsRegex.exec(matchString); >+ var flags = FLAGS; > if (result) { > matchString = matchString.substring(result[0].length); >+ if (result[1].indexOf("i") !== -1) { >+ flags += "i"; >+ } >+ if (result[1].indexOf("m") !== -1) { >+ flags += "m"; >+ } > } >- return matchString; >+ return new RegExp(matchString, flags); > }; > var lastBlock = -1; > var index = 0; > patterns.forEach(function(current) { > var pattern; > if (current.match && !current.begin && !current.end) { >- var flags = FLAGS; >- var match = processIgnore(current.match); >- if (match !== current.match) { >- flags += "i"; //$NON-NLS-0$ >- } >- pattern = {regex: new RegExp(match, flags), pattern: current}; >+ pattern = {regex: initRegex(current.match), pattern: current}; > this._linePatterns.push(pattern); > 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$ > this._enclosurePatterns[current.name] = pattern; > } > } else if (!current.match && current.begin && current.end) { > lastBlock = index; >- var beginFlags = FLAGS; >- var begin = processIgnore(current.begin); >- if (begin !== current.begin) { >- beginFlags += "i"; //$NON-NLS-0$ >- } >- var endFlags = FLAGS; >- var end = processIgnore(current.end); >- if (end !== current.end) { >- endFlags += "i"; //$NON-NLS-0$ >- } >- pattern = {regexBegin: new RegExp(begin, beginFlags), regexEnd: new RegExp(end, endFlags), pattern: current}; >+ pattern = {regexBegin: initRegex(current.begin), regexEnd: initRegex(current.end), pattern: current}; > this._linePatterns.push(pattern); > } > index++;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 430833
: 241071