Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
try restructuring code to get around Shrinksafe problem #3540
  • Loading branch information
peller committed Oct 22, 2012
1 parent 5b24b55 commit bf88b9d
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions maqetta.core.client/WebContent/orion/editor/textMateStyler.js
Expand Up @@ -14,6 +14,33 @@

define("orion/editor/textMateStyler", ['orion/editor/regex'], function(mRegex) {

/**
* @param obj {Object} A JSON-ish object.
* @returns {Object} Deep copy of <code>obj</code>. Does not work on properties that are functions or RegExp instances.
*/
var clone = function (obj) {
var c;
if (obj instanceof Array) {
c = new Array(obj.length);
for (var i=0; i < obj.length; i++) {
c[i] = clone(obj[i]);
}
} else {
c = {};
for (var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
var value = obj[prop];
if (typeof value === "object" && value !== null) {
c[prop] = clone(value);
} else {
c[prop] = value;
}
}
}
}
return c;
};

var RegexUtil = {
// Rules to detect some unsupported Oniguruma features
unsupported: [
Expand Down Expand Up @@ -395,7 +422,7 @@ var RegexUtil = {
* </ul>
*
* @description Creates a new TextMateStyler.
* @extends orion.editor.AbstractStyler
* @extends orion.editor.AbstractStylr

This comment has been minimized.

Copy link
@peller

peller Oct 23, 2012

Member

oops... made a typo here

* @param {orion.textview.TextView} textView The <code>TextView</code> to provide styling for.
* @param {Object} grammar The TextMate grammar to use for styling the <code>TextView</code>, as a JavaScript object. You can
* produce this object by running a PList-to-JavaScript conversion tool on a TextMate <code>.tmLanguage</code> file.
Expand All @@ -404,8 +431,8 @@ var RegexUtil = {
function TextMateStyler(textView, grammar, externalGrammars) {
this.initialize(textView);
// Copy grammar object(s) since we will mutate them
this.grammar = this.clone(grammar);
this.externalGrammars = externalGrammars ? this.clone(externalGrammars) : [];
this.grammar = clone(grammar);
this.externalGrammars = externalGrammars ? clone(externalGrammars) : [];

this._styles = {}; /* key: {String} scopeName, value: {String[]} cssClassNames */
this._tree = null;
Expand Down Expand Up @@ -447,33 +474,6 @@ var RegexUtil = {
this._tree = null;
this._listener = null;
},
/**
* @private
* @param obj {Object} A JSON-ish object.
* @returns {Object} Deep copy of <code>obj</code>. Does not work on properties that are functions or RegExp instances.
*/
clone: function clone(obj) {
var c;
if (obj instanceof Array) {
c = new Array(obj.length);
for (var i=0; i < obj.length; i++) {
c[i] = clone(obj[i]);
}
} else {
c = {};
for (var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
var value = obj[prop];
if (typeof value === "object" && value !== null) {
c[prop] = clone(value);
} else {
c[prop] = value;
}
}
}
}
return c;
},
/** @private */
preprocess: function(grammar) {
var stack = [grammar];
Expand Down

0 comments on commit bf88b9d

Please sign in to comment.