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 */ | 8 */ |
9 WebInspector.ExecutionContextSelector = function() | 9 WebInspector.ExecutionContextSelector = function() |
10 { | 10 { |
11 WebInspector.targetManager.observeTargets(this); | 11 WebInspector.targetManager.observeTargets(this); |
12 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext,
this._executionContextChanged, this); | 12 WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext,
this._executionContextChanged, this); |
13 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._targ
etChanged, this); | 13 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._targ
etChanged, this); |
| 14 |
| 15 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn
spector.RuntimeModel.Events.ExecutionContextCreated, this._onExecutionContextCre
ated, this); |
| 16 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn
spector.RuntimeModel.Events.ExecutionContextDestroyed, this._onExecutionContextD
estroyed, this); |
14 } | 17 } |
15 | 18 |
16 WebInspector.ExecutionContextSelector.prototype = { | 19 WebInspector.ExecutionContextSelector.prototype = { |
17 | 20 |
18 /** | 21 /** |
19 * @param {!WebInspector.Target} target | 22 * @param {!WebInspector.Target} target |
20 */ | 23 */ |
21 targetAdded: function(target) | 24 targetAdded: function(target) |
22 { | 25 { |
23 if (!WebInspector.context.flavor(WebInspector.Target)) | 26 if (!WebInspector.context.flavor(WebInspector.Target)) |
24 WebInspector.context.setFlavor(WebInspector.Target, target); | 27 WebInspector.context.setFlavor(WebInspector.Target, target); |
25 | |
26 target.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.Ex
ecutionContextCreated, this._onExecutionContextCreated, this); | |
27 target.runtimeModel.addEventListener(WebInspector.RuntimeModel.Events.Ex
ecutionContextDestroyed, this._onExecutionContextDestroyed, this); | |
28 }, | 28 }, |
29 | 29 |
30 /** | 30 /** |
31 * @param {!WebInspector.Target} target | 31 * @param {!WebInspector.Target} target |
32 */ | 32 */ |
33 targetRemoved: function(target) | 33 targetRemoved: function(target) |
34 { | 34 { |
35 target.runtimeModel.removeEventListener(WebInspector.RuntimeModel.Events
.ExecutionContextCreated, this._onExecutionContextCreated, this); | |
36 target.runtimeModel.removeEventListener(WebInspector.RuntimeModel.Events
.ExecutionContextDestroyed, this._onExecutionContextDestroyed, this); | |
37 var currentExecutionContext = WebInspector.context.flavor(WebInspector.E
xecutionContext); | 35 var currentExecutionContext = WebInspector.context.flavor(WebInspector.E
xecutionContext); |
38 if (currentExecutionContext && currentExecutionContext.target() === targ
et) | 36 if (currentExecutionContext && currentExecutionContext.target() === targ
et) |
39 this._currentExecutionContextGone(); | 37 this._currentExecutionContextGone(); |
40 | 38 |
41 var targets = WebInspector.targetManager.targets(); | 39 var targets = WebInspector.targetManager.targets(); |
42 if (WebInspector.context.flavor(WebInspector.Target) === target && targe
ts.length) | 40 if (WebInspector.context.flavor(WebInspector.Target) === target && targe
ts.length) |
43 WebInspector.context.setFlavor(WebInspector.Target, targets[0]); | 41 WebInspector.context.setFlavor(WebInspector.Target, targets[0]); |
44 }, | 42 }, |
45 | 43 |
46 /** | 44 /** |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 completionsReadyCallback([]); | 123 completionsReadyCallback([]); |
126 return; | 124 return; |
127 } | 125 } |
128 | 126 |
129 // Pass less stop characters to rangeOfWord so the range will be a more comp
lete expression. | 127 // Pass less stop characters to rangeOfWord so the range will be a more comp
lete expression. |
130 var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOf
fset, " =:[({;,!+-*/&|^<>", proxyElement, "backward"); | 128 var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOf
fset, " =:[({;,!+-*/&|^<>", proxyElement, "backward"); |
131 var expressionString = expressionRange.toString(); | 129 var expressionString = expressionRange.toString(); |
132 var prefix = wordRange.toString(); | 130 var prefix = wordRange.toString(); |
133 executionContext.completionsForExpression(expressionString, prefix, force, c
ompletionsReadyCallback); | 131 executionContext.completionsForExpression(expressionString, prefix, force, c
ompletionsReadyCallback); |
134 } | 132 } |
OLD | NEW |