Commit a35788c9 authored by aandrey@chromium.org's avatar aandrey@chromium.org

DevTools: Introduce WebInspector.RegExpSetting.

R=vsevik@chromium.org, vsevik

Review URL: https://codereview.chromium.org/212223003

git-svn-id: svn://svn.chromium.org/blink/trunk@170035 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e6bc9e8a
......@@ -72,7 +72,7 @@ WebInspector.FileSystemMapping = function()
else
defaultExcludedFolders = defaultExcludedFolders.concat(defaultLinuxExcludedFolders);
var defaultExcludedFoldersPattern = defaultExcludedFolders.join("|");
WebInspector.settings.workspaceFolderExcludePattern = WebInspector.settings.createSetting("workspaceFolderExcludePattern", defaultExcludedFoldersPattern);
WebInspector.settings.workspaceFolderExcludePattern = WebInspector.settings.createRegExpSetting("workspaceFolderExcludePattern", defaultExcludedFoldersPattern, WebInspector.isWin() ? "i" : "");
/** @type {!Object.<string, !Array.<!WebInspector.FileSystemMapping.Entry>>} */
this._fileSystemMappings = {};
/** @type {!Object.<string, !Array.<!WebInspector.FileSystemMapping.ExcludedFolderEntry>>} */
......@@ -121,13 +121,6 @@ WebInspector.FileSystemMapping.prototype = {
}
}
var workspaceFolderExcludePattern = WebInspector.settings.workspaceFolderExcludePattern.get()
try {
var flags = WebInspector.isWin() ? "i" : "";
this._workspaceFolderExcludeRegex = workspaceFolderExcludePattern ? new RegExp(workspaceFolderExcludePattern, flags) : null;
} catch (e) {
}
this._rebuildIndexes();
},
......@@ -329,7 +322,8 @@ WebInspector.FileSystemMapping.prototype = {
if (entry.path === folderPath)
return true;
}
return this._workspaceFolderExcludeRegex && this._workspaceFolderExcludeRegex.test(folderPath);
var regex = WebInspector.settings.workspaceFolderExcludePattern.asRegExp();
return regex && regex.test(folderPath);
},
/**
......
......@@ -106,7 +106,7 @@ WebInspector.Settings = function()
this.shortcutPanelSwitch = this.createSetting("shortcutPanelSwitch", false);
this.showWhitespacesInEditor = this.createSetting("showWhitespacesInEditor", false);
this.skipStackFramesSwitch = this.createSetting("skipStackFramesSwitch", false);
this.skipStackFramesPattern = this.createSetting("skipStackFramesPattern", "");
this.skipStackFramesPattern = this.createRegExpSetting("skipStackFramesPattern", "");
this.pauseOnExceptionEnabled = this.createSetting("pauseOnExceptionEnabled", false);
this.pauseOnCaughtException = this.createSetting("pauseOnCaughtException", false);
this.enableAsyncStackTraces = this.createSetting("enableAsyncStackTraces", false);
......@@ -125,6 +125,19 @@ WebInspector.Settings.prototype = {
return this._registry[key];
},
/**
* @param {string} key
* @param {string} defaultValue
* @param {string=} regexFlags
* @return {!WebInspector.Setting}
*/
createRegExpSetting: function(key, defaultValue, regexFlags)
{
if (!this._registry[key])
this._registry[key] = new WebInspector.RegExpSetting(key, defaultValue, this._eventSupport, window.localStorage, regexFlags);
return this._registry[key];
},
/**
* @param {string} key
* @param {*} defaultValue
......@@ -221,6 +234,46 @@ WebInspector.Setting.prototype = {
}
}
/**
* @constructor
* @extends {WebInspector.Setting}
* @param {string} name
* @param {string} defaultValue
* @param {!WebInspector.Object} eventSupport
* @param {?Storage} storage
* @param {string=} regexFlags
*/
WebInspector.RegExpSetting = function(name, defaultValue, eventSupport, storage, regexFlags)
{
WebInspector.Setting.call(this, name, defaultValue, eventSupport, storage);
this._regexFlags = regexFlags;
}
WebInspector.RegExpSetting.prototype = {
set: function(value)
{
delete this._regex;
WebInspector.Setting.prototype.set.call(this, value);
},
/**
* @return {?RegExp}
*/
asRegExp: function()
{
if (typeof this._regex !== "undefined")
return this._regex;
this._regex = null;
try {
this._regex = new RegExp(this.get(), this._regexFlags || "");
} catch (e) {
}
return this._regex;
},
__proto__: WebInspector.Setting.prototype
}
/**
* @constructor
* @extends {WebInspector.Setting}
......@@ -259,7 +312,7 @@ WebInspector.BackendSetting.prototype = {
},
__proto__: WebInspector.Setting.prototype
};
}
/**
* @constructor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment