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.JavaScriptOutlineDialog = class extends UI.FilteredListWidget.Delegate { | 10 Sources.JavaScriptOutlineDialog = class extends QuickOpen.FilteredListWidget.Del
egate { |
11 /** | 11 /** |
12 * @param {!Workspace.UISourceCode} uiSourceCode | 12 * @param {!Workspace.UISourceCode} uiSourceCode |
13 * @param {function(number, number)} selectItemCallback | 13 * @param {function(number, number)} selectItemCallback |
14 */ | 14 */ |
15 constructor(uiSourceCode, selectItemCallback) { | 15 constructor(uiSourceCode, selectItemCallback) { |
16 super([]); | 16 super([]); |
17 | 17 |
18 this._functionItems = []; | 18 this._functionItems = []; |
19 this._selectItemCallback = selectItemCallback; | 19 this._selectItemCallback = selectItemCallback; |
20 Common.formatterWorkerPool.javaScriptOutline(uiSourceCode.workingCopy(), thi
s._didBuildOutlineChunk.bind(this)); | 20 Common.formatterWorkerPool.javaScriptOutline(uiSourceCode.workingCopy(), thi
s._didBuildOutlineChunk.bind(this)); |
21 } | 21 } |
22 | 22 |
23 /** | 23 /** |
24 * @param {!Workspace.UISourceCode} uiSourceCode | 24 * @param {!Workspace.UISourceCode} uiSourceCode |
25 * @param {function(number, number)} selectItemCallback | 25 * @param {function(number, number)} selectItemCallback |
26 */ | 26 */ |
27 static show(uiSourceCode, selectItemCallback) { | 27 static show(uiSourceCode, selectItemCallback) { |
28 Sources.JavaScriptOutlineDialog._instanceForTests = | 28 Sources.JavaScriptOutlineDialog._instanceForTests = |
29 new Sources.JavaScriptOutlineDialog(uiSourceCode, selectItemCallback); | 29 new Sources.JavaScriptOutlineDialog(uiSourceCode, selectItemCallback); |
30 new UI.FilteredListWidget(Sources.JavaScriptOutlineDialog._instanceForTests)
.showAsDialog(); | 30 new QuickOpen.FilteredListWidget(Sources.JavaScriptOutlineDialog._instanceFo
rTests).showAsDialog(); |
31 } | 31 } |
32 | 32 |
33 /** | 33 /** |
34 * @param {boolean} isLastChunk | 34 * @param {boolean} isLastChunk |
35 * @param {!Array<!Common.FormatterWorkerPool.JSOutlineItem>} items | 35 * @param {!Array<!Common.FormatterWorkerPool.JSOutlineItem>} items |
36 */ | 36 */ |
37 _didBuildOutlineChunk(isLastChunk, items) { | 37 _didBuildOutlineChunk(isLastChunk, items) { |
38 this._functionItems.push(...items); | 38 this._functionItems.push(...items); |
39 this.refresh(); | 39 this.refresh(); |
40 } | 40 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 * @param {string} promptValue | 91 * @param {string} promptValue |
92 */ | 92 */ |
93 selectItem(itemIndex, promptValue) { | 93 selectItem(itemIndex, promptValue) { |
94 if (itemIndex === null) | 94 if (itemIndex === null) |
95 return; | 95 return; |
96 var lineNumber = this._functionItems[itemIndex].line; | 96 var lineNumber = this._functionItems[itemIndex].line; |
97 if (!isNaN(lineNumber) && lineNumber >= 0) | 97 if (!isNaN(lineNumber) && lineNumber >= 0) |
98 this._selectItemCallback(lineNumber, this._functionItems[itemIndex].column
); | 98 this._selectItemCallback(lineNumber, this._functionItems[itemIndex].column
); |
99 } | 99 } |
100 }; | 100 }; |
OLD | NEW |