| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @unrestricted | 8 * @unrestricted |
| 9 */ | 9 */ |
| 10 Sources.FilteredUISourceCodeListProvider = class extends QuickOpen.FilteredListW
idget.Provider { | 10 Sources.FilteredUISourceCodeListProvider = class extends QuickOpen.FilteredListW
idget.Provider { |
| 11 /** | 11 /** |
| 12 * @param {!Map.<!Workspace.UISourceCode, number>=} defaultScores | 12 * @param {?Map.<!Workspace.UISourceCode, number>=} defaultScores |
| 13 */ | 13 */ |
| 14 constructor(defaultScores) { | 14 constructor(defaultScores) { |
| 15 super(); | 15 super(); |
| 16 | 16 |
| 17 this._defaultScores = defaultScores; | 17 this._defaultScores = defaultScores || null; |
| 18 this._scorer = new Sources.FilePathScoreFunction(''); | 18 this._scorer = new Sources.FilePathScoreFunction(''); |
| 19 } | 19 } |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * @param {!Common.Event} event | 22 * @param {!Common.Event} event |
| 23 */ | 23 */ |
| 24 _projectRemoved(event) { | 24 _projectRemoved(event) { |
| 25 var project = /** @type {!Workspace.Project} */ (event.data); | 25 var project = /** @type {!Workspace.Project} */ (event.data); |
| 26 this._populate(project); | 26 this._populate(project); |
| 27 this.refresh(); | 27 this.refresh(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 /** | 80 /** |
| 81 * @override | 81 * @override |
| 82 * @param {number} itemIndex | 82 * @param {number} itemIndex |
| 83 * @return {string} | 83 * @return {string} |
| 84 */ | 84 */ |
| 85 itemKeyAt(itemIndex) { | 85 itemKeyAt(itemIndex) { |
| 86 return this._uiSourceCodes[itemIndex].url(); | 86 return this._uiSourceCodes[itemIndex].url(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * @protected |
| 91 * @param {?Map.<!Workspace.UISourceCode, number>} defaultScores |
| 92 */ |
| 93 setDefaultScores(defaultScores) { |
| 94 this._defaultScores = defaultScores; |
| 95 } |
| 96 |
| 97 /** |
| 90 * @override | 98 * @override |
| 91 * @param {number} itemIndex | 99 * @param {number} itemIndex |
| 92 * @param {string} query | 100 * @param {string} query |
| 93 * @return {number} | 101 * @return {number} |
| 94 */ | 102 */ |
| 95 itemScoreAt(itemIndex, query) { | 103 itemScoreAt(itemIndex, query) { |
| 96 var uiSourceCode = this._uiSourceCodes[itemIndex]; | 104 var uiSourceCode = this._uiSourceCodes[itemIndex]; |
| 97 var score = this._defaultScores ? (this._defaultScores.get(uiSourceCode) ||
0) : 0; | 105 var score = this._defaultScores ? (this._defaultScores.get(uiSourceCode) ||
0) : 0; |
| 98 if (!query || query.length < 2) | 106 if (!query || query.length < 2) |
| 99 return score; | 107 return score; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 228 |
| 221 /** | 229 /** |
| 222 * @override | 230 * @override |
| 223 */ | 231 */ |
| 224 detach() { | 232 detach() { |
| 225 Workspace.workspace.removeEventListener( | 233 Workspace.workspace.removeEventListener( |
| 226 Workspace.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdded, t
his); | 234 Workspace.Workspace.Events.UISourceCodeAdded, this._uiSourceCodeAdded, t
his); |
| 227 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.ProjectRe
moved, this._projectRemoved, this); | 235 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.ProjectRe
moved, this._projectRemoved, this); |
| 228 } | 236 } |
| 229 }; | 237 }; |
| OLD | NEW |