OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 28 matching lines...) Expand all Loading... |
39 * @param {!DOMFileSystem} domFileSystem | 39 * @param {!DOMFileSystem} domFileSystem |
40 */ | 40 */ |
41 constructor(manager, path, embedderPath, domFileSystem) { | 41 constructor(manager, path, embedderPath, domFileSystem) { |
42 this._manager = manager; | 42 this._manager = manager; |
43 this._path = path; | 43 this._path = path; |
44 this._embedderPath = embedderPath; | 44 this._embedderPath = embedderPath; |
45 this._domFileSystem = domFileSystem; | 45 this._domFileSystem = domFileSystem; |
46 this._excludedFoldersSetting = Common.settings.createLocalSetting('workspace
ExcludedFolders', {}); | 46 this._excludedFoldersSetting = Common.settings.createLocalSetting('workspace
ExcludedFolders', {}); |
47 /** @type {!Set<string>} */ | 47 /** @type {!Set<string>} */ |
48 this._excludedFolders = new Set(this._excludedFoldersSetting.get()[path] ||
[]); | 48 this._excludedFolders = new Set(this._excludedFoldersSetting.get()[path] ||
[]); |
49 /** @type {!Set<string>} */ | |
50 this._nonConfigurableExcludedFolders = new Set(); | |
51 | 49 |
52 /** @type {!Set<string>} */ | 50 /** @type {!Set<string>} */ |
53 this._initialFilePaths = new Set(); | 51 this._initialFilePaths = new Set(); |
54 /** @type {!Set<string>} */ | 52 /** @type {!Set<string>} */ |
55 this._initialGitFolders = new Set(); | 53 this._initialGitFolders = new Set(); |
56 } | 54 } |
57 | 55 |
58 /** | 56 /** |
59 * @param {!Workspace.IsolatedFileSystemManager} manager | 57 * @param {!Workspace.IsolatedFileSystemManager} manager |
60 * @param {string} path | 58 * @param {string} path |
61 * @param {string} embedderPath | 59 * @param {string} embedderPath |
62 * @param {string} name | 60 * @param {string} name |
63 * @param {string} rootURL | 61 * @param {string} rootURL |
64 * @return {!Promise<?Workspace.IsolatedFileSystem>} | 62 * @return {!Promise<?Workspace.IsolatedFileSystem>} |
65 */ | 63 */ |
66 static create(manager, path, embedderPath, name, rootURL) { | 64 static create(manager, path, embedderPath, name, rootURL) { |
67 var domFileSystem = InspectorFrontendHost.isolatedFileSystem(name, rootURL); | 65 var domFileSystem = InspectorFrontendHost.isolatedFileSystem(name, rootURL); |
68 if (!domFileSystem) | 66 if (!domFileSystem) |
69 return Promise.resolve(/** @type {?Workspace.IsolatedFileSystem} */ (null)
); | 67 return Promise.resolve(/** @type {?Workspace.IsolatedFileSystem} */ (null)
); |
70 | 68 |
71 var fileSystem = new Workspace.IsolatedFileSystem(manager, path, embedderPat
h, domFileSystem); | 69 var fileSystem = new Workspace.IsolatedFileSystem(manager, path, embedderPat
h, domFileSystem); |
72 var fileContentPromise = fileSystem.requestFileContentPromise('.devtools'); | 70 return fileSystem._initializeFilePaths() |
73 return fileContentPromise.then(onConfigAvailable) | |
74 .then(() => fileSystem) | 71 .then(() => fileSystem) |
75 .catchException(/** @type {?Workspace.IsolatedFileSystem} */ (null)); | 72 .catchException(/** @type {?Workspace.IsolatedFileSystem} */ (null)); |
76 | |
77 /** | |
78 * @param {?string} projectText | |
79 * @return {!Promise} | |
80 */ | |
81 function onConfigAvailable(projectText) { | |
82 if (projectText) { | |
83 try { | |
84 var projectObject = JSON.parse(projectText); | |
85 fileSystem._initializeProject( | |
86 typeof projectObject === 'object' ? /** @type {!Object} */ (projec
tObject) : null); | |
87 } catch (e) { | |
88 Common.console.error('Invalid project file: ' + projectText); | |
89 } | |
90 } | |
91 return fileSystem._initializeFilePaths(); | |
92 } | |
93 } | 73 } |
94 | 74 |
95 /** | 75 /** |
96 * @param {!DOMError} error | 76 * @param {!DOMError} error |
97 * @return {string} | 77 * @return {string} |
98 */ | 78 */ |
99 static errorMessage(error) { | 79 static errorMessage(error) { |
100 return Common.UIString('File system error: %s', error.message); | 80 return Common.UIString('File system error: %s', error.message); |
101 } | 81 } |
102 | 82 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 129 } |
150 | 130 |
151 /** | 131 /** |
152 * @return {string} | 132 * @return {string} |
153 */ | 133 */ |
154 embedderPath() { | 134 embedderPath() { |
155 return this._embedderPath; | 135 return this._embedderPath; |
156 } | 136 } |
157 | 137 |
158 /** | 138 /** |
159 * @param {?Object} projectObject | |
160 */ | |
161 _initializeProject(projectObject) { | |
162 this._projectObject = projectObject; | |
163 | |
164 var projectExcludes = this.projectProperty('excludes'); | |
165 if (Array.isArray(projectExcludes)) { | |
166 for (var folder of /** @type {!Array<*>} */ (projectExcludes)) { | |
167 if (typeof folder === 'string') | |
168 this._nonConfigurableExcludedFolders.add(folder); | |
169 } | |
170 } | |
171 } | |
172 | |
173 /** | |
174 * @param {string} key | |
175 * @return {*} | |
176 */ | |
177 projectProperty(key) { | |
178 return this._projectObject ? this._projectObject[key] : null; | |
179 } | |
180 | |
181 /** | |
182 * @return {!Promise} | 139 * @return {!Promise} |
183 */ | 140 */ |
184 _initializeFilePaths() { | 141 _initializeFilePaths() { |
185 var fulfill; | 142 var fulfill; |
186 var promise = new Promise(x => fulfill = x); | 143 var promise = new Promise(x => fulfill = x); |
187 var pendingRequests = 1; | 144 var pendingRequests = 1; |
188 var boundInnerCallback = innerCallback.bind(this); | 145 var boundInnerCallback = innerCallback.bind(this); |
189 this._requestEntries('', boundInnerCallback); | 146 this._requestEntries('', boundInnerCallback); |
190 return promise; | 147 return promise; |
191 | 148 |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 var settingValue = this._excludedFoldersSetting.get(); | 524 var settingValue = this._excludedFoldersSetting.get(); |
568 delete settingValue[this._path]; | 525 delete settingValue[this._path]; |
569 this._excludedFoldersSetting.set(settingValue); | 526 this._excludedFoldersSetting.set(settingValue); |
570 } | 527 } |
571 | 528 |
572 /** | 529 /** |
573 * @param {string} folderPath | 530 * @param {string} folderPath |
574 * @return {boolean} | 531 * @return {boolean} |
575 */ | 532 */ |
576 _isFileExcluded(folderPath) { | 533 _isFileExcluded(folderPath) { |
577 if (this._nonConfigurableExcludedFolders.has(folderPath) || this._excludedFo
lders.has(folderPath)) | 534 if (this._excludedFolders.has(folderPath)) |
578 return true; | 535 return true; |
579 var regex = this._manager.workspaceFolderExcludePatternSetting().asRegExp(); | 536 var regex = this._manager.workspaceFolderExcludePatternSetting().asRegExp(); |
580 return !!(regex && regex.test(folderPath)); | 537 return !!(regex && regex.test(folderPath)); |
581 } | 538 } |
582 | 539 |
583 /** | 540 /** |
584 * @return {!Set<string>} | 541 * @return {!Set<string>} |
585 */ | 542 */ |
586 excludedFolders() { | 543 excludedFolders() { |
587 return this._excludedFolders; | 544 return this._excludedFolders; |
588 } | 545 } |
589 | 546 |
590 /** | 547 /** |
591 * @return {!Set<string>} | |
592 */ | |
593 nonConfigurableExcludedFolders() { | |
594 return this._nonConfigurableExcludedFolders; | |
595 } | |
596 | |
597 /** | |
598 * @param {string} query | 548 * @param {string} query |
599 * @param {!Common.Progress} progress | 549 * @param {!Common.Progress} progress |
600 * @param {function(!Array.<string>)} callback | 550 * @param {function(!Array.<string>)} callback |
601 */ | 551 */ |
602 searchInPath(query, progress, callback) { | 552 searchInPath(query, progress, callback) { |
603 var requestId = this._manager.registerCallback(innerCallback); | 553 var requestId = this._manager.registerCallback(innerCallback); |
604 InspectorFrontendHost.searchInPath(requestId, this._embedderPath, query); | 554 InspectorFrontendHost.searchInPath(requestId, this._embedderPath, query); |
605 | 555 |
606 /** | 556 /** |
607 * @param {!Array.<string>} files | 557 * @param {!Array.<string>} files |
(...skipping 10 matching lines...) Expand all Loading... |
618 */ | 568 */ |
619 indexContent(progress) { | 569 indexContent(progress) { |
620 progress.setTotalWork(1); | 570 progress.setTotalWork(1); |
621 var requestId = this._manager.registerProgress(progress); | 571 var requestId = this._manager.registerProgress(progress); |
622 InspectorFrontendHost.indexPath(requestId, this._embedderPath); | 572 InspectorFrontendHost.indexPath(requestId, this._embedderPath); |
623 } | 573 } |
624 }; | 574 }; |
625 | 575 |
626 Workspace.IsolatedFileSystem.ImageExtensions = | 576 Workspace.IsolatedFileSystem.ImageExtensions = |
627 new Set(['jpeg', 'jpg', 'svg', 'gif', 'webp', 'png', 'ico', 'tiff', 'tif', '
bmp']); | 577 new Set(['jpeg', 'jpg', 'svg', 'gif', 'webp', 'png', 'ico', 'tiff', 'tif', '
bmp']); |
OLD | NEW |