@@ -11,11 +11,12 @@ import {
1111 TreeItemCollapsibleState ,
1212 ProviderResult ,
1313 window ,
14- ThemeIcon ,
1514 ExtensionContext ,
1615 commands ,
1716 Uri ,
18- MarkdownString ,
17+ DataTransfer ,
18+ TreeDragAndDropController ,
19+ CancellationToken ,
1920} from "vscode" ;
2021import IILSpyBackend from "./IILSpyBackend" ;
2122import Node from "../protocol/Node" ;
@@ -28,15 +29,26 @@ import {
2829} from "./settings" ;
2930import { getNodeIcon } from "../icons" ;
3031import { NodeFlags } from "../protocol/NodeFlags" ;
31- import { createNodeTooltip , getNodeContextValue , hasNodeFlag } from "./utils" ;
32-
33- export class DecompiledTreeProvider implements TreeDataProvider < Node > {
32+ import {
33+ ASSEMBLY_FILE_EXTENSIONS ,
34+ createNodeTooltip ,
35+ getNodeContextValue ,
36+ hasNodeFlag ,
37+ } from "./utils" ;
38+ import path = require( "path" ) ;
39+ import OutputWindowLogger from "../OutputWindowLogger" ;
40+ import { addAssemblyFromFilePath } from "../commands/utils" ;
41+
42+ export class DecompiledTreeProvider
43+ implements TreeDataProvider < Node > , TreeDragAndDropController < Node >
44+ {
3445 private _onDidChangeTreeData : EventEmitter < any > = new EventEmitter < any > ( ) ;
3546 readonly onDidChangeTreeData : Event < any > = this . _onDidChangeTreeData . event ;
3647
3748 constructor (
3849 private extensionContext : ExtensionContext ,
39- private backend : IILSpyBackend
50+ private backend : IILSpyBackend ,
51+ private logger : OutputWindowLogger
4052 ) { }
4153
4254 public refresh ( ) : void {
@@ -183,6 +195,43 @@ export class DecompiledTreeProvider implements TreeDataProvider<Node> {
183195 ) ?? [ ]
184196 ) ;
185197 }
198+
199+ readonly dropMimeTypes = [ "text/uri-list" ] ;
200+ readonly dragMimeTypes = [ ] ;
201+
202+ async handleDrop (
203+ target : Node | undefined ,
204+ dataTransfer : DataTransfer ,
205+ token : CancellationToken
206+ ) : Promise < void > {
207+ const test = 1 ;
208+ const uris =
209+ ( await dataTransfer . get ( "text/uri-list" ) ?. asString ( ) ) ?. split ( "\r\n" ) ??
210+ [ ] ;
211+ uris . forEach ( ( uri ) => {
212+ const fileUri = Uri . parse ( uri ) ;
213+ const filePath = fileUri . fsPath ;
214+ if ( this . isValidFile ( fileUri . fsPath ) ) {
215+ this . processDroppedFile ( target , filePath ) ;
216+ this . logger . writeLine (
217+ `Dropped assembly file ${ filePath } , trying to add to assembly list`
218+ ) ;
219+ } else {
220+ this . logger . writeLine ( `Dropped unsupported file ${ filePath } !` ) ;
221+ }
222+ } ) ;
223+ }
224+
225+ private isValidFile ( filePath : string ) : boolean {
226+ const ext = path . extname ( filePath ) ;
227+ return ASSEMBLY_FILE_EXTENSIONS . includes (
228+ path . extname ( filePath ) . substring ( 1 )
229+ ) ;
230+ }
231+
232+ private processDroppedFile ( target : Node | undefined , filePath : string ) : void {
233+ commands . executeCommand ( "ilspy.addAssemblyByPath" , filePath ) ;
234+ }
186235}
187236
188237function setTreeWithNodes ( treeWithNodes : boolean ) {
0 commit comments