| 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 */ |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 this._ignoreContextChanged = true; | 184 this._ignoreContextChanged = true; |
| 185 this._context.setFlavor(WebInspector.ExecutionContext, newContext); | 185 this._context.setFlavor(WebInspector.ExecutionContext, newContext); |
| 186 this._ignoreContextChanged = false; | 186 this._ignoreContextChanged = false; |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 /** | 190 /** |
| 191 * @param {!Element} proxyElement | 191 * @param {!Element} proxyElement |
| 192 * @param {string} text | |
| 193 * @param {number} cursorOffset | |
| 194 * @param {!Range} wordRange | 192 * @param {!Range} wordRange |
| 195 * @param {boolean} force | 193 * @param {boolean} force |
| 196 * @param {function(!Array.<string>, number=)} completionsReadyCallback | 194 * @param {function(!Array.<string>, number=)} completionsReadyCallback |
| 197 */ | 195 */ |
| 198 WebInspector.ExecutionContextSelector.completionsForTextPromptInCurrentContext =
function(proxyElement, text, cursorOffset, wordRange, force, completionsReadyCa
llback) | 196 WebInspector.ExecutionContextSelector.completionsForTextPromptInCurrentContext =
function(proxyElement, wordRange, force, completionsReadyCallback) |
| 199 { | 197 { |
| 200 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionCon
text); | 198 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionCon
text); |
| 201 if (!executionContext) { | 199 if (!executionContext) { |
| 202 completionsReadyCallback([]); | 200 completionsReadyCallback([]); |
| 203 return; | 201 return; |
| 204 } | 202 } |
| 205 | 203 |
| 206 // Pass less stop characters to rangeOfWord so the range will be a more comp
lete expression. | 204 // Pass less stop characters to rangeOfWord so the range will be a more comp
lete expression. |
| 207 var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOf
fset, " =:({;,!+-*/&|^<>", proxyElement, "backward"); | 205 var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOf
fset, " =:({;,!+-*/&|^<>", proxyElement, "backward"); |
| 208 var expressionString = expressionRange.toString(); | 206 var expressionString = expressionRange.toString(); |
| 209 | 207 |
| 210 // The "[" is also a stop character, except when it's the last character of
the expression. | 208 // The "[" is also a stop character, except when it's the last character of
the expression. |
| 211 var pos = expressionString.lastIndexOf("[", expressionString.length - 2); | 209 var pos = expressionString.lastIndexOf("[", expressionString.length - 2); |
| 212 if (pos !== -1) | 210 if (pos !== -1) |
| 213 expressionString = expressionString.substr(pos + 1); | 211 expressionString = expressionString.substr(pos + 1); |
| 214 | 212 |
| 215 var prefix = wordRange.toString(); | 213 var prefix = wordRange.toString(); |
| 216 executionContext.completionsForExpression(expressionString, text, cursorOffs
et, prefix, force, completionsReadyCallback); | 214 executionContext.completionsForExpression(expressionString, prefix, force, c
ompletionsReadyCallback); |
| 217 } | 215 } |
| OLD | NEW |