From 04937688c3506434af64686a6e42e7c5f3758121 Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Wed, 22 Jun 2022 10:33:50 +0800 Subject: [PATCH] fix: Use context value to identify the node types Signed-off-by: Sheng Chen --- src/constants.ts | 1 + src/views/DragAndDropController.ts | 24 +++++++++++++----------- src/views/documentSymbolNode.ts | 5 +++++ src/views/explorerNode.ts | 2 ++ src/views/packageNode.ts | 5 +++++ src/views/symbolNode.ts | 5 +++++ 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 45ac1443..36b81729 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -19,6 +19,7 @@ export namespace Explorer { File = "file", Type = "type", Folder = "folder", + Symbol = "symbol", } export enum Mime { diff --git a/src/views/DragAndDropController.ts b/src/views/DragAndDropController.ts index 1d315da3..2f5e140b 100644 --- a/src/views/DragAndDropController.ts +++ b/src/views/DragAndDropController.ts @@ -37,7 +37,7 @@ export class DragAndDropController implements TreeDragAndDropControllerthis.symbolInfo).selectionRange; } + + public computeContextValue(): string | undefined { + return `java:${Explorer.ContextValueType.Symbol}`; + } } diff --git a/src/views/explorerNode.ts b/src/views/explorerNode.ts index c892a1d6..c5c29092 100644 --- a/src/views/explorerNode.ts +++ b/src/views/explorerNode.ts @@ -31,4 +31,6 @@ export abstract class ExplorerNode { public abstract getChildren(): ProviderResult; public abstract getTreeItem(): TreeItem | Promise; + + public abstract computeContextValue(): string | undefined; } diff --git a/src/views/packageNode.ts b/src/views/packageNode.ts index da05fbb8..213cded4 100644 --- a/src/views/packageNode.ts +++ b/src/views/packageNode.ts @@ -17,6 +17,11 @@ export class PackageNode extends DataNode { super(nodeData, parent); } + public isSourcePackage(): boolean { + const parentData = this._rootNode.nodeData; + return parentData.entryKind === PackageRootKind.K_SOURCE || parentData.kind === NodeKind.Project; + } + protected async loadData(): Promise { return Jdtls.getPackageData({ kind: NodeKind.Package, diff --git a/src/views/symbolNode.ts b/src/views/symbolNode.ts index eb7817a8..1505a079 100644 --- a/src/views/symbolNode.ts +++ b/src/views/symbolNode.ts @@ -2,6 +2,7 @@ // Licensed under the MIT license. import { Range, SymbolInformation, TreeItem, TreeItemCollapsibleState } from "vscode"; +import { Explorer } from "../constants"; import { ITypeRootNodeData } from "../java/typeRootNodeData"; import { BaseSymbolNode } from "./baseSymbolNode"; import { ExplorerNode } from "./explorerNode"; @@ -39,4 +40,8 @@ export class SymbolNode extends BaseSymbolNode { public get range(): Range { return (this.symbolInfo).location.range; } + + public computeContextValue(): string | undefined { + return `java:${Explorer.ContextValueType.Symbol}`; + } }