mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-09 10:28:32 +00:00
Speed up IDE startup time.
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
@@ -13,7 +13,7 @@ import {
|
||||
} from '@theia/core/lib/browser/tree';
|
||||
import { SketchbookCommands } from './sketchbook-commands';
|
||||
import { OpenerService, open } from '@theia/core/lib/browser';
|
||||
import { SketchesServiceClientImpl } from '../../../common/protocol/sketches-service-client-impl';
|
||||
import { CurrentSketch, SketchesServiceClientImpl } from '../../../common/protocol/sketches-service-client-impl';
|
||||
import { CommandRegistry } from '@theia/core/lib/common/command';
|
||||
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
|
||||
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
||||
@@ -28,7 +28,7 @@ import { Disposable } from '@theia/core/lib/common/disposable';
|
||||
@injectable()
|
||||
export class SketchbookTreeModel extends FileTreeModel {
|
||||
@inject(FileService)
|
||||
protected readonly fileService: FileService;
|
||||
protected override readonly fileService: FileService;
|
||||
|
||||
@inject(ArduinoPreferences)
|
||||
protected readonly arduinoPreferences: ArduinoPreferences;
|
||||
@@ -45,7 +45,7 @@ export class SketchbookTreeModel extends FileTreeModel {
|
||||
@inject(SketchesServiceClientImpl)
|
||||
protected readonly sketchServiceClient: SketchesServiceClientImpl;
|
||||
|
||||
@inject(SketchbookTree) protected readonly tree: SketchbookTree;
|
||||
@inject(SketchbookTree) protected override readonly tree: SketchbookTree;
|
||||
@inject(WorkspaceService)
|
||||
protected readonly workspaceService: WorkspaceService;
|
||||
@inject(FrontendApplicationStateService)
|
||||
@@ -55,7 +55,7 @@ export class SketchbookTreeModel extends FileTreeModel {
|
||||
protected readonly progressService: ProgressService;
|
||||
|
||||
@postConstruct()
|
||||
protected init(): void {
|
||||
protected override init(): void {
|
||||
super.init();
|
||||
this.reportBusyProgress();
|
||||
this.initializeRoot();
|
||||
@@ -143,7 +143,7 @@ export class SketchbookTreeModel extends FileTreeModel {
|
||||
}
|
||||
}
|
||||
|
||||
*getNodesByUri(uri: URI): IterableIterator<TreeNode> {
|
||||
override *getNodesByUri(uri: URI): IterableIterator<TreeNode> {
|
||||
const workspace = this.root;
|
||||
if (WorkspaceNode.is(workspace)) {
|
||||
for (const root of workspace.children) {
|
||||
@@ -183,7 +183,7 @@ export class SketchbookTreeModel extends FileTreeModel {
|
||||
/**
|
||||
* Move the given source file or directory to the given target directory.
|
||||
*/
|
||||
async move(source: TreeNode, target: TreeNode): Promise<URI | undefined> {
|
||||
override async move(source: TreeNode, target: TreeNode): Promise<URI | undefined> {
|
||||
if (source.parent && WorkspaceRootNode.is(source)) {
|
||||
// do not support moving a root folder
|
||||
return undefined;
|
||||
@@ -250,7 +250,7 @@ export class SketchbookTreeModel extends FileTreeModel {
|
||||
|
||||
// selectNode gets called when the user single-clicks on an item
|
||||
// when this happens, we want to open the file if it belongs to the currently open sketch
|
||||
async selectNode(node: Readonly<SelectableTreeNode>): Promise<void> {
|
||||
override async selectNode(node: Readonly<SelectableTreeNode>): Promise<void> {
|
||||
super.selectNode(node);
|
||||
if (FileNode.is(node) && (await this.isFileInsideCurrentSketch(node))) {
|
||||
this.open(node.uri);
|
||||
@@ -264,7 +264,7 @@ export class SketchbookTreeModel extends FileTreeModel {
|
||||
});
|
||||
}
|
||||
|
||||
protected async doOpenNode(node: TreeNode): Promise<void> {
|
||||
protected override async doOpenNode(node: TreeNode): Promise<void> {
|
||||
// if it's a sketch dir, or a file from another sketch, open in new window
|
||||
if (!(await this.isFileInsideCurrentSketch(node))) {
|
||||
const sketchRoot = this.recursivelyFindSketchRoot(node);
|
||||
@@ -294,7 +294,10 @@ export class SketchbookTreeModel extends FileTreeModel {
|
||||
|
||||
// check if the node is a file that belongs to another sketch
|
||||
const sketch = await this.sketchServiceClient.currentSketch();
|
||||
if (sketch && node.uri.toString().indexOf(sketch.uri) !== 0) {
|
||||
if (
|
||||
CurrentSketch.isValid(sketch) &&
|
||||
node.uri.toString().indexOf(sketch.uri) !== 0
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -14,7 +14,10 @@ import { ContextMenuRenderer } from '@theia/core/lib/browser/context-menu-render
|
||||
import { SketchbookTree } from './sketchbook-tree';
|
||||
import { SketchbookTreeModel } from './sketchbook-tree-model';
|
||||
import { ArduinoPreferences } from '../../arduino-preferences';
|
||||
import { SketchesServiceClientImpl } from '../../../common/protocol/sketches-service-client-impl';
|
||||
import {
|
||||
CurrentSketch,
|
||||
SketchesServiceClientImpl,
|
||||
} from '../../../common/protocol/sketches-service-client-impl';
|
||||
import { SelectableTreeNode } from '@theia/core/lib/browser/tree/tree-selection';
|
||||
import { Sketch } from '../../contributions/contribution';
|
||||
import { nls } from '@theia/core/lib/common';
|
||||
@@ -33,10 +36,10 @@ export class SketchbookTreeWidget extends FileTreeWidget {
|
||||
protected currentSketchUri = '';
|
||||
|
||||
constructor(
|
||||
@inject(TreeProps) readonly props: TreeProps,
|
||||
@inject(SketchbookTreeModel) readonly model: SketchbookTreeModel,
|
||||
@inject(TreeProps) override readonly props: TreeProps,
|
||||
@inject(SketchbookTreeModel) override readonly model: SketchbookTreeModel,
|
||||
@inject(ContextMenuRenderer)
|
||||
readonly contextMenuRenderer: ContextMenuRenderer,
|
||||
override readonly contextMenuRenderer: ContextMenuRenderer,
|
||||
@inject(EditorManager) readonly editorManager: EditorManager
|
||||
) {
|
||||
super(props, model, contextMenuRenderer);
|
||||
@@ -50,14 +53,14 @@ export class SketchbookTreeWidget extends FileTreeWidget {
|
||||
}
|
||||
|
||||
@postConstruct()
|
||||
protected async init(): Promise<void> {
|
||||
protected override async init(): Promise<void> {
|
||||
super.init();
|
||||
// cache the current open sketch uri
|
||||
const currentSketch = await this.sketchServiceClient.currentSketch();
|
||||
this.currentSketchUri = (currentSketch && currentSketch.uri) || '';
|
||||
this.currentSketchUri = (CurrentSketch.isValid(currentSketch) && currentSketch.uri) || '';
|
||||
}
|
||||
|
||||
protected createNodeClassNames(node: TreeNode, props: NodeProps): string[] {
|
||||
protected override createNodeClassNames(node: TreeNode, props: NodeProps): string[] {
|
||||
const classNames = super.createNodeClassNames(node, props);
|
||||
|
||||
if (
|
||||
@@ -70,7 +73,7 @@ export class SketchbookTreeWidget extends FileTreeWidget {
|
||||
return classNames;
|
||||
}
|
||||
|
||||
protected renderIcon(node: TreeNode, props: NodeProps): React.ReactNode {
|
||||
protected override renderIcon(node: TreeNode, props: NodeProps): React.ReactNode {
|
||||
if (SketchbookTree.SketchDirNode.is(node) || Sketch.isSketchFile(node.id)) {
|
||||
return <div className="sketch-folder-icon file-icon"></div>;
|
||||
}
|
||||
@@ -81,7 +84,7 @@ export class SketchbookTreeWidget extends FileTreeWidget {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
protected renderTailDecorations(
|
||||
protected override renderTailDecorations(
|
||||
node: TreeNode,
|
||||
props: NodeProps
|
||||
): React.ReactNode {
|
||||
@@ -99,7 +102,7 @@ export class SketchbookTreeWidget extends FileTreeWidget {
|
||||
this.update();
|
||||
}
|
||||
|
||||
protected createNodeAttributes(
|
||||
protected override createNodeAttributes(
|
||||
node: TreeNode,
|
||||
props: NodeProps
|
||||
): React.Attributes & React.HTMLAttributes<HTMLElement> {
|
||||
@@ -160,7 +163,7 @@ export class SketchbookTreeWidget extends FileTreeWidget {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
protected handleClickEvent(
|
||||
protected override handleClickEvent(
|
||||
node: TreeNode | undefined,
|
||||
event: React.MouseEvent<HTMLElement>
|
||||
): void {
|
||||
@@ -186,7 +189,7 @@ export class SketchbookTreeWidget extends FileTreeWidget {
|
||||
}
|
||||
}
|
||||
|
||||
protected doToggle(event: React.MouseEvent<HTMLElement>): void {
|
||||
protected override doToggle(event: React.MouseEvent<HTMLElement>): void {
|
||||
const nodeId = event.currentTarget.getAttribute('data-node-id');
|
||||
if (nodeId) {
|
||||
const node = this.model.getNode(nodeId);
|
||||
|
||||
@@ -18,7 +18,7 @@ export class SketchbookTree extends FileNavigatorTree {
|
||||
@inject(ArduinoPreferences)
|
||||
protected readonly arduinoPreferences: ArduinoPreferences;
|
||||
|
||||
async resolveChildren(parent: CompositeTreeNode): Promise<TreeNode[]> {
|
||||
override async resolveChildren(parent: CompositeTreeNode): Promise<TreeNode[]> {
|
||||
const showAllFiles =
|
||||
this.arduinoPreferences['arduino.sketchbook.showAllFiles'];
|
||||
|
||||
|
||||
@@ -23,7 +23,10 @@ import {
|
||||
Disposable,
|
||||
DisposableCollection,
|
||||
} from '@theia/core/lib/common/disposable';
|
||||
import { SketchesServiceClientImpl } from '../../../common/protocol/sketches-service-client-impl';
|
||||
import {
|
||||
CurrentSketch,
|
||||
SketchesServiceClientImpl,
|
||||
} from '../../../common/protocol/sketches-service-client-impl';
|
||||
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
||||
import { URI } from '../../contributions/contribution';
|
||||
|
||||
@@ -95,7 +98,7 @@ export class SketchbookWidgetContribution
|
||||
return this.openView() as Promise<any>;
|
||||
}
|
||||
|
||||
registerCommands(registry: CommandRegistry): void {
|
||||
override registerCommands(registry: CommandRegistry): void {
|
||||
super.registerCommands(registry);
|
||||
|
||||
registry.registerCommand(SketchbookCommands.OPEN_NEW_WINDOW, {
|
||||
@@ -142,7 +145,10 @@ export class SketchbookWidgetContribution
|
||||
// disable the "open sketch" command for the current sketch.
|
||||
// otherwise make the command clickable
|
||||
const currentSketch = await this.sketchServiceClient.currentSketch();
|
||||
if (currentSketch && currentSketch.uri === arg.node.uri.toString()) {
|
||||
if (
|
||||
CurrentSketch.isValid(currentSketch) &&
|
||||
currentSketch.uri === arg.node.uri.toString()
|
||||
) {
|
||||
const placeholder = new PlaceholderMenuNode(
|
||||
SKETCHBOOK__CONTEXT__MAIN_GROUP,
|
||||
SketchbookCommands.OPEN_NEW_WINDOW.label!
|
||||
@@ -186,7 +192,7 @@ export class SketchbookWidgetContribution
|
||||
});
|
||||
}
|
||||
|
||||
registerMenus(registry: MenuModelRegistry): void {
|
||||
override registerMenus(registry: MenuModelRegistry): void {
|
||||
super.registerMenus(registry);
|
||||
|
||||
// unregister main menu action
|
||||
|
||||
@@ -33,7 +33,7 @@ export class SketchbookWidget extends BaseWidget {
|
||||
this.sketchbookTreesContainer.addWidget(this.localSketchbookTreeWidget);
|
||||
}
|
||||
|
||||
protected onAfterAttach(message: Message): void {
|
||||
protected override onAfterAttach(message: Message): void {
|
||||
super.onAfterAttach(message);
|
||||
Widget.attach(this.sketchbookTreesContainer, this.node);
|
||||
this.toDisposeOnDetach.push(
|
||||
@@ -45,7 +45,7 @@ export class SketchbookWidget extends BaseWidget {
|
||||
return this.localSketchbookTreeWidget;
|
||||
}
|
||||
|
||||
protected onActivateRequest(message: Message): void {
|
||||
protected override onActivateRequest(message: Message): void {
|
||||
super.onActivateRequest(message);
|
||||
|
||||
// TODO: focus the active sketchbook
|
||||
@@ -56,7 +56,7 @@ export class SketchbookWidget extends BaseWidget {
|
||||
this.node.focus();
|
||||
}
|
||||
|
||||
protected onResize(message: Widget.ResizeMessage): void {
|
||||
protected override onResize(message: Widget.ResizeMessage): void {
|
||||
super.onResize(message);
|
||||
MessageLoop.sendMessage(
|
||||
this.sketchbookTreesContainer,
|
||||
@@ -67,7 +67,7 @@ export class SketchbookWidget extends BaseWidget {
|
||||
}
|
||||
}
|
||||
|
||||
protected onAfterShow(msg: Message): void {
|
||||
protected override onAfterShow(msg: Message): void {
|
||||
super.onAfterShow(msg);
|
||||
this.onResize(Widget.ResizeMessage.UnknownSize);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user