UNPKG

4.62 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 WITH Classpath-exception-2.0
16// *****************************************************************************
17var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21 return c > 3 && r && Object.defineProperty(target, key, r), r;
22};
23var __metadata = (this && this.__metadata) || function (k, v) {
24 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25};
26var QuickHelpService_1;
27Object.defineProperty(exports, "__esModule", { value: true });
28exports.QuickHelpService = void 0;
29const inversify_1 = require("inversify");
30const quick_access_1 = require("./quick-access");
31const quick_input_service_1 = require("./quick-input-service");
32let QuickHelpService = QuickHelpService_1 = class QuickHelpService {
33 getPicks(filter, token) {
34 const { editorProviders, globalProviders } = this.getQuickAccessProviders();
35 const result = editorProviders.length === 0 || globalProviders.length === 0 ?
36 // Without groups
37 [
38 ...(editorProviders.length === 0 ? globalProviders : editorProviders)
39 ] :
40 // With groups
41 [
42 { type: 'separator', label: 'global commands' },
43 ...globalProviders,
44 { type: 'separator', label: 'editor commands' },
45 ...editorProviders
46 ];
47 return result;
48 }
49 getQuickAccessProviders() {
50 const globalProviders = [];
51 const editorProviders = [];
52 const providers = this.quickAccessRegistry.getQuickAccessProviders();
53 for (const provider of providers.sort((providerA, providerB) => providerA.prefix.localeCompare(providerB.prefix))) {
54 if (provider.prefix === QuickHelpService_1.PREFIX) {
55 continue; // exclude help which is already active
56 }
57 for (const helpEntry of provider.helpEntries) {
58 const prefix = helpEntry.prefix || provider.prefix;
59 const label = prefix || '\u2026' /* ... */;
60 (helpEntry.needsEditor ? editorProviders : globalProviders).push({
61 label,
62 ariaLabel: `${label}, ${helpEntry.description}`,
63 description: helpEntry.description,
64 execute: () => this.quickInputService.open(prefix)
65 });
66 }
67 }
68 return { editorProviders, globalProviders };
69 }
70 registerQuickAccessProvider() {
71 this.quickAccessRegistry.registerQuickAccessProvider({
72 getInstance: () => this,
73 prefix: QuickHelpService_1.PREFIX,
74 placeholder: 'Type "?" to get help on the actions you can take from here.',
75 helpEntries: [{ description: 'Show all Quick Access Providers', needsEditor: false }]
76 });
77 }
78};
79QuickHelpService.PREFIX = '?';
80__decorate([
81 (0, inversify_1.inject)(quick_access_1.QuickAccessRegistry),
82 __metadata("design:type", Object)
83], QuickHelpService.prototype, "quickAccessRegistry", void 0);
84__decorate([
85 (0, inversify_1.inject)(quick_input_service_1.QuickInputService),
86 __metadata("design:type", Object)
87], QuickHelpService.prototype, "quickInputService", void 0);
88QuickHelpService = QuickHelpService_1 = __decorate([
89 (0, inversify_1.injectable)()
90], QuickHelpService);
91exports.QuickHelpService = QuickHelpService;
92//# sourceMappingURL=quick-help-service.js.map
\No newline at end of file