Skip to content

Commit d3d6e89

Browse files
author
Akos Kitta
committed
customized JSON schema store, editor navigation history, and preference tree generator.
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 1fd3e96 commit d3d6e89

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ import {
271271
IDEUpdaterDialogWidget,
272272
} from './dialogs/ide-updater/ide-updater-dialog';
273273
import { ElectronIpcConnectionProvider } from '@theia/core/lib/electron-browser/messaging/electron-ipc-connection-provider';
274+
import { DefaultJsonSchemaContribution } from './theia/core/json-schema-store';
275+
import { DefaultJsonSchemaContribution as TheiaDefaultJsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store';
276+
import { EditorNavigationContribution } from './theia/editor/editor-navigation-contribution';
277+
import { EditorNavigationContribution as TheiaEditorNavigationContribution } from '@theia/editor/lib/browser/editor-navigation-contribution';
278+
import { PreferenceTreeGenerator } from './theia/preferences/preference-tree-generator';
279+
import { PreferenceTreeGenerator as TheiaPreferenceTreeGenerator } from '@theia/preferences/lib/browser/util/preference-tree-generator';
274280

275281
MonacoThemingService.register({
276282
id: 'arduino-theme',
@@ -669,6 +675,21 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
669675
bind(NavigatorTabBarDecorator).toSelf().inSingletonScope();
670676
rebind(TheiaNavigatorTabBarDecorator).toService(NavigatorTabBarDecorator);
671677

678+
// Do not fetch the `catalog.json` from Azure on FE load.
679+
bind(DefaultJsonSchemaContribution).toSelf().inSingletonScope();
680+
rebind(TheiaDefaultJsonSchemaContribution).toService(
681+
DefaultJsonSchemaContribution
682+
);
683+
684+
// Do not block the app startup when initializing the editor navigation history.
685+
bind(EditorNavigationContribution).toSelf().inSingletonScope();
686+
rebind(TheiaEditorNavigationContribution).toService(
687+
EditorNavigationContribution
688+
);
689+
690+
bind(PreferenceTreeGenerator).toSelf().inSingletonScope()
691+
rebind(TheiaPreferenceTreeGenerator).toService(PreferenceTreeGenerator);
692+
672693
// To avoid running `Save All` when there are no dirty editors before starting the debug session.
673694
bind(DebugSessionManager).toSelf().inSingletonScope();
674695
rebind(TheiaDebugSessionManager).toService(DebugSessionManager);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { injectable } from '@theia/core/shared/inversify';
2+
import { DefaultJsonSchemaContribution as TheiaDefaultJsonSchemaContribution } from '@theia/core/lib/browser/json-schema-store';
3+
4+
@injectable()
5+
export class DefaultJsonSchemaContribution extends TheiaDefaultJsonSchemaContribution {
6+
override async registerSchemas(): Promise<void> {
7+
// NOOP
8+
// Do not fetch the https://www.schemastore.org/api/json/catalog.json on every single browser window load.
9+
// If the schemas are required in the future, we should fetch the `catalog.json` on build time and load it.
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { injectable } from '@theia/core/shared/inversify';
2+
import { EditorNavigationContribution as TheiaEditorNavigationContribution } from '@theia/editor/lib/browser/editor-navigation-contribution';
3+
4+
@injectable()
5+
export class EditorNavigationContribution extends TheiaEditorNavigationContribution {
6+
override async onStart(): Promise<void> {
7+
// No await.
8+
// Restore the navigation history asynchronously.
9+
super.onStart();
10+
}
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { CompositeTreeNode } from '@theia/core/lib/browser/tree/tree';
2+
import { injectable } from '@theia/core/shared/inversify';
3+
import { PreferenceTreeGenerator as TheiaPreferenceTreeGenerator } from '@theia/preferences/lib/browser/util/preference-tree-generator';
4+
5+
@injectable()
6+
export class PreferenceTreeGenerator extends TheiaPreferenceTreeGenerator {
7+
protected override async init(): Promise<void> {
8+
// The IDE2 does not use the default Theia preferences UI.
9+
// There is no need to create and keep the the tree model synchronized when there is no UI for it.
10+
}
11+
12+
// Just returns with the empty root.
13+
override generateTree(): CompositeTreeNode {
14+
this._root = this.createRootNode();
15+
return this._root;
16+
}
17+
}

0 commit comments

Comments
 (0)