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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 */ | 195 */ |
196 WebInspector.ExecutionContextSelector.completionsForTextPromptInCurrentContext =
function(proxyElement, wordRange, force, completionsReadyCallback) | 196 WebInspector.ExecutionContextSelector.completionsForTextPromptInCurrentContext =
function(proxyElement, wordRange, force, completionsReadyCallback) |
197 { | 197 { |
198 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionCon
text); | 198 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionCon
text); |
199 if (!executionContext) { | 199 if (!executionContext) { |
200 completionsReadyCallback([]); | 200 completionsReadyCallback([]); |
201 return; | 201 return; |
202 } | 202 } |
203 | 203 |
204 // 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. |
205 var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOf
fset, " =:({;,!+-*/&|^<>", proxyElement, "backward"); | 205 var expressionRange = wordRange.startContainer.rangeOfWord(wordRange.startOf
fset, " =:({;,!+-*/&|^<>`", proxyElement, "backward"); |
206 var expressionString = expressionRange.toString(); | 206 var expressionString = expressionRange.toString(); |
207 | 207 |
208 // The "[" is also a stop character, except when it's the last character of
the expression. | 208 var bracketCount = 0; |
209 var pos = expressionString.lastIndexOf("[", expressionString.length - 2); | 209 var index = expressionString.length - 1; |
210 if (pos !== -1) | 210 while (index >= 0) { |
211 expressionString = expressionString.substr(pos + 1); | 211 var character = expressionString.charAt(index); |
| 212 if (character === "]") |
| 213 bracketCount++; |
| 214 // Allow an open bracket at the end for property completion. |
| 215 if (character === "[" && index < expressionString.length - 1) { |
| 216 bracketCount--; |
| 217 if (bracketCount < 0) |
| 218 break; |
| 219 } |
| 220 index--; |
| 221 } |
| 222 expressionString = expressionString.substring(index + 1); |
212 | 223 |
213 var prefix = wordRange.toString(); | 224 var prefix = wordRange.toString(); |
214 executionContext.completionsForExpression(expressionString, prefix, force, c
ompletionsReadyCallback); | 225 executionContext.completionsForExpression(expressionString, prefix, force, c
ompletionsReadyCallback); |
215 } | 226 } |
OLD | NEW |