@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
80 lines • 3.65 kB
JavaScript
// *****************************************************************************
// Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************
var QuickHelpService_1;
import { __decorate } from "tslib";
import { inject, injectable } from 'inversify';
import { QuickAccessRegistry } from './quick-access.js';
import { QuickInputService } from './quick-input-service.js';
let QuickHelpService = class QuickHelpService {
static { QuickHelpService_1 = this; }
static { this.PREFIX = '?'; }
getPicks(filter, token) {
const { editorProviders, globalProviders } = this.getQuickAccessProviders();
const result = editorProviders.length === 0 || globalProviders.length === 0 ?
// Without groups
[
...(editorProviders.length === 0 ? globalProviders : editorProviders)
] :
// With groups
[
{ type: 'separator', label: 'global commands' },
...globalProviders,
{ type: 'separator', label: 'editor commands' },
...editorProviders
];
return result;
}
getQuickAccessProviders() {
const globalProviders = [];
const editorProviders = [];
const providers = this.quickAccessRegistry.getQuickAccessProviders();
for (const provider of providers.sort((providerA, providerB) => providerA.prefix.localeCompare(providerB.prefix))) {
if (provider.prefix === QuickHelpService_1.PREFIX) {
continue; // exclude help which is already active
}
for (const helpEntry of provider.helpEntries) {
const prefix = helpEntry.prefix || provider.prefix;
const label = prefix || '\u2026'; // ...
(helpEntry.needsEditor ? editorProviders : globalProviders).push({
label,
ariaLabel: `${label}, ${helpEntry.description}`,
description: helpEntry.description,
execute: () => this.quickInputService.open(prefix)
});
}
}
return { editorProviders, globalProviders };
}
registerQuickAccessProvider() {
this.quickAccessRegistry.registerQuickAccessProvider({
getInstance: () => this,
prefix: QuickHelpService_1.PREFIX,
placeholder: 'Type "?" to get help on the actions you can take from here.',
helpEntries: [{ description: 'Show all Quick Access Providers', needsEditor: false }]
});
}
};
__decorate([
inject(QuickAccessRegistry)
], QuickHelpService.prototype, "quickAccessRegistry", void 0);
__decorate([
inject(QuickInputService)
], QuickHelpService.prototype, "quickInputService", void 0);
QuickHelpService = QuickHelpService_1 = __decorate([
injectable()
], QuickHelpService);
export { QuickHelpService };
//# sourceMappingURL=quick-help-service.js.map