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"); |
lushnikov
2016/07/20 23:37:54
did you test this new apostrophe?
einbinder
2016/07/22 23:26:46
Done.
| |
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 for (var i = expressionString.length - 1; i >= 0; i--) { |
lushnikov
2016/07/20 23:37:54
1. let's extract "i" outside of the loop and name
einbinder
2016/07/22 23:26:46
Done.
| |
212 if (pos !== -1) | 212 switch (expressionString.charAt(i)) { |
lushnikov
2016/07/20 23:37:54
converting this into if statement would be easier
einbinder
2016/07/22 23:26:45
Done.
| |
213 expressionString = expressionString.substr(pos + 1); | 213 case "]": |
214 bracketCount++; | |
215 break; | |
216 case "[": | |
217 // Allow an open bracket at the end for property completion | |
lushnikov
2016/07/20 23:37:54
nit: comments should finish with "."
einbinder
2016/07/22 23:26:45
Done.
| |
218 if (i < expressionString.length - 1) | |
219 bracketCount--; | |
220 break; | |
221 } | |
222 if (bracketCount < 0) | |
223 break; | |
224 } | |
225 expressionString = expressionString.substr(i + 1); | |
214 | 226 |
215 var prefix = wordRange.toString(); | 227 var prefix = wordRange.toString(); |
216 executionContext.completionsForExpression(expressionString, text, cursorOffs et, prefix, force, completionsReadyCallback); | 228 executionContext.completionsForExpression(expressionString, text, cursorOffs et, prefix, force, completionsReadyCallback); |
217 } | 229 } |
OLD | NEW |