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

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

Issue 2480423002: DevTools: Use CodeMirror syntax highlighting to improve JS autocomplete (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | third_party/WebKit/Source/devtools/front_end/console/ConsolePrompt.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 WebInspector.JavaScriptAutocomplete = {}; 5 WebInspector.JavaScriptAutocomplete = {};
6 6
7 /** 7 /**
8 * @param {!Element} proxyElement 8 * @param {!Element} proxyElement
9 * @param {!Range} wordRange 9 * @param {!Range} wordRange
10 * @param {boolean} force 10 * @param {boolean} force
11 * @param {function(!Array.<string>, number=)} completionsReadyCallback 11 * @param {function(!Array.<string>, number=)} completionsReadyCallback
12 */ 12 */
13 WebInspector.JavaScriptAutocomplete.completionsForTextPromptInCurrentContext = f unction(proxyElement, wordRange, force, completionsReadyCallback) { 13 WebInspector.JavaScriptAutocomplete.completionsForTextPromptInCurrentContext = f unction(proxyElement, wordRange, force, completionsReadyCallback) {
14 var expressionRange = wordRange.cloneRange(); 14 var expressionRange = wordRange.cloneRange();
15 expressionRange.collapse(true); 15 expressionRange.collapse(true);
16 expressionRange.setStartBefore(proxyElement); 16 expressionRange.setStartBefore(proxyElement);
17 WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext(express ionRange.toString(), wordRange.toString(), force) 17 WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext(express ionRange.toString(), wordRange.toString(), force)
18 .then(completionsReadyCallback); 18 .then(completionsReadyCallback);
19 }; 19 };
20 20
21 /** 21 /**
22 * @param {string} text 22 * @param {string} text
23 * @param {string} query 23 * @param {string} query
24 * @param {boolean=} force 24 * @param {boolean=} force
25 * @param {string=} tokenType
25 * @return {!Promise<!Array<string>>} 26 * @return {!Promise<!Array<string>>}
26 */ 27 */
27 WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext = functio n(text, query, force) { 28 WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext = functio n(text, query, force, tokenType) {
29 var excludedTokens = new Set(['js-comment', 'js-string-2']);
30 if (!text.endsWith('['))
einbinder 2016/11/07 23:04:48 If the user is typing window["docu then we want to
31 excludedTokens.add('js-string');
32 if (excludedTokens.has(tokenType))
33 return Promise.resolve([]);
34
28 var index; 35 var index;
29 var stopChars = new Set(' =:({;,!+-*/&|^<>`'.split('')); 36 var stopChars = new Set(' =:({;,!+-*/&|^<>`'.split(''));
30 for (index = text.length - 1; index >= 0; index--) { 37 for (index = text.length - 1; index >= 0; index--) {
31 // Pass less stop characters to rangeOfWord so the range will be a more comp lete expression. 38 // Pass less stop characters to rangeOfWord so the range will be a more comp lete expression.
32 if (stopChars.has(text.charAt(index))) 39 if (stopChars.has(text.charAt(index)))
33 break; 40 break;
34 } 41 }
35 var clippedExpression = text.substring(index + 1); 42 var clippedExpression = text.substring(index + 1);
36 var bracketCount = 0; 43 var bracketCount = 0;
37 44
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 caseSensitivePrefix.push(prop); 290 caseSensitivePrefix.push(prop);
284 else if (property.toLowerCase().startsWith(query.toLowerCase())) 291 else if (property.toLowerCase().startsWith(query.toLowerCase()))
285 caseInsensitivePrefix.push(prop); 292 caseInsensitivePrefix.push(prop);
286 else if (property.indexOf(query) !== -1) 293 else if (property.indexOf(query) !== -1)
287 caseSensitiveAnywhere.push(prop); 294 caseSensitiveAnywhere.push(prop);
288 else 295 else
289 caseInsensitiveAnywhere.push(prop); 296 caseInsensitiveAnywhere.push(prop);
290 } 297 }
291 return caseSensitivePrefix.concat(caseInsensitivePrefix).concat(caseSensitiveA nywhere).concat(caseInsensitiveAnywhere); 298 return caseSensitivePrefix.concat(caseInsensitivePrefix).concat(caseSensitiveA nywhere).concat(caseInsensitiveAnywhere);
292 }; 299 };
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/console/ConsolePrompt.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698