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

Unified Diff: third_party/WebKit/Source/devtools/front_end/console/ConsolePrompt.js

Issue 2480423002: DevTools: Use CodeMirror syntax highlighting to improve JS autocomplete (Closed)
Patch Set: CurrentTokenType 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/console/ConsolePrompt.js
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsolePrompt.js b/third_party/WebKit/Source/devtools/front_end/console/ConsolePrompt.js
index 53ca7697a7eaa70e3af665785bb5232989db3721..65d93e967c174cf8c197a2792da32eb39c216897 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsolePrompt.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsolePrompt.js
@@ -252,12 +252,20 @@ WebInspector.ConsolePrompt = class extends WebInspector.Widget {
* @param {!WebInspector.TextRange} queryRange
* @param {!WebInspector.TextRange} substituteRange
* @param {boolean=} force
+ * @param {string=} currentTokenType
* @return {!Promise<!WebInspector.SuggestBox.Suggestions>}
*/
- _wordsWithQuery(queryRange, substituteRange, force) {
+ _wordsWithQuery(queryRange, substituteRange, force, currentTokenType) {
var query = this._editor.text(queryRange);
var before = this._editor.text(new WebInspector.TextRange(0, 0, queryRange.startLine, queryRange.startColumn));
var historyWords = this._historyCompletions(query, force);
+
+ var excludedTokens = new Set(['js-comment', 'js-string-2']);
+ if (!before.endsWith('['))
+ excludedTokens.add('js-string');
+ if (excludedTokens.has(currentTokenType))
+ return Promise.resolve(historyWords);
+
return WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContext(before, query, force)
.then(innerWordsWithQuery);
/**

Powered by Google App Engine
This is Rietveld 408576698