mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-02 18:11:04 +08:00
R=lushnikov@chromium.org Bug: chromium:646849 Change-Id: I8141bcdcfef7d9734ee9f1c97bfa552160fdcd9d Reviewed-on: https://chromium-review.googlesource.com/1182865 Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org> Reviewed-by: Andrey Lushnikov <lushnikov@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#586149} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: cc09ed9dfa66c1c27020fafe36c07601b947d2ad
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
Sources.ScriptOriginPlugin = class extends Sources.UISourceCodeFrame.Plugin {
|
|
/**
|
|
* @param {!SourceFrame.SourcesTextEditor} textEditor
|
|
* @param {!Workspace.UISourceCode} uiSourceCode
|
|
*/
|
|
constructor(textEditor, uiSourceCode) {
|
|
super();
|
|
this._textEditor = textEditor;
|
|
this._uiSourceCode = uiSourceCode;
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @param {!Workspace.UISourceCode} uiSourceCode
|
|
* @return {boolean}
|
|
*/
|
|
static accepts(uiSourceCode) {
|
|
return !!Sources.ScriptOriginPlugin._script(uiSourceCode);
|
|
}
|
|
|
|
/**
|
|
* @override
|
|
* @return {!Array<!UI.ToolbarItem>}
|
|
*/
|
|
rightToolbarItems() {
|
|
const script = Sources.ScriptOriginPlugin._script(this._uiSourceCode);
|
|
if (!script || !script.originStackTrace)
|
|
return [];
|
|
const link = Sources.ScriptOriginPlugin._linkifier.linkifyStackTraceTopFrame(
|
|
script.debuggerModel.target(), script.originStackTrace);
|
|
return [new UI.ToolbarItem(link)];
|
|
}
|
|
|
|
/**
|
|
* @param {!Workspace.UISourceCode} uiSourceCode
|
|
* @return {?SDK.Script}
|
|
*/
|
|
static _script(uiSourceCode) {
|
|
const locations = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode, 0, 0);
|
|
for (const location of locations) {
|
|
const script = location.script();
|
|
if (script.originStackTrace)
|
|
return script;
|
|
}
|
|
return null;
|
|
}
|
|
};
|
|
|
|
Sources.ScriptOriginPlugin._linkifier = new Components.Linkifier(); |