From f86247664ed225e46548f5e67a036519969fdf99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=A4der?= Date: Wed, 16 Aug 2023 15:31:05 +0200 Subject: [PATCH] Address lint problems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Mäder --- CHANGELOG.md | 2 +- .../core/src/browser/tree/tree-widget.tsx | 5 ++-- packages/core/src/browser/tree/tree.ts | 4 ++-- .../plugin-ext/src/common/plugin-api-rpc.ts | 2 +- .../main/browser/view/tree-view-widget.tsx | 4 ++-- .../src/main/browser/view/tree-views-main.ts | 12 ++++------ .../plugin-ext/src/plugin/tree/tree-views.ts | 15 ++++++++---- packages/plugin-ext/src/plugin/types-impl.ts | 7 ++++-- packages/plugin/src/theia.d.ts | 23 ++++++++----------- 9 files changed, 38 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f821fc0e16a0..33cad2171f03b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/) ## v1.41.0 - - [application-package] Quit Electron app when back end fails to start [#12778](https://github.com/eclipse-theia/theia/pull/12778) - Contributed on behalf of STMicroelectronics. - +- [vscode] added support for tree checkbox api [#12836](https://github.com/eclipse-theia/theia/pull/12836) - Contributed on behalf of STMicroelectronics ## v1.40.0 - 07/27/2023 - [application-package] bumped the default supported VS Code API from `1.78.0` to `1.79.0` [#12764](https://github.com/eclipse-theia/theia/pull/12764) - Contributed on behalf of STMicroelectronics. diff --git a/packages/core/src/browser/tree/tree-widget.tsx b/packages/core/src/browser/tree/tree-widget.tsx index 4b93c4755f26e..f11d828ad84fc 100644 --- a/packages/core/src/browser/tree/tree-widget.tsx +++ b/packages/core/src/browser/tree/tree-widget.tsx @@ -597,11 +597,10 @@ export class TreeWidget extends ReactWidget implements StatefulWidget { aria-label={node.checkboxInfo.accessibilityInformation?.label} role={node.checkboxInfo.accessibilityInformation?.role} className='theia-input' - onClick={event => this.toggleChecked(event)} /> - + onClick={event => this.toggleChecked(event)} />; } - protected toggleChecked(event: React.MouseEvent) { + protected toggleChecked(event: React.MouseEvent): void { const nodeId = event.currentTarget.getAttribute('data-node-id'); if (nodeId) { const node = this.model.getNode(nodeId); diff --git a/packages/core/src/browser/tree/tree.ts b/packages/core/src/browser/tree/tree.ts index 5ef93e9a78529..3e78cab724d47 100644 --- a/packages/core/src/browser/tree/tree.ts +++ b/packages/core/src/browser/tree/tree.ts @@ -136,7 +136,7 @@ export interface TreeNode { readonly busy?: number; /** - * Whether this node is checked. + * Whether this node is checked. */ readonly checkboxInfo?: TreeViewItemCheckboxInfo; } @@ -390,7 +390,7 @@ export class TreeImpl implements Tree { } } - markAsChecked(node: Mutable, checked: boolean) { + markAsChecked(node: Mutable, checked: boolean): void { node.checkboxInfo!.checked = checked; this.onDidUpdateEmitter.fire([node]); } diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index 20e416dba5721..394f38a174da6 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -770,7 +770,7 @@ export class DataTransferFileDTO { } export interface TreeViewsExt { - $checkStateChanged(treeViewId: string, itemIds: { id: string, checked: boolean }[]): unknown; + $checkStateChanged(treeViewId: string, itemIds: { id: string, checked: boolean }[]): Promise; $dragStarted(treeViewId: string, treeItemIds: string[], token: CancellationToken): Promise; $dragEnd(treeViewId: string): Promise; $drop(treeViewId: string, treeItemId: string | undefined, dataTransferItems: [string, string | DataTransferFileDTO][], token: CancellationToken): Promise; diff --git a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx index c6ea2fd16a732..bf71914ebc7b4 100644 --- a/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx +++ b/packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx @@ -302,7 +302,7 @@ export class PluginTree extends TreeImpl { findChildrenToChange(node, nodesToChange); } - nodesToChange.forEach(n => n.checkboxInfo!.checked = checked) + nodesToChange.forEach(n => n.checkboxInfo!.checked = checked); this.onDidUpdateEmitter.fire(nodesToChange); this.proxy?.$checkStateChanged(this.options.id, [{ id: node.id, checked: checked }]); } @@ -532,7 +532,7 @@ export class TreeViewWidget extends TreeViewWelcomeWidget { ...attrs, onMouseLeave: () => source?.cancel(), onMouseEnter: async event => { - const target = event.currentTarget; // event.currentTarget will be null after awaiting node resolve() + const target = event.currentTarget; // event.currentTarget will be null after awaiting node resolve() if (configuredTip) { if (MarkdownString.is(node.tooltip)) { this.hoverService.requestHover({ diff --git a/packages/plugin-ext/src/main/browser/view/tree-views-main.ts b/packages/plugin-ext/src/main/browser/view/tree-views-main.ts index d2bc6b14d2130..7809098732fbf 100644 --- a/packages/plugin-ext/src/main/browser/view/tree-views-main.ts +++ b/packages/plugin-ext/src/main/browser/view/tree-views-main.ts @@ -184,13 +184,11 @@ export class TreeViewsMainImpl implements TreeViewsMain, Disposable { } } - async setChecked(treeViewWidget: TreeViewWidget, changedNodes: TreeViewNode[]) { - this.proxy.$checkStateChanged(treeViewWidget.id, changedNodes.map(node => { - return { - id: node.id, - checked: !!node.checkboxInfo?.checked - } - })); + async setChecked(treeViewWidget: TreeViewWidget, changedNodes: TreeViewNode[]): Promise { + await this.proxy.$checkStateChanged(treeViewWidget.id, changedNodes.map(node => ({ + id: node.id, + checked: !!node.checkboxInfo?.checked + }))); } protected handleTreeEvents(treeViewId: string, treeViewWidget: TreeViewWidget): void { diff --git a/packages/plugin-ext/src/plugin/tree/tree-views.ts b/packages/plugin-ext/src/plugin/tree/tree-views.ts index c8188106bf64b..1b62c35505bfc 100644 --- a/packages/plugin-ext/src/plugin/tree/tree-views.ts +++ b/packages/plugin-ext/src/plugin/tree/tree-views.ts @@ -55,7 +55,7 @@ export class TreeViewsExtImpl implements TreeViewsExt { } }); } - $checkStateChanged(treeViewId: string, itemIds: { id: string; checked: boolean; }[]): unknown { + $checkStateChanged(treeViewId: string, itemIds: { id: string; checked: boolean; }[]): Promise { return this.getTreeView(treeViewId).checkStateChanged(itemIds); } $dragStarted(treeViewId: string, treeItemIds: string[], token: CancellationToken): Promise { @@ -244,7 +244,12 @@ class TreeViewExtImpl implements Disposable { // make copies of optionally provided MIME types: const dragMimeTypes = options.dragAndDropController?.dragMimeTypes?.slice(); const dropMimeTypes = options.dragAndDropController?.dropMimeTypes?.slice(); - proxy.$registerTreeDataProvider(treeViewId, { manageCheckboxStateManually: options.manageCheckboxStateManually, showCollapseAll: options.showCollapseAll, canSelectMany: options.canSelectMany, dragMimeTypes, dropMimeTypes }); + proxy.$registerTreeDataProvider(treeViewId, { + manageCheckboxStateManually: options.manageCheckboxStateManually, + showCollapseAll: options.showCollapseAll, + canSelectMany: options.canSelectMany, + dragMimeTypes, dropMimeTypes + }); this.toDispose.push(Disposable.create(() => this.proxy.$unregisterTreeDataProvider(treeViewId))); options.treeDataProvider.onDidChangeTreeData?.(() => { this.pendingRefresh = proxy.$refresh(treeViewId); @@ -451,11 +456,11 @@ class TreeViewExtImpl implements Disposable { checked: treeItem.checkboxState.state === TreeItemCheckboxState.Checked, tooltip: treeItem.checkboxState.tooltip, accessibilityInformation: treeItem.accessibilityInformation - } + }; } else { checkboxInfo = { checked: treeItem.checkboxState === TreeItemCheckboxState.Checked - } + }; } const treeViewItem: TreeViewItem = { @@ -537,7 +542,7 @@ class TreeViewExtImpl implements Disposable { } } - checkStateChanged(items: readonly { id: string; checked: boolean; }[]): void { + async checkStateChanged(items: readonly { id: string; checked: boolean; }[]): Promise { const transformed: [T, TreeItemCheckboxState][] = []; items.forEach(item => { const node = this.nodes.get(item.id); diff --git a/packages/plugin-ext/src/plugin/types-impl.ts b/packages/plugin-ext/src/plugin/types-impl.ts index b63f4c4ac5d0d..18b15b374b8dc 100644 --- a/packages/plugin-ext/src/plugin/types-impl.ts +++ b/packages/plugin-ext/src/plugin/types-impl.ts @@ -1908,8 +1908,11 @@ export class TreeItem { contextValue?: string; - checkboxState?: theia.TreeItemCheckboxState | { readonly state: theia.TreeItemCheckboxState; readonly tooltip?: string; readonly accessibilityInformation?: AccessibilityInformation }; - + checkboxState?: theia.TreeItemCheckboxState | { + readonly state: theia.TreeItemCheckboxState; + readonly tooltip?: string; + readonly accessibilityInformation?: AccessibilityInformation + }; constructor(label: string | theia.TreeItemLabel, collapsibleState?: theia.TreeItemCollapsibleState) constructor(resourceUri: URI, collapsibleState?: theia.TreeItemCollapsibleState) diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index 0541277a7e8b7..c55570f398331 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -5956,7 +5956,7 @@ export module '@theia/plugin' { * * 2. A tree item's parent is checked. The tree item and all of it's siblings will be checked. * - [ ] Parent - * - [ ] Child 1 + * - [ ] Child 1 * - [ ] Child 2 * When the user checks Parent, the tree will look like this: * - [x] Parent @@ -6200,12 +6200,11 @@ export module '@theia/plugin' { */ export interface TreeCheckboxChangeEvent { /** - * The items that were checked or unchecked. - */ + * The items that were checked or unchecked. + */ readonly items: ReadonlyArray<[T, TreeItemCheckboxState]>; } - /** * Represents a Tree view */ @@ -6241,10 +6240,9 @@ export module '@theia/plugin' { */ readonly onDidChangeVisibility: Event; - /** - * An event to signal that an element or root has either been checked or unchecked. - */ + * An event to signal that an element or root has either been checked or unchecked. + */ readonly onDidChangeCheckboxState: Event>; /** @@ -6419,7 +6417,6 @@ export module '@theia/plugin' { */ accessibilityInformation?: AccessibilityInformation; - /** * {@link TreeItemCheckboxState TreeItemCheckboxState} of the tree item. * {@link TreeDataProvider.onDidChangeTreeData onDidChangeTreeData} should be fired when {@link TreeItem.checkboxState checkboxState} changes. @@ -6427,9 +6424,9 @@ export module '@theia/plugin' { checkboxState?: TreeItemCheckboxState | { readonly state: TreeItemCheckboxState; readonly tooltip?: string; readonly accessibilityInformation?: AccessibilityInformation }; /** - * @param label A human-readable string describing this item - * @param collapsibleState {@link TreeItemCollapsibleState TreeItemCollapsibleState} of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None) - */ + * @param label A human-readable string describing this item + * @param collapsibleState {@link TreeItemCollapsibleState TreeItemCollapsibleState} of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None) + */ constructor(label: string | TreeItemLabel, collapsibleState?: TreeItemCollapsibleState); /** @@ -6475,8 +6472,8 @@ export module '@theia/plugin' { } /** - * Checkbox state of the tree item - */ + * Checkbox state of the tree item + */ export enum TreeItemCheckboxState { /** * Determines an item is unchecked