| // Copyright 2017 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.SnippetsPlugin = 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 Snippets.isSnippetsUISourceCode(uiSourceCode); |
| } |
| |
| /** |
| * @override |
| * @return {!Array<!UI.ToolbarItem>} |
| */ |
| rightToolbarItems() { |
| const runSnippet = UI.Toolbar.createActionButtonForId('debugger.run-snippet'); |
| runSnippet.setText(Host.isMac() ? Common.UIString('\u2318+Enter') : Common.UIString('Ctrl+Enter')); |
| |
| return [runSnippet]; |
| } |
| }; |