Commit 427d4a56 authored by pfeldman's avatar pfeldman Committed by Commit bot

DevTools: merge excluded folder manager into isolated file system.

BUG=529471

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

Cr-Commit-Position: refs/heads/master@{#351203}
parent 7a73be6e
...@@ -71,18 +71,8 @@ MockIsolatedFileSystem.prototype = { ...@@ -71,18 +71,8 @@ MockIsolatedFileSystem.prototype = {
if (!this._callback) if (!this._callback)
return; return;
var files = Object.keys(this._files); var files = Object.keys(this._files);
for (var i = 0; i < files.length; ++i) { for (var i = 0; i < files.length; ++i)
var isExcluded = false;
for (var j = 0; j < files[i].length; ++j) {
if (files[i][j] === "/") {
if (InspectorTest.testExcludedFolderManager.isFileExcluded(this._path, files[i].substr(0, j + 1)))
isExcluded = true;
}
}
if (isExcluded)
continue;
this._callback(files[i].substr(1)); this._callback(files[i].substr(1));
}
delete this._callback; delete this._callback;
}, },
...@@ -128,11 +118,6 @@ MockIsolatedFileSystemManager.prototype = { ...@@ -128,11 +118,6 @@ MockIsolatedFileSystemManager.prototype = {
return this.fileSystemMapping; return this.fileSystemMapping;
}, },
excludedFolderManager: function()
{
return InspectorTest.testExcludedFolderManager;
},
__proto__: WebInspector.Object.prototype __proto__: WebInspector.Object.prototype
} }
...@@ -148,7 +133,7 @@ InspectorTest.addFilesToMockFileSystem = function(path, files) ...@@ -148,7 +133,7 @@ InspectorTest.addFilesToMockFileSystem = function(path, files)
MockIsolatedFileSystem._isolatedFileSystemMocks[path]._addFiles(files); MockIsolatedFileSystem._isolatedFileSystemMocks[path]._addFiles(files);
} }
InspectorFrontendHost.isolatedFileSystem = function(name, url) InspectorFrontendHost.isolatedFileSystem = function(name)
{ {
return InspectorTest.TestFileSystem._instances[name]; return InspectorTest.TestFileSystem._instances[name];
} }
...@@ -164,7 +149,6 @@ InspectorTest.TestFileSystem._instances = {}; ...@@ -164,7 +149,6 @@ InspectorTest.TestFileSystem._instances = {};
InspectorTest.TestFileSystem.prototype = { InspectorTest.TestFileSystem.prototype = {
reportCreated: function() reportCreated: function()
{ {
WebInspector.isolatedFileSystemManager._loaded = true;
InspectorTest.TestFileSystem._instances[this.fileSystemPath] = this; InspectorTest.TestFileSystem._instances[this.fileSystemPath] = this;
InspectorFrontendHost.events.dispatchEventToListeners(InspectorFrontendHostAPI.Events.FileSystemAdded, { InspectorFrontendHost.events.dispatchEventToListeners(InspectorFrontendHostAPI.Events.FileSystemAdded, {
fileSystem: { fileSystemPath: this.fileSystemPath, fileSystem: { fileSystemPath: this.fileSystemPath,
......
...@@ -4,7 +4,6 @@ InspectorTest.createWorkspace = function(ignoreEvents) ...@@ -4,7 +4,6 @@ InspectorTest.createWorkspace = function(ignoreEvents)
{ {
WebInspector.settings.createSetting("fileSystemMapping", {}).set({}); WebInspector.settings.createSetting("fileSystemMapping", {}).set({});
InspectorTest.testFileSystemMapping = new WebInspector.FileSystemMapping(); InspectorTest.testFileSystemMapping = new WebInspector.FileSystemMapping();
InspectorTest.testExcludedFolderManager = new WebInspector.ExcludedFolderManager();
InspectorTest.testFileSystemMapping._fileSystemMappingSetting = new InspectorTest.MockSetting({}); InspectorTest.testFileSystemMapping._fileSystemMappingSetting = new InspectorTest.MockSetting({});
InspectorTest.testFileSystemMapping._excludedFoldersSetting = new InspectorTest.MockSetting({}); InspectorTest.testFileSystemMapping._excludedFoldersSetting = new InspectorTest.MockSetting({});
......
...@@ -46,3 +46,21 @@ Removing second file system. ...@@ -46,3 +46,21 @@ Removing second file system.
Removing first file system. Removing first file system.
number of uiSourceCodes in workspace after removing first file system: 0 number of uiSourceCodes in workspace after removing first file system: 0
Running: testFileSystems
-- Default excludes --
Dumping uiSourceCodes origin URLs:
- file:///var/www/html/foo.js
- file:///var/www/bar.js
- file:///var/www/html2/foo.js
-- Excluded /html/ --
Dumping uiSourceCodes origin URLs:
- file:///var/www2/bar.js
- file:///var/www2/html2/foo.js
-- Excluded /html2/ --
Dumping uiSourceCodes origin URLs:
- file:///var/www3/html/foo.js
- file:///var/www3/bar.js
...@@ -75,11 +75,6 @@ function test() ...@@ -75,11 +75,6 @@ function test()
dumpUISourceCodes(uiSourceCodes, uiSourceCodesDumped); dumpUISourceCodes(uiSourceCodes, uiSourceCodesDumped);
} }
function uiSourceCodeAdded(uiSourceCode)
{
uiSourceCodes.push(uiSourceCode)
}
function uiSourceCodesDumped() function uiSourceCodesDumped()
{ {
dumpUISourceCodeLocations(uiSourceCodes, 5); dumpUISourceCodeLocations(uiSourceCodes, 5);
...@@ -126,6 +121,49 @@ function test() ...@@ -126,6 +121,49 @@ function test()
} }
} }
}, },
function testFileSystems(next)
{
function dumpWorkspaceUISourceCodes()
{
InspectorTest.addResult("Dumping uiSourceCodes origin URLs:");
var uiSourceCodes = InspectorTest.fileSystemUISourceCodes();
for (var i = 0; i < uiSourceCodes.length; ++i)
InspectorTest.addResult(" - " + uiSourceCodes[i].originURL());
}
var fs;
function createFileSystem(name)
{
fs = new InspectorTest.TestFileSystem(name);
fs.root.mkdir("html").addFile("foo.js", "");
fs.root.mkdir(".git").addFile("foogit.js", "");
fs.root.addFile("bar.js", "");
fs.root.mkdir("html2").addFile("foo.js", "");
fs.reportCreated();
}
createFileSystem("/var/www");
InspectorTest.addResult("");
InspectorTest.addResult("-- Default excludes --");
dumpWorkspaceUISourceCodes();
fs.removeFileSystem();
WebInspector.settings.createLocalSetting("workspaceExcludedFolders", {}).set({"/var/www2":["/html/"]});
createFileSystem("/var/www2");
InspectorTest.addResult("");
InspectorTest.addResult("-- Excluded /html/ --");
dumpWorkspaceUISourceCodes();
fs.removeFileSystem();
createFileSystem("/var/www3");
InspectorTest.fileSystemUISourceCodes()[0].project().excludeFolder("/html2/");
InspectorTest.addResult("");
InspectorTest.addResult("-- Excluded /html2/ --");
dumpWorkspaceUISourceCodes();
fs.removeFileSystem();
next();
}
]); ]);
}; };
</script> </script>
......
...@@ -94,19 +94,6 @@ function f() ...@@ -94,19 +94,6 @@ function f()
==Source frame contents end== ==Source frame contents end==
Running: testExcludingFolders
Adding file system.
Adding exclusion pattern and excluded folder.
Workspace event: UISourceCodeAdded: filesystem:/var/www/bar.js.
Workspace event: UISourceCodeAdded: filesystem:/var/www/html2/foo.js.
Dumping uiSourceCodes origin URLs:
- file:///var/www/bar.js
- file:///var/www/html2/foo.js
Excluding html2 folder:
Workspace event: UISourceCodeRemoved: filesystem:/var/www/html2/foo.js.
Dumping uiSourceCodes origin URLs:
- file:///var/www/bar.js
Running: testRemoveProject Running: testRemoveProject
Adding file system. Adding file system.
Workspace event: UISourceCodeAdded: filesystem:/var/www/foo.js. Workspace event: UISourceCodeAdded: filesystem:/var/www/foo.js.
......
...@@ -279,35 +279,6 @@ function test() ...@@ -279,35 +279,6 @@ function test()
} }
}, },
function testExcludingFolders(next)
{
function dumpWorkspaceUISourceCodes()
{
InspectorTest.addResult("Dumping uiSourceCodes origin URLs:");
var uiSourceCodes = InspectorTest.testWorkspace.uiSourceCodes();
for (var i = 0; i < uiSourceCodes.length; ++i)
InspectorTest.addResult(" - " + uiSourceCodes[i].originURL());
}
var fileSystemPath = "/var/www";
var fileSystemProjectId = WebInspector.FileSystemWorkspaceBinding.projectId(fileSystemPath);
var files = {"/html/foo.js": "", "/.git/foogit.js": "", "/bar.js": "", "/html2/foo.js": ""};
createObjects();
InspectorTest.addResult("Adding file system.");
manager.addMockFileSystem(fileSystemPath);
InspectorTest.addResult("Adding exclusion pattern and excluded folder.");
InspectorTest.testExcludedFolderManager.addExcludedFolder(fileSystemPath, "/html/");
manager.addFiles(fileSystemPath, files);
dumpWorkspaceUISourceCodes();
InspectorTest.addResult("Excluding html2 folder:");
InspectorTest.testWorkspace.uiSourceCodes()[0].project().excludeFolder("/html2/");
dumpWorkspaceUISourceCodes();
InspectorTest.testExcludedFolderManager.removeExcludedFolder(fileSystemPath, "/html/");
next();
},
function testRemoveProject(next) function testRemoveProject(next)
{ {
function dumpWorkspaceUISourceCodes() function dumpWorkspaceUISourceCodes()
......
...@@ -167,7 +167,6 @@ ...@@ -167,7 +167,6 @@
'front_end/sdk/WorkerManager.js', 'front_end/sdk/WorkerManager.js',
], ],
'devtools_workspace_js_files': [ 'devtools_workspace_js_files': [
'front_end/workspace/ExcludedFolderManager.js',
'front_end/workspace/FileManager.js', 'front_end/workspace/FileManager.js',
'front_end/workspace/FileSystemMapping.js', 'front_end/workspace/FileSystemMapping.js',
'front_end/workspace/IsolatedFileSystem.js', 'front_end/workspace/IsolatedFileSystem.js',
......
...@@ -515,7 +515,7 @@ WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { ...@@ -515,7 +515,7 @@ WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
*/ */
excludeFolder: function(path) excludeFolder: function(path)
{ {
this._fileSystemWorkspaceBinding._isolatedFileSystemManager.excludedFolderManager().addExcludedFolder(this._fileSystem.path(), path); this._fileSystem.addExcludedFolder(path);
}, },
/** /**
......
...@@ -47,8 +47,8 @@ WebInspector.EditFileSystemDialog = function(fileSystemPath) ...@@ -47,8 +47,8 @@ WebInspector.EditFileSystemDialog = function(fileSystemPath)
WebInspector.fileSystemMapping.addEventListener(WebInspector.FileSystemMapping.Events.FileMappingAdded, this._fileMappingAdded, this); WebInspector.fileSystemMapping.addEventListener(WebInspector.FileSystemMapping.Events.FileMappingAdded, this._fileMappingAdded, this);
WebInspector.fileSystemMapping.addEventListener(WebInspector.FileSystemMapping.Events.FileMappingRemoved, this._fileMappingRemoved, this); WebInspector.fileSystemMapping.addEventListener(WebInspector.FileSystemMapping.Events.FileMappingRemoved, this._fileMappingRemoved, this);
WebInspector.isolatedFileSystemManager.excludedFolderManager().addEventListener(WebInspector.ExcludedFolderManager.Events.ExcludedFolderAdded, this._excludedFolderAdded, this); WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.ExcludedFolderAdded, this._excludedFolderAdded, this);
WebInspector.isolatedFileSystemManager.excludedFolderManager().addEventListener(WebInspector.ExcludedFolderManager.Events.ExcludedFolderRemoved, this._excludedFolderRemoved, this); WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.ExcludedFolderRemoved, this._excludedFolderRemoved, this);
var blockHeader = contents.createChild("div", "block-header"); var blockHeader = contents.createChild("div", "block-header");
blockHeader.textContent = WebInspector.UIString("Mappings"); blockHeader.textContent = WebInspector.UIString("Mappings");
...@@ -73,15 +73,16 @@ WebInspector.EditFileSystemDialog = function(fileSystemPath) ...@@ -73,15 +73,16 @@ WebInspector.EditFileSystemDialog = function(fileSystemPath)
blockHeader.textContent = WebInspector.UIString("Excluded folders"); blockHeader.textContent = WebInspector.UIString("Excluded folders");
this._excludedFolderListSection = contents.createChild("div", "section excluded-folders-section"); this._excludedFolderListSection = contents.createChild("div", "section excluded-folders-section");
this._excludedFolderListContainer = this._excludedFolderListSection.createChild("div", "settings-list-container"); this._excludedFolderListContainer = this._excludedFolderListSection.createChild("div", "settings-list-container");
var excludedFolderEntries = WebInspector.isolatedFileSystemManager.excludedFolderManager().excludedFolders(fileSystemPath);
this._excludedFolderList = new WebInspector.EditableSettingsList([pathColumn], this._excludedFolderValueProvider.bind(this), this._excludedFolderValidate.bind(this), this._excludedFolderEdit.bind(this)); this._excludedFolderList = new WebInspector.EditableSettingsList([pathColumn], this._excludedFolderValueProvider.bind(this), this._excludedFolderValidate.bind(this), this._excludedFolderEdit.bind(this));
this._excludedFolderList.addEventListener(WebInspector.SettingsList.Events.Removed, this._excludedFolderRemovedfromList.bind(this)); this._excludedFolderList.addEventListener(WebInspector.SettingsList.Events.Removed, this._excludedFolderRemovedfromList.bind(this));
this._excludedFolderList.element.classList.add("excluded-folders-list"); this._excludedFolderList.element.classList.add("excluded-folders-list");
this._excludedFolderListContainer.appendChild(this._excludedFolderList.element); this._excludedFolderListContainer.appendChild(this._excludedFolderList.element);
this._excludedFolderEntries = new Map(); /** @type {!Set<string>} */
for (var i = 0; i < excludedFolderEntries.length; ++i) this._excludedFolderEntries = new Set();
this._addExcludedFolderRow(excludedFolderEntries[i]); var excludedFolders = WebInspector.isolatedFileSystemManager.fileSystem(fileSystemPath).excludedFolders();
for (var i = 0; i < excludedFolders.length; ++i)
this._addExcludedFolderRow(excludedFolders[i]);
this.element.tabIndex = 0; this.element.tabIndex = 0;
this._hasMappingChanges = false; this._hasMappingChanges = false;
...@@ -274,21 +275,24 @@ WebInspector.EditFileSystemDialog.prototype = { ...@@ -274,21 +275,24 @@ WebInspector.EditFileSystemDialog.prototype = {
this._resize(); this._resize();
}, },
/**
* @param {!WebInspector.Event} event
*/
_excludedFolderAdded: function(event) _excludedFolderAdded: function(event)
{ {
var entry = /** @type {!WebInspector.ExcludedFolderManager.Entry} */ (event.data); var path = /** @type {string} */ (event.data);
this._addExcludedFolderRow(entry); this._addExcludedFolderRow(path);
}, },
/**
* @param {!WebInspector.Event} event
*/
_excludedFolderRemoved: function(event) _excludedFolderRemoved: function(event)
{ {
var entry = /** @type {!WebInspector.ExcludedFolderManager.Entry} */ (event.data); var path = /** @type {string} */ (event.data);
var fileSystemPath = entry.fileSystemPath; delete this._excludedFolderEntries[path];
if (!fileSystemPath || this._fileSystemPath !== fileSystemPath) if (this._excludedFolderList.itemForId(path))
return; this._excludedFolderList.removeItem(path);
delete this._excludedFolderEntries[entry.path];
if (this._excludedFolderList.itemForId(entry.path))
this._excludedFolderList.removeItem(entry.path);
}, },
/** /**
...@@ -329,11 +333,10 @@ WebInspector.EditFileSystemDialog.prototype = { ...@@ -329,11 +333,10 @@ WebInspector.EditFileSystemDialog.prototype = {
*/ */
_excludedFolderEdit: function(itemId, data) _excludedFolderEdit: function(itemId, data)
{ {
var fileSystemPath = this._fileSystemPath;
if (itemId) if (itemId)
WebInspector.isolatedFileSystemManager.excludedFolderManager().removeExcludedFolder(fileSystemPath, itemId); WebInspector.isolatedFileSystemManager.fileSystem(this._fileSystemPath).removeExcludedFolder(itemId);
var excludedFolderPath = data["path"]; var excludedFolderPath = data["path"];
WebInspector.isolatedFileSystemManager.excludedFolderManager().addExcludedFolder(fileSystemPath, excludedFolderPath); WebInspector.isolatedFileSystemManager.fileSystem(this._fileSystemPath).addExcludedFolder(excludedFolderPath);
}, },
/** /**
...@@ -344,19 +347,15 @@ WebInspector.EditFileSystemDialog.prototype = { ...@@ -344,19 +347,15 @@ WebInspector.EditFileSystemDialog.prototype = {
var itemId = /** @type{?string} */ (event.data); var itemId = /** @type{?string} */ (event.data);
if (!itemId) if (!itemId)
return; return;
WebInspector.isolatedFileSystemManager.excludedFolderManager().removeExcludedFolder(this._fileSystemPath, itemId); WebInspector.isolatedFileSystemManager.fileSystem(this._fileSystemPath).removeExcludedFolder(itemId);
}, },
/** /**
* @param {!WebInspector.ExcludedFolderManager.Entry} entry * @param {string} path
*/ */
_addExcludedFolderRow: function(entry) _addExcludedFolderRow: function(path)
{ {
var fileSystemPath = entry.fileSystemPath; this._excludedFolderEntries.add(path);
if (!fileSystemPath || this._fileSystemPath !== fileSystemPath)
return;
var path = entry.path;
this._excludedFolderEntries.set(path, entry);
this._excludedFolderList.addItem(path, null); this._excludedFolderList.addItem(path, null);
this._resize(); this._resize();
}, },
......
...@@ -340,7 +340,7 @@ WebInspector.WorkspaceSettingsTab = function() ...@@ -340,7 +340,7 @@ WebInspector.WorkspaceSettingsTab = function()
WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this); WebInspector.isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this);
this._commonSection = this._appendSection(WebInspector.UIString("Common")); this._commonSection = this._appendSection(WebInspector.UIString("Common"));
var folderExcludeSetting = WebInspector.isolatedFileSystemManager.excludedFolderManager().workspaceFolderExcludePatternSetting(); var folderExcludeSetting = WebInspector.isolatedFileSystemManager.workspaceFolderExcludePatternSetting();
var folderExcludePatternInput = WebInspector.SettingsUI.createSettingInputField(WebInspector.UIString("Folder exclude pattern"), folderExcludeSetting, false, 0, "270px", WebInspector.SettingsUI.regexValidator); var folderExcludePatternInput = WebInspector.SettingsUI.createSettingInputField(WebInspector.UIString("Folder exclude pattern"), folderExcludeSetting, false, 0, "270px", WebInspector.SettingsUI.regexValidator);
this._commonSection.appendChild(folderExcludePatternInput); this._commonSection.appendChild(folderExcludePatternInput);
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @constructor
* @extends {WebInspector.Object}
*/
WebInspector.ExcludedFolderManager = function()
{
WebInspector.Object.call(this);
this._excludedFoldersSetting = WebInspector.settings.createLocalSetting("workspaceExcludedFolders", {});
var defaultCommonExcludedFolders = [
"/\\.git/",
"/\\.sass-cache/",
"/\\.hg/",
"/\\.idea/",
"/\\.svn/",
"/\\.cache/",
"/\\.project/"
];
var defaultWinExcludedFolders = [
"/Thumbs.db$",
"/ehthumbs.db$",
"/Desktop.ini$",
"/\\$RECYCLE.BIN/"
];
var defaultMacExcludedFolders = [
"/\\.DS_Store$",
"/\\.Trashes$",
"/\\.Spotlight-V100$",
"/\\.AppleDouble$",
"/\\.LSOverride$",
"/Icon$",
"/\\._.*$"
];
var defaultLinuxExcludedFolders = [
"/.*~$"
];
var defaultExcludedFolders = defaultCommonExcludedFolders;
if (WebInspector.isWin())
defaultExcludedFolders = defaultExcludedFolders.concat(defaultWinExcludedFolders);
else if (WebInspector.isMac())
defaultExcludedFolders = defaultExcludedFolders.concat(defaultMacExcludedFolders);
else
defaultExcludedFolders = defaultExcludedFolders.concat(defaultLinuxExcludedFolders);
var defaultExcludedFoldersPattern = defaultExcludedFolders.join("|");
this._workspaceFolderExcludePatternSetting = WebInspector.settings.createRegExpSetting("workspaceFolderExcludePattern", defaultExcludedFoldersPattern, WebInspector.isWin() ? "i" : "");
/** @type {!Object.<string, !Array.<!WebInspector.ExcludedFolderManager.Entry>>} */
this._excludedFolders = {};
this._loadFromSettings();
}
WebInspector.ExcludedFolderManager.Events = {
ExcludedFolderAdded: "ExcludedFolderAdded",
ExcludedFolderRemoved: "ExcludedFolderRemoved"
}
WebInspector.ExcludedFolderManager.prototype = {
/**
* @return {!WebInspector.Setting}
*/
workspaceFolderExcludePatternSetting: function()
{
return this._workspaceFolderExcludePatternSetting;
},
_loadFromSettings: function()
{
var savedExcludedFolders = this._excludedFoldersSetting.get();
this._excludedFolders = {};
for (var fileSystemPath in savedExcludedFolders) {
var savedExcludedFoldersForPath = savedExcludedFolders[fileSystemPath];
this._excludedFolders[fileSystemPath] = [];
var excludedFolders = this._excludedFolders[fileSystemPath];
for (var i = 0; i < savedExcludedFoldersForPath.length; ++i) {
var savedEntry = savedExcludedFoldersForPath[i];
var entry = new WebInspector.ExcludedFolderManager.Entry(savedEntry.fileSystemPath, savedEntry.path);
excludedFolders.push(entry);
}
}
},
_saveToSettings: function()
{
var savedExcludedFolders = this._excludedFolders;
this._excludedFoldersSetting.set(savedExcludedFolders);
},
/**
* @param {string} fileSystemPath
* @param {string} excludedFolderPath
*/
addExcludedFolder: function(fileSystemPath, excludedFolderPath)
{
if (!this._excludedFolders[fileSystemPath])
this._excludedFolders[fileSystemPath] = [];
var entry = new WebInspector.ExcludedFolderManager.Entry(fileSystemPath, excludedFolderPath);
this._excludedFolders[fileSystemPath].push(entry);
this._saveToSettings();
this.dispatchEventToListeners(WebInspector.ExcludedFolderManager.Events.ExcludedFolderAdded, entry);
},
/**
* @param {string} fileSystemPath
* @param {string} path
*/
removeExcludedFolder: function(fileSystemPath, path)
{
var entry = this._excludedFolderEntryForPath(fileSystemPath, path);
if (!entry)
return;
this._excludedFolders[fileSystemPath].remove(entry);
this._saveToSettings();
this.dispatchEventToListeners(WebInspector.ExcludedFolderManager.Events.ExcludedFolderRemoved, entry);
},
/**
* @param {string} fileSystemPath
*/
removeFileSystem: function(fileSystemPath)
{
delete this._excludedFolders[fileSystemPath];
this._saveToSettings();
},
/**
* @param {string} fileSystemPath
* @param {string} path
* @return {?WebInspector.ExcludedFolderManager.Entry}
*/
_excludedFolderEntryForPath: function(fileSystemPath, path)
{
var entries = this._excludedFolders[fileSystemPath];
if (!entries)
return null;
for (var i = 0; i < entries.length; ++i) {
if (entries[i].path === path)
return entries[i];
}
return null;
},
/**
* @param {string} fileSystemPath
* @param {string} folderPath
* @return {boolean}
*/
isFileExcluded: function(fileSystemPath, folderPath)
{
var excludedFolders = this._excludedFolders[fileSystemPath] || [];
for (var i = 0; i < excludedFolders.length; ++i) {
var entry = excludedFolders[i];
if (entry.path === folderPath)
return true;
}
var regex = this._workspaceFolderExcludePatternSetting.asRegExp();
return !!(regex && regex.test(folderPath));
},
/**
* @param {string} fileSystemPath
* @return {!Array.<!WebInspector.ExcludedFolderManager.Entry>}
*/
excludedFolders: function(fileSystemPath)
{
var excludedFolders = this._excludedFolders[fileSystemPath];
return excludedFolders ? excludedFolders.slice() : [];
},
__proto__: WebInspector.Object.prototype
}
/**
* @constructor
* @param {string} fileSystemPath
* @param {string} path
*/
WebInspector.ExcludedFolderManager.Entry = function(fileSystemPath, path)
{
this.fileSystemPath = fileSystemPath;
this.path = path;
}
...@@ -40,6 +40,8 @@ WebInspector.IsolatedFileSystem = function(manager, path, name, rootURL) ...@@ -40,6 +40,8 @@ WebInspector.IsolatedFileSystem = function(manager, path, name, rootURL)
this._manager = manager; this._manager = manager;
this._path = path; this._path = path;
this._domFileSystem = InspectorFrontendHost.isolatedFileSystem(name, rootURL); this._domFileSystem = InspectorFrontendHost.isolatedFileSystem(name, rootURL);
this._excludedFoldersSetting = WebInspector.settings.createLocalSetting("workspaceExcludedFolders", {});
this._excludedFolders = this._excludedFoldersSetting.get()[path] || [];
} }
/** /**
...@@ -101,12 +103,12 @@ WebInspector.IsolatedFileSystem.prototype = { ...@@ -101,12 +103,12 @@ WebInspector.IsolatedFileSystem.prototype = {
for (var i = 0; i < entries.length; ++i) { for (var i = 0; i < entries.length; ++i) {
var entry = entries[i]; var entry = entries[i];
if (!entry.isDirectory) { if (!entry.isDirectory) {
if (this._manager.excludedFolderManager().isFileExcluded(this._path, entry.fullPath)) if (this._isFileExcluded(entry.fullPath))
continue; continue;
fileCallback(entry.fullPath.substr(1)); fileCallback(entry.fullPath.substr(1));
} }
else { else {
if (this._manager.excludedFolderManager().isFileExcluded(this._path, entry.fullPath + "/")) if (this._isFileExcluded(entry.fullPath + "/"))
continue; continue;
++pendingRequests; ++pendingRequests;
this._requestEntries(entry.fullPath, innerCallback.bind(this)); this._requestEntries(entry.fullPath, innerCallback.bind(this));
...@@ -486,5 +488,61 @@ WebInspector.IsolatedFileSystem.prototype = { ...@@ -486,5 +488,61 @@ WebInspector.IsolatedFileSystem.prototype = {
console.error(errorMessage + " when requesting entry '" + path + "'"); console.error(errorMessage + " when requesting entry '" + path + "'");
callback([]); callback([]);
} }
},
_saveExcludedFolders: function()
{
var settingValue = this._excludedFoldersSetting.get();
settingValue[this._path] = this._excludedFolders;
this._excludedFoldersSetting.set(settingValue);
},
/**
* @param {string} path
*/
addExcludedFolder: function(path)
{
this._excludedFolders.push(path);
this._saveExcludedFolders();
this._manager.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.ExcludedFolderAdded, path);
},
/**
* @param {string} path
*/
removeExcludedFolder: function(path)
{
this._excludedFolders.remove(path);
this._saveExcludedFolders();
this._manager.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.ExcludedFolderRemoved, path);
},
fileSystemRemoved: function()
{
var settingValue = this._excludedFoldersSetting.get();
delete settingValue[this._path];
this._excludedFoldersSetting.set(settingValue);
},
/**
* @param {string} folderPath
* @return {boolean}
*/
_isFileExcluded: function(folderPath)
{
for (var i = 0; i < this._excludedFolders.length; ++i) {
if (this._excludedFolders[i] === folderPath)
return true;
}
var regex = this._manager.workspaceFolderExcludePatternSetting().asRegExp();
return !!(regex && regex.test(folderPath));
},
/**
* @return {!Array<string>}
*/
excludedFolders: function()
{
return this._excludedFolders.slice();
} }
} }
...@@ -36,11 +36,12 @@ WebInspector.IsolatedFileSystemManager = function() ...@@ -36,11 +36,12 @@ WebInspector.IsolatedFileSystemManager = function()
{ {
/** @type {!Object.<string, !WebInspector.IsolatedFileSystem>} */ /** @type {!Object.<string, !WebInspector.IsolatedFileSystem>} */
this._fileSystems = {}; this._fileSystems = {};
this._excludedFolderManager = new WebInspector.ExcludedFolderManager();
InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.FileSystemsLoaded, this._onFileSystemsLoaded, this); InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.FileSystemsLoaded, this._onFileSystemsLoaded, this);
InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.FileSystemRemoved, this._onFileSystemRemoved, this); InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.FileSystemRemoved, this._onFileSystemRemoved, this);
InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.FileSystemAdded, this._onFileSystemAdded, this); InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Events.FileSystemAdded, this._onFileSystemAdded, this);
this._initExcludePatterSetting();
} }
/** @typedef {!{fileSystemName: string, rootURL: string, fileSystemPath: string}} */ /** @typedef {!{fileSystemName: string, rootURL: string, fileSystemPath: string}} */
...@@ -48,24 +49,17 @@ WebInspector.IsolatedFileSystemManager.FileSystem; ...@@ -48,24 +49,17 @@ WebInspector.IsolatedFileSystemManager.FileSystem;
WebInspector.IsolatedFileSystemManager.Events = { WebInspector.IsolatedFileSystemManager.Events = {
FileSystemAdded: "FileSystemAdded", FileSystemAdded: "FileSystemAdded",
FileSystemRemoved: "FileSystemRemoved" FileSystemRemoved: "FileSystemRemoved",
ExcludedFolderAdded: "ExcludedFolderAdded",
ExcludedFolderRemoved: "ExcludedFolderRemoved"
} }
WebInspector.IsolatedFileSystemManager.prototype = { WebInspector.IsolatedFileSystemManager.prototype = {
/**
* @return {!WebInspector.ExcludedFolderManager}
*/
excludedFolderManager: function()
{
return this._excludedFolderManager;
},
/** /**
* @param {function()} callback * @param {function()} callback
*/ */
initialize: function(callback) initialize: function(callback)
{ {
console.assert(!this._loaded);
this._initializeCallback = callback; this._initializeCallback = callback;
InspectorFrontendHost.requestFileSystems(); InspectorFrontendHost.requestFileSystems();
}, },
...@@ -95,8 +89,6 @@ WebInspector.IsolatedFileSystemManager.prototype = { ...@@ -95,8 +89,6 @@ WebInspector.IsolatedFileSystemManager.prototype = {
addedFileSystemPaths[fileSystems[i].fileSystemPath] = true; addedFileSystemPaths[fileSystems[i].fileSystemPath] = true;
} }
this._loaded = true;
this._initializeCallback(); this._initializeCallback();
delete this._initializeCallback; delete this._initializeCallback;
}, },
...@@ -138,11 +130,12 @@ WebInspector.IsolatedFileSystemManager.prototype = { ...@@ -138,11 +130,12 @@ WebInspector.IsolatedFileSystemManager.prototype = {
*/ */
_fileSystemRemoved: function(fileSystemPath) _fileSystemRemoved: function(fileSystemPath)
{ {
this._excludedFolderManager.removeFileSystem(fileSystemPath);
var isolatedFileSystem = this._fileSystems[fileSystemPath]; var isolatedFileSystem = this._fileSystems[fileSystemPath];
delete this._fileSystems[fileSystemPath]; delete this._fileSystems[fileSystemPath];
if (isolatedFileSystem) if (isolatedFileSystem) {
isolatedFileSystem.fileSystemRemoved();
this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, isolatedFileSystem); this.dispatchEventToListeners(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, isolatedFileSystem);
}
}, },
/** /**
...@@ -153,6 +146,63 @@ WebInspector.IsolatedFileSystemManager.prototype = { ...@@ -153,6 +146,63 @@ WebInspector.IsolatedFileSystemManager.prototype = {
return Object.keys(this._fileSystems); return Object.keys(this._fileSystems);
}, },
/**
* @param {string} fileSystemPath
* @return {?WebInspector.IsolatedFileSystem}
*/
fileSystem: function(fileSystemPath)
{
return this._fileSystems[fileSystemPath];
},
_initExcludePatterSetting: function()
{
var defaultCommonExcludedFolders = [
"/\\.git/",
"/\\.sass-cache/",
"/\\.hg/",
"/\\.idea/",
"/\\.svn/",
"/\\.cache/",
"/\\.project/"
];
var defaultWinExcludedFolders = [
"/Thumbs.db$",
"/ehthumbs.db$",
"/Desktop.ini$",
"/\\$RECYCLE.BIN/"
];
var defaultMacExcludedFolders = [
"/\\.DS_Store$",
"/\\.Trashes$",
"/\\.Spotlight-V100$",
"/\\.AppleDouble$",
"/\\.LSOverride$",
"/Icon$",
"/\\._.*$"
];
var defaultLinuxExcludedFolders = [
"/.*~$"
];
var defaultExcludedFolders = defaultCommonExcludedFolders;
if (WebInspector.isWin())
defaultExcludedFolders = defaultExcludedFolders.concat(defaultWinExcludedFolders);
else if (WebInspector.isMac())
defaultExcludedFolders = defaultExcludedFolders.concat(defaultMacExcludedFolders);
else
defaultExcludedFolders = defaultExcludedFolders.concat(defaultLinuxExcludedFolders);
var defaultExcludedFoldersPattern = defaultExcludedFolders.join("|");
this._workspaceFolderExcludePatternSetting = WebInspector.settings.createRegExpSetting("workspaceFolderExcludePattern", defaultExcludedFoldersPattern, WebInspector.isWin() ? "i" : "");
},
/**
* @return {!WebInspector.Setting}
*/
workspaceFolderExcludePatternSetting: function()
{
return this._workspaceFolderExcludePatternSetting;
},
__proto__: WebInspector.Object.prototype __proto__: WebInspector.Object.prototype
} }
......
{ {
"dependencies": ["common", "host", "platform"], "dependencies": ["common", "host", "platform"],
"scripts": [ "scripts": [
"ExcludedFolderManager.js",
"FileManager.js", "FileManager.js",
"FileSystemMapping.js", "FileSystemMapping.js",
"IsolatedFileSystem.js", "IsolatedFileSystem.js",
......
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