mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-13 06:16:33 +00:00
fix: filtered undesired contributions: RTOS view
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
parent
d0e383853f
commit
5695fd8afb
@ -111,6 +111,8 @@ import { IsTempSketch } from './is-temp-sketch';
|
|||||||
import { rebindNsfwFileSystemWatcher } from './theia/filesystem/nsfw-watcher/nsfw-bindings';
|
import { rebindNsfwFileSystemWatcher } from './theia/filesystem/nsfw-watcher/nsfw-bindings';
|
||||||
import { MessagingContribution } from './theia/core/messaging-contribution';
|
import { MessagingContribution } from './theia/core/messaging-contribution';
|
||||||
import { MessagingService } from '@theia/core/lib/node/messaging/messaging-service';
|
import { MessagingService } from '@theia/core/lib/node/messaging/messaging-service';
|
||||||
|
import { HostedPluginReader } from './theia/plugin-ext/plugin-reader';
|
||||||
|
import { HostedPluginReader as TheiaHostedPluginReader } from '@theia/plugin-ext/lib/hosted/node/plugin-reader';
|
||||||
|
|
||||||
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
||||||
bind(BackendApplication).toSelf().inSingletonScope();
|
bind(BackendApplication).toSelf().inSingletonScope();
|
||||||
@ -384,6 +386,12 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|||||||
rebind(MessagingService.Identifier)
|
rebind(MessagingService.Identifier)
|
||||||
.to(MessagingContribution)
|
.to(MessagingContribution)
|
||||||
.inSingletonScope();
|
.inSingletonScope();
|
||||||
|
|
||||||
|
// Removed undesired contributions from VS Code extensions
|
||||||
|
// Such as the RTOS view from the `cortex-debug` extension
|
||||||
|
// https://github.com/arduino/arduino-ide/pull/1706#pullrequestreview-1195595080
|
||||||
|
bind(HostedPluginReader).toSelf().inSingletonScope();
|
||||||
|
rebind(TheiaHostedPluginReader).toService(HostedPluginReader);
|
||||||
});
|
});
|
||||||
|
|
||||||
function bindChildLogger(bind: interfaces.Bind, name: string): void {
|
function bindChildLogger(bind: interfaces.Bind, name: string): void {
|
||||||
|
@ -0,0 +1,80 @@
|
|||||||
|
import { injectable } from '@theia/core/shared/inversify';
|
||||||
|
import type {
|
||||||
|
PluginContribution,
|
||||||
|
PluginPackage,
|
||||||
|
} from '@theia/plugin-ext/lib/common/plugin-protocol';
|
||||||
|
import { HostedPluginReader as TheiaHostedPluginReader } from '@theia/plugin-ext/lib/hosted/node/plugin-reader';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class HostedPluginReader extends TheiaHostedPluginReader {
|
||||||
|
override readContribution(
|
||||||
|
plugin: PluginPackage
|
||||||
|
): PluginContribution | undefined {
|
||||||
|
const scanner = this.scanner.getScanner(plugin);
|
||||||
|
const contributions = scanner.getContribution(plugin);
|
||||||
|
return this.filterContribution(plugin.name, contributions);
|
||||||
|
}
|
||||||
|
private filterContribution(
|
||||||
|
pluginName: string,
|
||||||
|
contributions: PluginContribution | undefined
|
||||||
|
): PluginContribution | undefined {
|
||||||
|
if (!contributions) {
|
||||||
|
return contributions;
|
||||||
|
}
|
||||||
|
const filter = pluginFilters.get(pluginName);
|
||||||
|
return filter ? filter(contributions) : contributions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type PluginContributionFilter = (
|
||||||
|
contribution: PluginContribution
|
||||||
|
) => PluginContribution | undefined;
|
||||||
|
const cortexDebugFilter: PluginContributionFilter = (
|
||||||
|
contribution: PluginContribution
|
||||||
|
) => {
|
||||||
|
if (contribution.viewsContainers) {
|
||||||
|
for (const location of Object.keys(contribution.viewsContainers)) {
|
||||||
|
const viewContainers = contribution.viewsContainers[location];
|
||||||
|
for (let i = 0; i < viewContainers.length; i++) {
|
||||||
|
const viewContainer = viewContainers[i];
|
||||||
|
if (
|
||||||
|
viewContainer.id === 'cortex-debug' &&
|
||||||
|
viewContainer.title === 'RTOS'
|
||||||
|
) {
|
||||||
|
viewContainers.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (contribution.views) {
|
||||||
|
for (const location of Object.keys(contribution.views)) {
|
||||||
|
if (location === 'cortex-debug') {
|
||||||
|
const views = contribution.views[location];
|
||||||
|
for (let i = 0; i < views.length; i++) {
|
||||||
|
const view = views[i];
|
||||||
|
if (view.id === 'cortex-debug.rtos') {
|
||||||
|
views.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (contribution.menus) {
|
||||||
|
for (const location of Object.keys(contribution.menus)) {
|
||||||
|
if (location === 'commandPalette') {
|
||||||
|
const menus = contribution.menus[location];
|
||||||
|
for (let i = 0; i < menus.length; i++) {
|
||||||
|
const menu = menus[i];
|
||||||
|
if (menu.command === 'cortex-debug.rtos.toggleRTOSPanel') {
|
||||||
|
menu.when = 'false';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return contribution;
|
||||||
|
};
|
||||||
|
|
||||||
|
const pluginFilters = new Map<string, PluginContributionFilter>([
|
||||||
|
['cortex-debug', cortexDebugFilter],
|
||||||
|
]);
|
Loading…
x
Reference in New Issue
Block a user