From 7bb6041daccc80e2f907ed0bf65a40246de0959f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Z=C3=BCnd?= Date: Thu, 9 Jan 2020 17:36:38 +0100 Subject: [PATCH] Prepare CoverageDecorationManager.js for source map asyncification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL prepares CoverageDecorationManager.js for the upcoming asyncification of {DebuggerWorkspaceBinding.uiLocationToRawLocations}. R=mathias@chromium.org Bug: chromium:1032016 Change-Id: I4b275d535f2f7c9a598ef9e5f5994060f524e2e5 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1991634 Commit-Queue: Simon Zünd Reviewed-by: Mathias Bynens --- front_end/coverage/CoverageDecorationManager.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/front_end/coverage/CoverageDecorationManager.js b/front_end/coverage/CoverageDecorationManager.js index 56bcf45d5b..3fa7cccb34 100644 --- a/front_end/coverage/CoverageDecorationManager.js +++ b/front_end/coverage/CoverageDecorationManager.js @@ -66,8 +66,9 @@ export class CoverageDecorationManager { result.push(undefined); continue; } - const startLocations = this._rawLocationsForSourceLocation(uiSourceCode, line, 0); - const endLocations = this._rawLocationsForSourceLocation(uiSourceCode, line, lineLength); + const startLocationsPromise = this._rawLocationsForSourceLocation(uiSourceCode, line, 0); + const endLocationsPromise = this._rawLocationsForSourceLocation(uiSourceCode, line, lineLength); + const [startLocations, endLocations] = await Promise.all([startLocationsPromise, endLocationsPromise]); let used = undefined; for (let startIndex = 0, endIndex = 0; startIndex < startLocations.length; ++startIndex) { const start = startLocations[startIndex]; @@ -109,10 +110,10 @@ export class CoverageDecorationManager { * @param {!TextUtils.Text} text * @return {!Promise} */ - _updateTexts(uiSourceCode, text) { + async _updateTexts(uiSourceCode, text) { const promises = []; for (let line = 0; line < text.lineCount(); ++line) { - for (const entry of this._rawLocationsForSourceLocation(uiSourceCode, line, 0)) { + for (const entry of await this._rawLocationsForSourceLocation(uiSourceCode, line, 0)) { if (this._textByProvider.has(entry.contentProvider)) { continue; } @@ -137,13 +138,13 @@ export class CoverageDecorationManager { * @param {!Workspace.UISourceCode} uiSourceCode * @param {number} line * @param {number} column - * @return {!Array} + * @return {!Promise>} */ - _rawLocationsForSourceLocation(uiSourceCode, line, column) { + async _rawLocationsForSourceLocation(uiSourceCode, line, column) { const result = []; const contentType = uiSourceCode.contentType(); if (contentType.hasScripts()) { - let locations = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode, line, column); + let locations = await Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode, line, column); locations = locations.filter(location => !!location.script()); for (const location of locations) { const script = location.script();