You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/11/24 12:13:56 UTC
[GitHub] [netbeans] sdedic commented on a change in pull request #3323: Enable node-based UIs in LSP
sdedic commented on a change in pull request #3323:
URL: https://github.com/apache/netbeans/pull/3323#discussion_r756002629
##########
File path: java/java.lsp.server/vscode/src/explorer.ts
##########
@@ -0,0 +1,253 @@
+import * as vscode from 'vscode';
+import { LanguageClient } from 'vscode-languageclient/node';
+import { NodeChangedParams, NodeInfoNotification, NodeInfoRequest } from './protocol';
+
+class TreeViewService {
+ private client : LanguageClient;
+ private trees : Map<string, vscode.TreeView<Visualizer>> = new Map();
+ private images : Map<number, vscode.Uri> = new Map();
+ private providers : Map<number, VisualizerProvider> = new Map();
+ constructor (c : LanguageClient) {
+ this.client = c;
+ }
+
+ getClient() : LanguageClient {
+ return this.client;
+ }
+
+ async createView(id : string, options? : Partial<vscode.TreeViewOptions<any>>) : Promise<vscode.TreeView<Visualizer>> {
+ let tv : vscode.TreeView<Visualizer> | undefined = this.trees.get(id);
+ if (tv) {
+ return tv;
+ }
+ const res = await createViewProvider(id);
+ this.providers.set(res.getRoot().data.id, res);
+ let opts : vscode.TreeViewOptions<Visualizer> = {
+ treeDataProvider : res,
+ canSelectMany: true,
+ showCollapseAll: true,
+ }
+
+ if (options?.canSelectMany !== undefined) {
+ opts.canSelectMany = options.canSelectMany;
+ }
+ if (options?.showCollapseAll !== undefined) {
+ opts.showCollapseAll = options.showCollapseAll;
+ }
+ let view = vscode.window.createTreeView(id, opts);
+ // this will replace the handler over and over, but never mind
+ this.client.onNotification(NodeInfoNotification.type, params => this.nodeChanged(params));
+ return view;
+ }
+
+ private nodeChanged(params : NodeChangedParams) : void {
+ let p : VisualizerProvider | undefined = this.providers.get(params.rootId);
+ if (p) {
+ p.refresh(params);
+ }
+ }
+
+ imageUri(nodeData : NodeInfoRequest.Data) : vscode.Uri | undefined {
+ if (nodeData.iconUri) {
+ const uri : vscode.Uri = vscode.Uri.parse(nodeData.iconUri)
+ this.images.set(nodeData.iconIndex, uri);
+ return uri;
+ } else {
+ return this.images.get(nodeData.iconIndex);
+ }
+ }
+}
+
+let treeService : Promise<TreeViewService>;
+let promisedTreeService : (ts : TreeViewService) => void;
Review comment:
Done (by you :-)) in 60a33320
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists