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