Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/ExecutionContextSelector.js

Issue 2163393002: DevTools: Give autocomplete suggestions even after brackets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nicer sequential Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/console/console-correct-suggestions-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698