forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProjectModel.js
More file actions
1 lines (1 loc) · 22.4 KB
/
ProjectModel.js
File metadata and controls
1 lines (1 loc) · 22.4 KB
1
define(function(require,exports,module){var InMemoryFile=require("document/InMemoryFile"),EventDispatcher=require("utils/EventDispatcher"),FileUtils=require("file/FileUtils"),_=require("thirdparty/lodash"),FileSystem=require("filesystem/FileSystem"),DocumentManager=require("document/DocumentManager"),FileSystemError=require("filesystem/FileSystemError"),FileTreeViewModel=require("project/FileTreeViewModel"),Async=require("utils/Async"),PerfUtils=require("utils/PerfUtils");const EVENT_CHANGE="change",EVENT_SHOULD_SELECT="select",EVENT_SHOULD_FOCUS="focus",EVENT_FS_RENAME_STARTED="mvStart",EVENT_FS_RENAME_END="mvEnd",ERROR_CREATION="creationError",ERROR_INVALID_FILENAME="invalidFilename",ERROR_NOT_IN_PROJECT="notInProject";var _exclusionListRegEx=/\.pyc$|^\.git$|^\.gitmodules$|^\.svn$|^\.DS_Store$|^Icon\r|^Thumbs\.db$|^\.hg$|^CVS$|^\.hgtags$|^\.idea$|^\.c9revisions$|^\.SyncArchive$|^\.SyncID$|^\.SyncIgnore$|\~$/,_cacheExcludeFileNameRegEx=/^node_modules$|^bower_components$|^.npm$|^.yarn$|^__pycache__$/;const defaultIgnoreGlobs=["node_modules/**","**/node_modules/**","bower_components/**","**/bower_components/**",".npm",".yarn","__pycache__",".pyc",".git",".gitmodules",".svn",".DS_Store","Thumbs.db",".hg","CVS",".hgtags",".idea",".c9revisions",".SyncArchive",".SyncID",".SyncIgnore"];var _invalidChars=/([?\*\|\<\>"]+|\/{2,}|\.{2,}|\.$)/i,_illegalFilenamesRegEx=/((\b(com[0-9]+|lpt[0-9]+|nul|con|prn|aux)\b)|\.+$|\/+|\\+|\:)/i;function isValidFilename(filename){return!(filename.match(_invalidChars)||filename.match(_illegalFilenamesRegEx))}function isValidPath(path){return!path.match(_invalidChars)}function _shouldShowName(name){return!_exclusionListRegEx.test(name)}function shouldShow(entry){return _shouldShowName(entry.name)}function shouldIndex(entry){return shouldShow(entry)&&!_cacheExcludeFileNameRegEx.test(entry.name)}FileSystem.setFileTreeFilter(_shouldShowName);const FILE_RENAMING=0,FILE_CREATING=1,RENAME_CANCELLED=2;function _pathIsFile(path){return"/"!==_.last(path)}function _getFSObject(path){return path?_pathIsFile(path)?FileSystem.getFileForPath(path):FileSystem.getDirectoryForPath(path):path}function _getPathFromFSObject(fsobj){return fsobj&&fsobj.fullPath?fsobj.fullPath:fsobj}function doCreate(path,isFolder){const d=new $.Deferred,filename=FileUtils.getBaseName(path);return isValidFilename(filename)&&isValidPath(path)?(FileSystem.resolve(path,function(err){if(err)if(isFolder){const directory=FileSystem.getDirectoryForPath(path);directory.create(function(err){err?d.reject(err):d.resolve(directory)})}else{const file=FileSystem.getFileForPath(path);FileUtils.writeText(file,"").then(function(){d.resolve(file)},d.reject)}else d.reject(FileSystemError.ALREADY_EXISTS)}),d.promise()):d.reject(ERROR_INVALID_FILENAME).promise()}function ProjectModel(initial){(initial=initial||{}).projectRoot&&(this.projectRoot=initial.projectRoot),void 0!==initial.focused&&(this._focused=initial.focused),this._viewModel=new FileTreeViewModel.FileTreeViewModel,this._viewModel.on(FileTreeViewModel.EVENT_CHANGE,function(){this.trigger(EVENT_CHANGE)}.bind(this)),this._selections={}}function _getGitIgnoreFileContent(fullPath){return new Promise(resolve=>{DocumentManager.getDocumentForPath(fullPath).done(function(doc){resolve(doc.getText()||"")}).fail(function(){resolve(null)})})}function _gitIgnores(entry,gitIgnoreFilters){try{for(let filter of gitIgnoreFilters){const relativePath=path.relative(filter.basePath,entry.fullPath);if(relativePath&&!relativePath.startsWith("..")&&filter.gitIgnore.ignores(relativePath))return!0}}catch(e){console.error("Error while filtering get all files: ",e)}return!1}async function _updateGitIgnoreFromPath(gitIgnorePath,parentFullPath,gitIgnoreSearchedInDir,gitIgnoreFilters){const gitIgnoreContent=await _getGitIgnoreFileContent(gitIgnorePath);gitIgnoreSearchedInDir[parentFullPath]=!0,gitIgnoreContent&&gitIgnoreFilters.push({basePath:parentFullPath,gitIgnore:fs.utils.ignore().add(gitIgnoreContent),gitIgnoreContent:gitIgnoreContent})}async function _updateGitIgnore(entry,siblingEntries,gitIgnoreSearchedInDir,gitIgnoreFilters){const parentFullPath=`${path.dirname(entry.fullPath)}/`;if(!gitIgnoreSearchedInDir[parentFullPath]&&siblingEntries)for(let sibling of siblingEntries)sibling.isFile&&".gitignore"===sibling.name&&await _updateGitIgnoreFromPath(sibling.fullPath,parentFullPath,gitIgnoreSearchedInDir,gitIgnoreFilters)}function _ensureTrailingSlash(fullPath){return _pathIsFile(fullPath)?fullPath+"/":fullPath}function _addWelcomeProjectPath(path,currentProjects){var pathNoSlash=FileUtils.stripTrailingSlash(path),newProjects;return-1===(newProjects=currentProjects?_.clone(currentProjects):[]).indexOf(pathNoSlash)&&newProjects.push(pathNoSlash),newProjects}function _isWelcomeProjectPath(path,welcomeProjectPath,welcomeProjects){if(path===welcomeProjectPath)return!0;if(!welcomeProjects)return!1;var pathNoSlash=FileUtils.stripTrailingSlash(path);return-1!==welcomeProjects.indexOf(pathNoSlash)}EventDispatcher.makeEventDispatcher(ProjectModel.prototype),ProjectModel.prototype.projectRoot=null,ProjectModel.prototype._viewModel=null,ProjectModel.prototype._projectBaseUrl="",ProjectModel.prototype._selections=null,ProjectModel.prototype._focused=!0,ProjectModel.prototype._currentPath=null,ProjectModel.prototype._allFilesCachePromise=null,ProjectModel.prototype._allFilesScopeCachePromise=null,ProjectModel.prototype._allFilesScope=null,ProjectModel.prototype.setFocused=function(focused){this._focused=focused,focused||this.setSelected(null)},ProjectModel.prototype.setSelectionWidth=function(width){this._viewModel.setSelectionWidth(width)},ProjectModel.prototype.setScrollerInfo=function(scrollWidth,scrollTop,scrollLeft,offsetTop){this._viewModel.setSelectionScrollerInfo(scrollWidth,scrollTop,scrollLeft,offsetTop)},ProjectModel.prototype.getBaseUrl=function getBaseUrl(){return this._projectBaseUrl},ProjectModel.prototype.setBaseUrl=function setBaseUrl(projectBaseUrl){return projectBaseUrl.length>0&&"/"!==projectBaseUrl[projectBaseUrl.length-1]&&(projectBaseUrl+="/"),this._projectBaseUrl=projectBaseUrl,projectBaseUrl},ProjectModel.prototype.isWithinProject=function isWithinProject(absPathOrEntry){var absPath=absPathOrEntry.fullPath||absPathOrEntry;return this.projectRoot&&0===absPath.indexOf(this.projectRoot.fullPath)},ProjectModel.prototype.makeProjectRelativeIfPossible=function makeProjectRelativeIfPossible(absPath){return absPath&&this.isWithinProject(absPath)?absPath.slice(this.projectRoot.fullPath.length):absPath},ProjectModel.prototype.getDirectoryInProject=function(path){return path&&"string"==typeof path?"/"!==_.last(path)&&(path+="/"):path=path&&path.isDirectory?path.fullPath:null,path&&"string"==typeof path&&this.isWithinProject(path)||(path=this.projectRoot.fullPath),path},ProjectModel.prototype.computeProjectGitIgnoreAsync=async function(){let self=this;return new Promise(resolve=>{let gitIgnoreFilters=[];jsPromise(self._getAllFilesCache(!1,gitIgnoreFilters)).catch(console.error).finally(()=>{resolve(gitIgnoreFilters)})})},ProjectModel.prototype._getAllFilesCache=function _getAllFilesCache(sort,_gitIgnoreFiltersOut){let self=this;if(!this._allFilesCachePromise){let gitIgnoreFilters=_gitIgnoreFiltersOut||[],gitIgnoreSearchedInDir={},deferred=new $.Deferred,allFiles=[],allFilesVisitor=async function(entry,siblingEntries){return entry.isDirectory&&self.projectRoot.fullPath===entry.fullPath&&await _updateGitIgnoreFromPath(`${entry.fullPath}.gitignore`,entry.fullPath,gitIgnoreSearchedInDir,gitIgnoreFilters),await _updateGitIgnore(entry,siblingEntries,gitIgnoreSearchedInDir,gitIgnoreFilters),!(!shouldIndex(entry)||_gitIgnores(entry,gitIgnoreFilters))&&(entry.isFile&&allFiles.push(entry),!0)};this._allFilesCachePromise=deferred.promise();var projectIndexTimer=PerfUtils.markStart("Creating project files cache: "+this.projectRoot.fullPath),options={sortList:sort};this.projectRoot.visit(allFilesVisitor,options,function(err){err?(PerfUtils.finalizeMeasurement(projectIndexTimer),deferred.reject(err)):(PerfUtils.addMeasurement(projectIndexTimer),deferred.resolve(allFiles))}.bind(this))}return this._allFilesCachePromise},ProjectModel.prototype._getAllFilesInScopeCache=function(sort,scope){let self=this;if(!this.isWithinProject(scope))return(new $.Deferred).reject(new Error(`Scope ${scope.fullPath} should be within project root ${self.projectRoot}`)).promise();if(!this._allFilesScopeCachePromise||this._allFilesScope!==scope){this._allFilesScope=scope;let gitIgnoreFilters=[],gitIgnoreSearchedInDir={};const deferred=new $.Deferred,allFiles=[],allFilesVisitor=async function(entry,siblingEntries){return entry.isDirectory&&self.projectRoot.fullPath===entry.fullPath&&await _updateGitIgnoreFromPath(`${entry.fullPath}.gitignore`,entry.fullPath,gitIgnoreSearchedInDir,gitIgnoreFilters),await _updateGitIgnore(entry,siblingEntries,gitIgnoreSearchedInDir,gitIgnoreFilters),!((!shouldIndex(entry)||_gitIgnores(entry,gitIgnoreFilters))&&entry.fullPath!==scope.fullPath)&&(entry.isFile&&allFiles.push(entry),!0)};this._allFilesScopeCachePromise=deferred.promise();const scopeTimer=PerfUtils.markStart("Project scope files cache: "+scope.fullPath),options={sortList:sort};scope.visit(allFilesVisitor,options,function(err){err?(PerfUtils.finalizeMeasurement(scopeTimer),deferred.reject(err)):(PerfUtils.addMeasurement(scopeTimer),deferred.resolve(allFiles))}.bind(this))}return this._allFilesScopeCachePromise},ProjectModel.prototype.getAllFiles=function getAllFiles(filter,additionalFiles,sort,options){"function"!=typeof filter&&(options=sort,sort=additionalFiles,additionalFiles=filter,filter=null),options=options||{};var filteredFilesDeferred=new $.Deferred;const getAllFilesFn=options.scope?this._getAllFilesInScopeCache.bind(this):this._getAllFilesCache.bind(this);return getAllFilesFn(sort,options.scope).done(function(result){result=[...result],additionalFiles&&additionalFiles.forEach(function(file){-1!==result.indexOf(file)||file instanceof InMemoryFile||result.push(file)}),filter&&(result=result.filter(filter));try{filteredFilesDeferred.resolve(result)}catch(e){console.error("Unhandled exception in getAllFiles handler: "+e,e.stack)}}).fail(function(err){try{filteredFilesDeferred.reject(err)}catch(e){console.error("Unhandled exception in getAllFiles handler: "+e,e.stack)}}),filteredFilesDeferred.promise()},ProjectModel.prototype._resetCache=function _resetCache(){this._allFilesCachePromise=null,this._allFilesScopeCachePromise=null,this._allFilesScope=null},ProjectModel.prototype.setProjectRoot=function(projectRoot){this.projectRoot=projectRoot,this._resetCache(),this._viewModel._rootChanged();var d=new $.Deferred,self=this;return projectRoot.getContents(function(err,contents){err?d.reject(err):(self._viewModel.setDirectoryContents("",contents),d.resolve())}),d.promise()},ProjectModel.prototype._getDirectoryContents=function(path){var d=new $.Deferred;return FileSystem.getDirectoryForPath(path).getContents(function(err,contents){err?d.reject(err):d.resolve(contents)}),d.promise()},ProjectModel.prototype.setDirectoryOpen=function(path,open){var projectRelative=this.makeProjectRelativeIfPossible(path),needsLoading=!this._viewModel.isPathLoaded(projectRelative),d=new $.Deferred,self=this;function onSuccess(contents){if(contents&&self._viewModel.setDirectoryContents(projectRelative,contents),open){if(self._viewModel.openPath(projectRelative),self._focused){var currentPathInProject=self.makeProjectRelativeIfPossible(self._currentPath);self._viewModel.isFilePathVisible(currentPathInProject)?self.setSelected(self._currentPath,!0):self.setSelected(null)}}else{self._viewModel.setDirectoryOpen(projectRelative,!1);var selected=self._selections.selected;if(selected){var relativeSelected=self.makeProjectRelativeIfPossible(selected);self._viewModel.isFilePathVisible(relativeSelected)||self.setSelected(null)}}d.resolve()}if(open&&needsLoading){var parentDirectory=FileUtils.getDirectoryPath(FileUtils.stripTrailingSlash(path));this.setDirectoryOpen(parentDirectory,!0).then(function(){self._getDirectoryContents(path).then(onSuccess).fail(function(err){d.reject(err)})},function(err){d.reject(err)})}else onSuccess();return d.promise()},ProjectModel.prototype.showInTree=function(path){var d=new $.Deferred;if(path=_getPathFromFSObject(path),!this.isWithinProject(path))return Phoenix.app.openPathInFileBrowser(path).then(d.resolve).catch(d.reject),d.promise();const self=this;return this.setDirectoryOpen(FileUtils.getDirectoryPath(path),!0).then(function(){_pathIsFile(path)&&self.setSelected(path),d.resolve()},function(err){d.reject(err)}),d.promise()},ProjectModel.prototype.setSelected=function(path,doNotOpen){if(_pathIsFile(path=_getPathFromFSObject(path))){var oldProjectPath=this.makeProjectRelativeIfPossible(this._selections.selected),pathInProject=this.makeProjectRelativeIfPossible(path);path&&!this._viewModel.isFilePathVisible(pathInProject)&&(path=null,pathInProject=null),this.performRename(),this._viewModel.moveMarker("selected",oldProjectPath,pathInProject),this._selections.context&&(this._viewModel.moveMarker("context",this.makeProjectRelativeIfPossible(this._selections.context),null),delete this._selections.context);var previousSelection=this._selections.selected;this._selections.selected=path,path&&(doNotOpen||this.trigger("select",{path:path,previousPath:previousSelection,hadFocus:this._focused}),this.trigger("focus"))}},ProjectModel.prototype.getSelected=function(){return _getFSObject(this._selections.selected)},ProjectModel.prototype.setCurrentFile=function(curFile){this._currentPath=_getPathFromFSObject(curFile)},ProjectModel.prototype.selectInWorkingSet=function(path){this.performRename(),this.trigger("select",{path:path,add:!0})},ProjectModel.prototype.setContext=function(path,_doNotRename,_saveContext){_saveContext?this._selections.previousContext=path||this._selections.context:delete this._selections.previousContext,path=_getPathFromFSObject(path),_doNotRename||this.performRename();var currentContext=this._selections.context;this._selections.context=path,this._viewModel.moveMarker("context",this.makeProjectRelativeIfPossible(currentContext),this.makeProjectRelativeIfPossible(path))},ProjectModel.prototype.restoreContext=function(){this._selections.previousContext&&this.setContext(this._selections.previousContext)},ProjectModel.prototype.getContext=function(){return _getFSObject(this._selections.context)},ProjectModel.prototype.startRename=function(path,isMoved){var d=new $.Deferred;if(!(path=_getPathFromFSObject(path))&&!(path=this._selections.context))return d.resolve().promise();if(this._selections.rename&&this._selections.rename.path===path)return d.resolve().promise();if(!this.isWithinProject(path))return d.reject({type:"notInProject",isFolder:!_pathIsFile(path),fullPath:path}).promise();var projectRelativePath=this.makeProjectRelativeIfPossible(path);return this._viewModel.isFilePathVisible(projectRelativePath)||this.showInTree(path),isMoved||(path!==this._selections.context?this.setContext(path):this.performRename(),this._viewModel.moveMarker("rename",null,projectRelativePath)),this._selections.rename={deferred:d,type:0,path:path,newPath:path},d.promise()},ProjectModel.prototype.setRenameValue=function(newPath){this._selections.rename&&(this._selections.rename.newPath=newPath)},ProjectModel.prototype.cancelRename=function(){var renameInfo=this._selections.rename;renameInfo&&(1!==renameInfo.type?(this._viewModel.moveMarker("rename",this.makeProjectRelativeIfPossible(renameInfo.path),null),renameInfo.deferred.resolve(2),delete this._selections.rename,this.setContext(null)):this._cancelCreating())},ProjectModel.prototype._renameItem=function(oldPath,newPath,newName){const result=new $.Deferred,isFolder=!_pathIsFile(oldPath),self=this;if(oldPath===newPath)result.resolve();else if(isValidFilename(newName)){var entry=isFolder?FileSystem.getDirectoryForPath(oldPath):FileSystem.getFileForPath(oldPath);self.trigger("mvStart"),entry.rename(newPath,function(err){self.trigger("mvEnd"),err?result.reject(err):result.resolve()})}else result.reject(ERROR_INVALID_FILENAME);return result.promise()},ProjectModel.prototype.performRename=function(){var renameInfo=this._selections.rename;if(renameInfo){var oldPath=renameInfo.path,isFolder=renameInfo.isFolder||!_pathIsFile(oldPath),oldProjectPath=this.makeProjectRelativeIfPossible(oldPath),parentDirectory=FileUtils.getDirectoryPath(isFolder?FileUtils.stripTrailingSlash(oldPath):oldPath),oldName=FileUtils.getBaseName(oldPath),newPath=renameInfo.newPath,newName=FileUtils.getBaseName(newPath),viewModel=this._viewModel,self=this;1===renameInfo.type||oldPath!==newPath?(isFolder&&"/"!==_.last(newPath)&&(newPath+="/"),delete this._selections.rename,delete this._selections.context,viewModel.moveMarker("rename",oldProjectPath,null),viewModel.moveMarker("context",oldProjectPath,null),viewModel.moveMarker("creating",oldProjectPath,null),1===renameInfo.type?this.createAtPath(newPath).done(function(entry){finalizeRename(),renameInfo.deferred.resolve(entry)}).fail(function(error){self._viewModel.deleteAtPath(self.makeProjectRelativeIfPossible(renameInfo.path)),renameInfo.deferred.reject(error)}):this._renameItem(oldPath,newPath,newName).then(function(){finalizeRename(),renameInfo.deferred.resolve({newPath:newPath})}).fail(function(errorType){var errorInfo={type:errorType,isFolder:isFolder,fullPath:oldPath};renameInfo.deferred.reject(errorInfo)})):this.cancelRename()}function finalizeRename(){viewModel.renameItem(oldProjectPath,self.makeProjectRelativeIfPossible(newPath)),self._selections.selected&&0===self._selections.selected.indexOf(oldPath)&&(self._selections.selected=newPath+self._selections.selected.slice(oldPath.length),self.setCurrentFile(newPath))}},ProjectModel.prototype.createAtPath=function(path){var isFolder=!_pathIsFile(path),name=FileUtils.getBaseName(path),self=this;return doCreate(path,isFolder).done(function(entry){isFolder||self.selectInWorkingSet(entry.fullPath)}).fail(function(error){self.trigger(ERROR_CREATION,{type:error,name:name,isFolder:isFolder})})},ProjectModel.prototype.startCreating=function(basedir,newName,isFolder){this.performRename();var d=new $.Deferred,self=this;return this.setDirectoryOpen(basedir,!0).then(function(){self._viewModel.createPlaceholder(self.makeProjectRelativeIfPossible(basedir),newName,isFolder);var promise=self.startRename(basedir+newName);self._selections.rename.type=1,isFolder&&(self._selections.rename.isFolder=isFolder),promise.then(d.resolve).fail(d.reject)}).fail(function(err){d.reject(err)}),d.promise()},ProjectModel.prototype._cancelCreating=function(){var renameInfo=this._selections.rename;renameInfo&&1===renameInfo.type&&(this._viewModel.deleteAtPath(this.makeProjectRelativeIfPossible(renameInfo.path)),renameInfo.deferred.resolve(2),delete this._selections.rename,this.setContext(null))},ProjectModel.prototype.setSortDirectoriesFirst=function(sortDirectoriesFirst){this._viewModel.setSortDirectoriesFirst(sortDirectoriesFirst)},ProjectModel.prototype.getOpenNodes=function(){return this._viewModel.getOpenNodes(this.projectRoot.fullPath)},ProjectModel.prototype.reopenNodes=function(nodesByDepth){var deferred=new $.Deferred;if(!nodesByDepth||0===nodesByDepth.length)return deferred.resolve().promise();var self=this;return Async.doSequentially(nodesByDepth,function(toOpenPaths){return Async.doInParallel(toOpenPaths,function(path){return self._getDirectoryContents(path).then(function(contents){var relative=self.makeProjectRelativeIfPossible(path);self._viewModel.setDirectoryContents(relative,contents),self._viewModel.setDirectoryOpen(relative,!0)})},!1)})},ProjectModel.prototype.refresh=function(){var projectRoot=this.projectRoot,openNodes=this.getOpenNodes(),self=this,selections=this._selections,viewModel=this._viewModel,deferred=new $.Deferred;return this.setProjectRoot(projectRoot).then(function(){self.reopenNodes(openNodes).then(function(){selections.selected&&viewModel.moveMarker("selected",null,self.makeProjectRelativeIfPossible(selections.selected)),selections.context&&viewModel.moveMarker("context",null,self.makeProjectRelativeIfPossible(selections.context)),selections.rename&&viewModel.moveMarker("rename",null,self.makeProjectRelativeIfPossible(selections.rename)),deferred.resolve()})}),deferred.promise()},ProjectModel.prototype.handleFSEvent=function(entry,added,removed){if(this._resetCache(),entry){if(this.isWithinProject(entry)){var changes={},self=this;if(entry.isFile)changes.changed=[this.makeProjectRelativeIfPossible(entry.fullPath)];else if(!added&&!removed)return void entry.getContents(function(err,contents){err?console.error("Unexpected error refreshing file tree for directory "+entry.fullPath+": "+err,err.stack):self._viewModel.setDirectoryContents(self.makeProjectRelativeIfPossible(entry.fullPath),contents)});added&&(changes.added=added.filter(function(entry){return _shouldShowName(entry.name)}).map(function(entry){return self.makeProjectRelativeIfPossible(entry.fullPath)})),removed&&(this._selections.selected&&_.find(removed,{fullPath:this._selections.selected})&&this.setSelected(null),this._selections.rename&&_.find(removed,{fullPath:this._selections.rename.path})&&this.cancelRename(),this._selections.context&&_.find(removed,{fullPath:this._selections.context})&&this.setContext(null),changes.removed=removed.map(function(entry){return self.makeProjectRelativeIfPossible(entry.fullPath)})),this._viewModel.processChanges(changes)}}else this.refresh()},ProjectModel.prototype.closeSubtree=function(path){this._viewModel.closeSubtree(this.makeProjectRelativeIfPossible(path))},ProjectModel.prototype.toggleSubdirectories=function(path,openOrClose){var self=this,d=new $.Deferred;return this.setDirectoryOpen(path,!0).then(function(){var projectRelativePath=self.makeProjectRelativeIfPossible(path),childNodes=self._viewModel.getChildDirectories(projectRelativePath);Async.doInParallel(childNodes,function(node){return self.setDirectoryOpen(path+node,openOrClose)},!0).then(function(){d.resolve()},function(err){d.reject(err)})}),d.promise()},exports._addWelcomeProjectPath=_addWelcomeProjectPath,exports._isWelcomeProjectPath=_isWelcomeProjectPath,exports._ensureTrailingSlash=_ensureTrailingSlash,exports._shouldShowName=_shouldShowName,exports._invalidChars='? * | : / < > \\ | " ..',exports.shouldShow=shouldShow,exports.shouldIndex=shouldIndex,exports.defaultIgnoreGlobs=defaultIgnoreGlobs,exports.isValidFilename=isValidFilename,exports.isValidPath=isValidPath,exports.EVENT_CHANGE=EVENT_CHANGE,exports.EVENT_SHOULD_SELECT="select",exports.EVENT_SHOULD_FOCUS="focus",exports.EVENT_FS_RENAME_STARTED="mvStart",exports.EVENT_FS_RENAME_END="mvEnd",exports.ERROR_CREATION=ERROR_CREATION,exports.ERROR_INVALID_FILENAME=ERROR_INVALID_FILENAME,exports.ERROR_NOT_IN_PROJECT="notInProject",exports.FILE_RENAMING=0,exports.FILE_CREATING=1,exports.RENAME_CANCELLED=2,exports.doCreate=doCreate,exports.ProjectModel=ProjectModel});