| OLD | NEW |
| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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', 'js-def']); | 265 var excludedTokens = new Set(['js-comment', 'js-string-2', 'js-def']); |
| 266 var trimmedBefore = before.trim(); | 266 var trimmedBefore = before.trim(); |
| 267 if (!trimmedBefore.endsWith('[') && !trimmedBefore.match(/\.\s*(get|set|dele
te)\s*\(\s*$/)) | 267 if (!trimmedBefore.endsWith('[')) |
| 268 excludedTokens.add('js-string'); | 268 excludedTokens.add('js-string'); |
| 269 if (!trimmedBefore.endsWith('.')) | 269 if (!trimmedBefore.endsWith('.')) |
| 270 excludedTokens.add('js-property'); | 270 excludedTokens.add('js-property'); |
| 271 if (excludedTokens.has(currentTokenType)) | 271 if (excludedTokens.has(currentTokenType)) |
| 272 return Promise.resolve(historyWords); | 272 return Promise.resolve(historyWords); |
| 273 | 273 |
| 274 return Components.JavaScriptAutocomplete.completionsForTextInCurrentContext(
before, query, force) | 274 return Components.JavaScriptAutocomplete.completionsForTextInCurrentContext(
before, query, force) |
| 275 .then(words => words.concat(historyWords)); | 275 .then(words => words.concat(historyWords)); |
| 276 } | 276 } |
| 277 | 277 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 return this._currentHistoryItem(); | 361 return this._currentHistoryItem(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 /** | 364 /** |
| 365 * @return {string|undefined} | 365 * @return {string|undefined} |
| 366 */ | 366 */ |
| 367 _currentHistoryItem() { | 367 _currentHistoryItem() { |
| 368 return this._data[this._data.length - this._historyOffset]; | 368 return this._data[this._data.length - this._historyOffset]; |
| 369 } | 369 } |
| 370 }; | 370 }; |
| OLD | NEW |