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

Side by Side 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 unified diff | Download patch
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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 WebInspector.ConsolePrompt = class extends WebInspector.Widget { 7 WebInspector.ConsolePrompt = class extends WebInspector.Widget {
8 constructor() { 8 constructor() {
9 super(); 9 super();
10 this._addCompletionsFromHistory = true; 10 this._addCompletionsFromHistory = true;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (' =:[({;,!+-*/&|^<>.'.indexOf(lineText.charAt(index)) !== -1) 245 if (' =:[({;,!+-*/&|^<>.'.indexOf(lineText.charAt(index)) !== -1)
246 break; 246 break;
247 } 247 }
248 return new WebInspector.TextRange(lineNumber, index + 1, lineNumber, columnN umber); 248 return new WebInspector.TextRange(lineNumber, index + 1, lineNumber, columnN umber);
249 } 249 }
250 250
251 /** 251 /**
252 * @param {!WebInspector.TextRange} queryRange 252 * @param {!WebInspector.TextRange} queryRange
253 * @param {!WebInspector.TextRange} substituteRange 253 * @param {!WebInspector.TextRange} substituteRange
254 * @param {boolean=} force 254 * @param {boolean=} force
255 * @param {string=} currentTokenType
255 * @return {!Promise<!WebInspector.SuggestBox.Suggestions>} 256 * @return {!Promise<!WebInspector.SuggestBox.Suggestions>}
256 */ 257 */
257 _wordsWithQuery(queryRange, substituteRange, force) { 258 _wordsWithQuery(queryRange, substituteRange, force, currentTokenType) {
258 var query = this._editor.text(queryRange); 259 var query = this._editor.text(queryRange);
259 var before = this._editor.text(new WebInspector.TextRange(0, 0, queryRange.s tartLine, queryRange.startColumn)); 260 var before = this._editor.text(new WebInspector.TextRange(0, 0, queryRange.s tartLine, queryRange.startColumn));
260 var historyWords = this._historyCompletions(query, force); 261 var historyWords = this._historyCompletions(query, force);
262
263 var excludedTokens = new Set(['js-comment', 'js-string-2']);
264 if (!before.endsWith('['))
265 excludedTokens.add('js-string');
266 if (excludedTokens.has(currentTokenType))
267 return Promise.resolve(historyWords);
268
261 return WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContex t(before, query, force) 269 return WebInspector.JavaScriptAutocomplete.completionsForTextInCurrentContex t(before, query, force)
262 .then(innerWordsWithQuery); 270 .then(innerWordsWithQuery);
263 /** 271 /**
264 * @param {!Array<string>} words 272 * @param {!Array<string>} words
265 * @return {!WebInspector.SuggestBox.Suggestions} 273 * @return {!WebInspector.SuggestBox.Suggestions}
266 */ 274 */
267 function innerWordsWithQuery(words) { 275 function innerWordsWithQuery(words) {
268 return words.map(item => ({title: item})).concat(historyWords); 276 return words.map(item => ({title: item})).concat(historyWords);
269 } 277 }
270 } 278 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return this._currentHistoryItem(); 363 return this._currentHistoryItem();
356 } 364 }
357 365
358 /** 366 /**
359 * @return {string|undefined} 367 * @return {string|undefined}
360 */ 368 */
361 _currentHistoryItem() { 369 _currentHistoryItem() {
362 return this._data[this._data.length - this._historyOffset]; 370 return this._data[this._data.length - this._historyOffset];
363 } 371 }
364 }; 372 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698