OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @implements {WebInspector.TargetManager.Observer} | 7 * @implements {WebInspector.TargetManager.Observer} |
8 * @param {!WebInspector.TargetManager} targetManager | 8 * @param {!WebInspector.TargetManager} targetManager |
9 * @param {!WebInspector.Context} context | 9 * @param {!WebInspector.Context} context |
10 */ | 10 */ |
11 WebInspector.ExecutionContextSelector = function(targetManager, context) | 11 WebInspector.ExecutionContextSelector = function(targetManager, context) |
12 { | 12 { |
13 targetManager.observeTargets(this, WebInspector.Target.Capability.JS); | 13 targetManager.observeTargets(this, WebInspector.Target.Capability.JS); |
14 context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executi
onContextChanged, this); | 14 context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executi
onContextChanged, this); |
15 context.addFlavorChangeListener(WebInspector.Target, this._targetChanged, th
is); | 15 context.addFlavorChangeListener(WebInspector.Target, this._targetChanged, th
is); |
16 | 16 |
17 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti
meModel.Events.ExecutionContextCreated, this._onExecutionContextCreated, this); | 17 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti
meModel.Events.ExecutionContextCreated, this._onExecutionContextCreated, this); |
18 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti
meModel.Events.ExecutionContextDestroyed, this._onExecutionContextDestroyed, thi
s); | 18 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti
meModel.Events.ExecutionContextDestroyed, this._onExecutionContextDestroyed, thi
s); |
19 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti
meModel.Events.ExecutionContextOrderChanged, this._onExecutionContextOrderChange
d, this); | 19 targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.Runti
meModel.Events.ExecutionContextOrderChanged, this._onExecutionContextOrderChange
d, this); |
20 this._targetManager = targetManager; | 20 this._targetManager = targetManager; |
21 this._context = context; | 21 this._context = context; |
22 } | 22 }; |
23 | 23 |
24 WebInspector.ExecutionContextSelector.prototype = { | 24 WebInspector.ExecutionContextSelector.prototype = { |
25 | 25 |
26 /** | 26 /** |
27 * @override | 27 * @override |
28 * @param {!WebInspector.Target} target | 28 * @param {!WebInspector.Target} target |
29 */ | 29 */ |
30 targetAdded: function(target) | 30 targetAdded: function(target) |
31 { | 31 { |
32 // Defer selecting default target since we need all clients to get their | 32 // Defer selecting default target since we need all clients to get their |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (executionContexts.length) { | 205 if (executionContexts.length) { |
206 newContext = executionContexts[0]; | 206 newContext = executionContexts[0]; |
207 break; | 207 break; |
208 } | 208 } |
209 } | 209 } |
210 } | 210 } |
211 this._ignoreContextChanged = true; | 211 this._ignoreContextChanged = true; |
212 this._context.setFlavor(WebInspector.ExecutionContext, newContext); | 212 this._context.setFlavor(WebInspector.ExecutionContext, newContext); |
213 this._ignoreContextChanged = false; | 213 this._ignoreContextChanged = false; |
214 } | 214 } |
215 } | 215 }; |
216 | 216 |
217 /** | 217 /** |
218 * @param {!Element} proxyElement | 218 * @param {!Element} proxyElement |
219 * @param {!Range} wordRange | 219 * @param {!Range} wordRange |
220 * @param {boolean} force | 220 * @param {boolean} force |
221 * @param {function(!Array.<string>, number=)} completionsReadyCallback | 221 * @param {function(!Array.<string>, number=)} completionsReadyCallback |
222 */ | 222 */ |
223 WebInspector.ExecutionContextSelector.completionsForTextPromptInCurrentContext =
function(proxyElement, wordRange, force, completionsReadyCallback) | 223 WebInspector.ExecutionContextSelector.completionsForTextPromptInCurrentContext =
function(proxyElement, wordRange, force, completionsReadyCallback) |
224 { | 224 { |
225 var expressionRange = wordRange.cloneRange(); | 225 var expressionRange = wordRange.cloneRange(); |
226 expressionRange.collapse(true); | 226 expressionRange.collapse(true); |
227 expressionRange.setStartBefore(proxyElement); | 227 expressionRange.setStartBefore(proxyElement); |
228 WebInspector.ExecutionContextSelector.completionsForTextInCurrentContext(exp
ressionRange.toString(), wordRange.toString(), force, completionsReadyCallback); | 228 WebInspector.ExecutionContextSelector.completionsForTextInCurrentContext(exp
ressionRange.toString(), wordRange.toString(), force, completionsReadyCallback); |
229 } | 229 }; |
230 /** | 230 /** |
231 * @param {string} text | 231 * @param {string} text |
232 * @param {string} completionsPrefix | 232 * @param {string} completionsPrefix |
233 * @param {boolean} force | 233 * @param {boolean} force |
234 * @param {function(!Array.<string>, number=)} completionsReadyCallback | 234 * @param {function(!Array.<string>, number=)} completionsReadyCallback |
235 */ | 235 */ |
236 WebInspector.ExecutionContextSelector.completionsForTextInCurrentContext = funct
ion(text, completionsPrefix, force, completionsReadyCallback) | 236 WebInspector.ExecutionContextSelector.completionsForTextInCurrentContext = funct
ion(text, completionsPrefix, force, completionsReadyCallback) |
237 { | 237 { |
238 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionCon
text); | 238 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionCon
text); |
239 if (!executionContext) { | 239 if (!executionContext) { |
(...skipping 19 matching lines...) Expand all Loading... |
259 if (character === "[" && index < clippedExpression.length - 1) { | 259 if (character === "[" && index < clippedExpression.length - 1) { |
260 bracketCount--; | 260 bracketCount--; |
261 if (bracketCount < 0) | 261 if (bracketCount < 0) |
262 break; | 262 break; |
263 } | 263 } |
264 index--; | 264 index--; |
265 } | 265 } |
266 clippedExpression = clippedExpression.substring(index + 1); | 266 clippedExpression = clippedExpression.substring(index + 1); |
267 | 267 |
268 executionContext.completionsForExpression(clippedExpression, completionsPref
ix, force, completionsReadyCallback); | 268 executionContext.completionsForExpression(clippedExpression, completionsPref
ix, force, completionsReadyCallback); |
269 } | 269 }; |
OLD | NEW |