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 ObjectUI.JavaScriptAutocomplete = {}; | 5 ObjectUI.JavaScriptAutocomplete = {}; |
6 | 6 |
7 /** @typedef {{title:(string|undefined), items:Array<string>}} */ | 7 /** @typedef {{title:(string|undefined), items:Array<string>}} */ |
8 ObjectUI.JavaScriptAutocomplete.CompletionGroup; | 8 ObjectUI.JavaScriptAutocomplete.CompletionGroup; |
9 | 9 |
10 /** | 10 /** |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 */ | 63 */ |
64 ObjectUI.JavaScriptAutocomplete._mapCompletions = function(text, query) { | 64 ObjectUI.JavaScriptAutocomplete._mapCompletions = function(text, query) { |
65 var mapMatch = text.match(/\.\s*(get|set|delete)\s*\(\s*$/); | 65 var mapMatch = text.match(/\.\s*(get|set|delete)\s*\(\s*$/); |
66 var executionContext = UI.context.flavor(SDK.ExecutionContext); | 66 var executionContext = UI.context.flavor(SDK.ExecutionContext); |
67 if (!executionContext || !mapMatch) | 67 if (!executionContext || !mapMatch) |
68 return Promise.resolve([]); | 68 return Promise.resolve([]); |
69 | 69 |
70 var clippedExpression = ObjectUI.JavaScriptAutocomplete._clipExpression(text.s
ubstring(0, mapMatch.index)); | 70 var clippedExpression = ObjectUI.JavaScriptAutocomplete._clipExpression(text.s
ubstring(0, mapMatch.index)); |
71 var fulfill; | 71 var fulfill; |
72 var promise = new Promise(x => fulfill = x); | 72 var promise = new Promise(x => fulfill = x); |
73 executionContext.evaluate(clippedExpression || 'this', 'completion', true, tru
e, false, false, false, evaluated); | 73 executionContext.evaluate(clippedExpression, 'completion', true, true, false,
false, false, evaluated); |
74 return promise; | 74 return promise; |
75 | 75 |
76 /** | 76 /** |
77 * @param {?SDK.RemoteObject} result | 77 * @param {?SDK.RemoteObject} result |
78 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails | 78 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails |
79 */ | 79 */ |
80 function evaluated(result, exceptionDetails) { | 80 function evaluated(result, exceptionDetails) { |
81 if (!result || !!exceptionDetails || result.subtype !== 'map') { | 81 if (!result || !!exceptionDetails || result.subtype !== 'map') { |
82 fulfill([]); | 82 fulfill([]); |
83 return; | 83 return; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 if (!query && !expressionString && !force) | 184 if (!query && !expressionString && !force) |
185 return Promise.resolve([]); | 185 return Promise.resolve([]); |
186 | 186 |
187 var fulfill; | 187 var fulfill; |
188 var promise = new Promise(x => fulfill = x); | 188 var promise = new Promise(x => fulfill = x); |
189 var selectedFrame = executionContext.debuggerModel.selectedCallFrame(); | 189 var selectedFrame = executionContext.debuggerModel.selectedCallFrame(); |
190 if (!expressionString && selectedFrame) | 190 if (!expressionString && selectedFrame) |
191 variableNamesInScopes(selectedFrame, receivedPropertyNames); | 191 variableNamesInScopes(selectedFrame, receivedPropertyNames); |
192 else | 192 else |
193 executionContext.evaluate(expressionString || 'this', 'completion', true, tr
ue, false, false, false, evaluated); | 193 executionContext.evaluate(expressionString, 'completion', true, true, false,
false, false, evaluated); |
194 | 194 |
195 return promise; | 195 return promise; |
196 /** | 196 /** |
197 * @param {?SDK.RemoteObject} result | 197 * @param {?SDK.RemoteObject} result |
198 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails | 198 * @param {!Protocol.Runtime.ExceptionDetails=} exceptionDetails |
199 */ | 199 */ |
200 function evaluated(result, exceptionDetails) { | 200 function evaluated(result, exceptionDetails) { |
201 if (!result || !!exceptionDetails) { | 201 if (!result || !!exceptionDetails) { |
202 fulfill([]); | 202 fulfill([]); |
203 return; | 203 return; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 function itemComparator(naturalOrder, a, b) { | 460 function itemComparator(naturalOrder, a, b) { |
461 var aStartsWithUnderscore = a.startsWith('_'); | 461 var aStartsWithUnderscore = a.startsWith('_'); |
462 var bStartsWithUnderscore = b.startsWith('_'); | 462 var bStartsWithUnderscore = b.startsWith('_'); |
463 if (aStartsWithUnderscore && !bStartsWithUnderscore) | 463 if (aStartsWithUnderscore && !bStartsWithUnderscore) |
464 return 1; | 464 return 1; |
465 if (bStartsWithUnderscore && !aStartsWithUnderscore) | 465 if (bStartsWithUnderscore && !aStartsWithUnderscore) |
466 return -1; | 466 return -1; |
467 return naturalOrder ? String.naturalOrderComparator(a, b) : a.localeCompare(
b); | 467 return naturalOrder ? String.naturalOrderComparator(a, b) : a.localeCompare(
b); |
468 } | 468 } |
469 }; | 469 }; |
OLD | NEW |