UNPKG

3.98 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16// *****************************************************************************
17var QuickHelpService_1;
18Object.defineProperty(exports, "__esModule", { value: true });
19exports.QuickHelpService = void 0;
20const tslib_1 = require("tslib");
21const inversify_1 = require("inversify");
22const quick_access_1 = require("./quick-access");
23const quick_input_service_1 = require("./quick-input-service");
24let QuickHelpService = QuickHelpService_1 = class QuickHelpService {
25 getPicks(filter, token) {
26 const { editorProviders, globalProviders } = this.getQuickAccessProviders();
27 const result = editorProviders.length === 0 || globalProviders.length === 0 ?
28 // Without groups
29 [
30 ...(editorProviders.length === 0 ? globalProviders : editorProviders)
31 ] :
32 // With groups
33 [
34 { type: 'separator', label: 'global commands' },
35 ...globalProviders,
36 { type: 'separator', label: 'editor commands' },
37 ...editorProviders
38 ];
39 return result;
40 }
41 getQuickAccessProviders() {
42 const globalProviders = [];
43 const editorProviders = [];
44 const providers = this.quickAccessRegistry.getQuickAccessProviders();
45 for (const provider of providers.sort((providerA, providerB) => providerA.prefix.localeCompare(providerB.prefix))) {
46 if (provider.prefix === QuickHelpService_1.PREFIX) {
47 continue; // exclude help which is already active
48 }
49 for (const helpEntry of provider.helpEntries) {
50 const prefix = helpEntry.prefix || provider.prefix;
51 const label = prefix || '\u2026' /* ... */;
52 (helpEntry.needsEditor ? editorProviders : globalProviders).push({
53 label,
54 ariaLabel: `${label}, ${helpEntry.description}`,
55 description: helpEntry.description,
56 execute: () => this.quickInputService.open(prefix)
57 });
58 }
59 }
60 return { editorProviders, globalProviders };
61 }
62 registerQuickAccessProvider() {
63 this.quickAccessRegistry.registerQuickAccessProvider({
64 getInstance: () => this,
65 prefix: QuickHelpService_1.PREFIX,
66 placeholder: 'Type "?" to get help on the actions you can take from here.',
67 helpEntries: [{ description: 'Show all Quick Access Providers', needsEditor: false }]
68 });
69 }
70};
71QuickHelpService.PREFIX = '?';
72(0, tslib_1.__decorate)([
73 (0, inversify_1.inject)(quick_access_1.QuickAccessRegistry),
74 (0, tslib_1.__metadata)("design:type", Object)
75], QuickHelpService.prototype, "quickAccessRegistry", void 0);
76(0, tslib_1.__decorate)([
77 (0, inversify_1.inject)(quick_input_service_1.QuickInputService),
78 (0, tslib_1.__metadata)("design:type", Object)
79], QuickHelpService.prototype, "quickInputService", void 0);
80QuickHelpService = QuickHelpService_1 = (0, tslib_1.__decorate)([
81 (0, inversify_1.injectable)()
82], QuickHelpService);
83exports.QuickHelpService = QuickHelpService;
84//# sourceMappingURL=quick-help-service.js.map
\No newline at end of file