Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export namespace Explorer {
File = "file",
Type = "type",
Folder = "folder",
Symbol = "symbol",
}

export enum Mime {
Expand Down
24 changes: 13 additions & 11 deletions src/views/DragAndDropController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
this.addInternalDragDataTransfer(dragItem, treeDataTransfer);
sendInfo("", {
dndType: "drag",
dragFrom: dragItem.constructor.name,
dragFrom: dragItem.computeContextValue() || "unknown",
});
}

Expand Down Expand Up @@ -121,8 +121,8 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
if (!this.isDraggableNode(source)) {
sendInfo("", {
dndType: "drop",
dragFrom: source ? source.constructor.name : "undefined",
dropTo: target ? target.constructor.name : "undefined",
dragFrom: source?.computeContextValue() || "unknown",
dropTo: target?.computeContextValue() || "unknown",
draggable: "false",
});
return;
Expand All @@ -131,8 +131,8 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
if (!this.isDroppableNode(target)) {
sendInfo("", {
dndType: "drop",
dragFrom: source ? source.constructor.name : "undefined",
dropTo: target ? target.constructor.name : "undefined",
dragFrom: source?.computeContextValue() || "unknown",
dropTo: target?.computeContextValue() || "unknown",
draggable: "true",
droppable: "false",
});
Expand All @@ -149,7 +149,7 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
|| !(target.getParent() as ProjectNode).isUnmanagedFolder()) {
sendInfo("", {
dndType: "drop",
dragFrom: source ? source.constructor.name : "undefined",
dragFrom: source?.computeContextValue() || "unknown",
dropTo: "Referenced Libraries",
draggable: "true",
droppable: "false",
Expand All @@ -160,7 +160,7 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
this.addReferencedLibraries([source?.uri!]);
sendInfo("", {
dndType: "drop",
dragFrom: source ? source.constructor.name : "undefined",
dragFrom: source?.computeContextValue() || "unknown",
dropTo: "Referenced Libraries",
draggable: "true",
droppable: "true",
Expand All @@ -170,8 +170,8 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
await this.move(Uri.parse(source!.uri!), Uri.parse(target.uri!));
sendInfo("", {
dndType: "drop",
dragFrom: source ? source.constructor.name : "undefined",
dropTo: target ? target.constructor.name : "undefined",
dragFrom: source?.computeContextValue() || "unknown",
dropTo: target?.computeContextValue() || "unknown",
draggable: "true",
droppable: "true",
});
Expand All @@ -188,7 +188,7 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
sendInfo("", {
dndType: "drop",
dragFrom: "File Explorer",
dropTo: target ? target.constructor.name : "undefined",
dropTo: target?.computeContextValue() || "unknown",
draggable: "true",
droppable: "false",
});
Expand Down Expand Up @@ -224,7 +224,7 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
sendInfo("", {
dndType: "drop",
dragFrom: "File Explorer",
dropTo: target ? target.constructor.name : "undefined",
dropTo: target?.computeContextValue() || "unknown",
draggable: "true",
droppable: "true",
});
Expand Down Expand Up @@ -294,6 +294,8 @@ export class DragAndDropController implements TreeDragAndDropController<Explorer
return false;
} else if (parent instanceof PackageRootNode) {
return parent.isSourceRoot();
} else if (parent instanceof PackageNode) {
return parent.isSourcePackage();
} else if (parent instanceof ContainerNode) {
if (parent.getContainerType() === ContainerType.ReferencedLibrary) {
return (parent.getParent() as ProjectNode).isUnmanagedFolder();
Expand Down
5 changes: 5 additions & 0 deletions src/views/documentSymbolNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license.

import { DocumentSymbol, Range, TreeItem, TreeItemCollapsibleState } from "vscode";
import { Explorer } from "../constants";
import { BaseSymbolNode } from "./baseSymbolNode";
import { ExplorerNode } from "./explorerNode";
import { PrimaryTypeNode } from "./PrimaryTypeNode";
Expand Down Expand Up @@ -35,4 +36,8 @@ export class DocumentSymbolNode extends BaseSymbolNode {
// Using `selectionRange` instead of `range` to make sure the cursor will be pointing to the codes, not the comments
return (<DocumentSymbol>this.symbolInfo).selectionRange;
}

public computeContextValue(): string | undefined {
return `java:${Explorer.ContextValueType.Symbol}`;
}
}
2 changes: 2 additions & 0 deletions src/views/explorerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ export abstract class ExplorerNode {
public abstract getChildren(): ProviderResult<ExplorerNode[]>;

public abstract getTreeItem(): TreeItem | Promise<TreeItem>;

public abstract computeContextValue(): string | undefined;
}
5 changes: 5 additions & 0 deletions src/views/packageNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export class PackageNode extends DataNode {
super(nodeData, parent);
}

public isSourcePackage(): boolean {
const parentData = <IPackageRootNodeData> this._rootNode.nodeData;
return parentData.entryKind === PackageRootKind.K_SOURCE || parentData.kind === NodeKind.Project;
}

protected async loadData(): Promise<INodeData[]> {
return Jdtls.getPackageData({
kind: NodeKind.Package,
Expand Down
5 changes: 5 additions & 0 deletions src/views/symbolNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -39,4 +40,8 @@ export class SymbolNode extends BaseSymbolNode {
public get range(): Range {
return (<SymbolInformation>this.symbolInfo).location.range;
}

public computeContextValue(): string | undefined {
return `java:${Explorer.ContextValueType.Symbol}`;
}
}