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

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

Issue 2639703002: DevTools: Console: Provide autocompletions for Maps (Closed)
Patch Set: Created 3 years, 11 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
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 Console.ConsolePrompt = class extends UI.Widget { 7 Console.ConsolePrompt = class extends UI.Widget {
8 constructor() { 8 constructor() {
9 super(); 9 super();
10 this._addCompletionsFromHistory = true; 10 this._addCompletionsFromHistory = true;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 * @param {boolean=} force 256 * @param {boolean=} force
257 * @param {string=} currentTokenType 257 * @param {string=} currentTokenType
258 * @return {!Promise<!UI.SuggestBox.Suggestions>} 258 * @return {!Promise<!UI.SuggestBox.Suggestions>}
259 */ 259 */
260 _wordsWithQuery(queryRange, substituteRange, force, currentTokenType) { 260 _wordsWithQuery(queryRange, substituteRange, force, currentTokenType) {
261 var query = this._editor.text(queryRange); 261 var query = this._editor.text(queryRange);
262 var before = this._editor.text(new Common.TextRange(0, 0, queryRange.startLi ne, queryRange.startColumn)); 262 var before = this._editor.text(new Common.TextRange(0, 0, queryRange.startLi ne, queryRange.startColumn));
263 var historyWords = this._historyCompletions(query, force); 263 var historyWords = this._historyCompletions(query, force);
264 264
265 var excludedTokens = new Set(['js-comment', 'js-string-2']); 265 var excludedTokens = new Set(['js-comment', 'js-string-2']);
266 if (!before.endsWith('[')) 266 if (!before.match(/\[\s*$/) && !before.match(/\.\s*[gs]et\s*\(\s*$/))
267 excludedTokens.add('js-string'); 267 excludedTokens.add('js-string');
268 if (excludedTokens.has(currentTokenType)) 268 if (excludedTokens.has(currentTokenType))
269 return Promise.resolve(historyWords); 269 return Promise.resolve(historyWords);
270 270
271 return Components.JavaScriptAutocomplete.completionsForTextInCurrentContext( before, query, force) 271 return Components.JavaScriptAutocomplete.completionsForTextInCurrentContext( before, query, force)
272 .then(words => words.concat(historyWords)); 272 .then(words => words.concat(historyWords));
273 } 273 }
274 274
275 _editorSetForTest() { 275 _editorSetForTest() {
276 } 276 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 return this._currentHistoryItem(); 358 return this._currentHistoryItem();
359 } 359 }
360 360
361 /** 361 /**
362 * @return {string|undefined} 362 * @return {string|undefined}
363 */ 363 */
364 _currentHistoryItem() { 364 _currentHistoryItem() {
365 return this._data[this._data.length - this._historyOffset]; 365 return this._data[this._data.length - this._historyOffset];
366 } 366 }
367 }; 367 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698