4
4
import * as fse from "fs-extra" ;
5
5
import * as _ from "lodash" ;
6
6
import * as path from "path" ;
7
- import { commands , Disposable , ExtensionContext , TextEditor , TreeView , TreeViewVisibilityChangeEvent , Uri , window } from "vscode" ;
8
- import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper" ;
7
+ import { commands , Disposable , ExtensionContext , TextEditor , TreeView ,
8
+ TreeViewExpansionEvent , TreeViewSelectionChangeEvent , TreeViewVisibilityChangeEvent , Uri , window } from "vscode" ;
9
+ import { instrumentOperationAsVsCodeCommand , sendInfo } from "vscode-extension-telemetry-wrapper" ;
9
10
import { Commands } from "../commands" ;
10
11
import { Build } from "../constants" ;
11
12
import { deleteFiles } from "../explorerCommands/delete" ;
12
13
import { renameFile } from "../explorerCommands/rename" ;
13
14
import { getCmdNode } from "../explorerCommands/utility" ;
14
15
import { Jdtls } from "../java/jdtls" ;
15
16
import { INodeData } from "../java/nodeData" ;
16
- import { Utility } from "../utility" ;
17
+ import { EventCounter , Utility } from "../utility" ;
17
18
import { Lock } from "../utils/Lock" ;
18
19
import { DataNode } from "./dataNode" ;
19
20
import { DependencyDataProvider } from "./dependencyDataProvider" ;
@@ -41,32 +42,27 @@ export class DependencyExplorer implements Disposable {
41
42
this . _dataProvider = new DependencyDataProvider ( context ) ;
42
43
this . _dependencyViewer = window . createTreeView ( "javaProjectExplorer" , { treeDataProvider : this . _dataProvider , showCollapseAll : true } ) ;
43
44
45
+ // register reveal events
44
46
context . subscriptions . push (
45
47
window . onDidChangeActiveTextEditor ( ( textEditor : TextEditor | undefined ) => {
46
48
if ( this . _dependencyViewer . visible && textEditor ?. document ) {
47
49
const uri : Uri = textEditor . document . uri ;
48
50
this . reveal ( uri ) ;
49
51
}
50
52
} ) ,
51
- ) ;
52
-
53
- context . subscriptions . push (
54
53
this . _dependencyViewer . onDidChangeVisibility ( ( e : TreeViewVisibilityChangeEvent ) => {
55
- if ( e . visible && window . activeTextEditor ) {
56
- this . reveal ( window . activeTextEditor . document . uri ) ;
54
+ if ( e . visible ) {
55
+ sendInfo ( "" , { projectManagerVisible : 1 } ) ;
56
+ if ( window . activeTextEditor ) {
57
+ this . reveal ( window . activeTextEditor . document . uri ) ;
58
+ }
57
59
}
58
60
} ) ,
59
- ) ;
60
-
61
- context . subscriptions . push (
62
61
this . _dataProvider . onDidChangeTreeData ( ( ) => {
63
62
if ( window . activeTextEditor ) {
64
63
this . reveal ( window . activeTextEditor . document . uri ) ;
65
64
}
66
65
} ) ,
67
- ) ;
68
-
69
- context . subscriptions . push (
70
66
instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_REVEAL_IN_PROJECT_EXPLORER , async ( uri : Uri ) => {
71
67
await commands . executeCommand ( Commands . JAVA_PROJECT_EXPLORER_FOCUS ) ;
72
68
let fsPath : string = uri . fsPath ;
@@ -77,13 +73,26 @@ export class DependencyExplorer implements Disposable {
77
73
78
74
uri = Uri . file ( fsPath ) ;
79
75
if ( ( await fse . stat ( fsPath ) ) . isFile ( ) ) {
80
- await commands . executeCommand ( Commands . VIEW_PACKAGE_OPEN_FILE , uri ) ;
76
+ await commands . executeCommand ( Commands . VSCODE_OPEN , uri , { preserveFocus : true } ) ;
81
77
}
82
78
83
79
this . reveal ( uri ) ;
84
80
} ) ,
85
81
) ;
86
82
83
+ // register telemetry events
84
+ context . subscriptions . push (
85
+ this . _dependencyViewer . onDidChangeSelection ( ( _e : TreeViewSelectionChangeEvent < ExplorerNode > ) => {
86
+ EventCounter . increase ( "didChangeSelection" ) ;
87
+ } ) ,
88
+ this . _dependencyViewer . onDidCollapseElement ( ( _e : TreeViewExpansionEvent < ExplorerNode > ) => {
89
+ EventCounter . increase ( "didCollapseElement" ) ;
90
+ } ) ,
91
+ this . _dependencyViewer . onDidExpandElement ( ( _e : TreeViewExpansionEvent < ExplorerNode > ) => {
92
+ EventCounter . increase ( "didExpandElement" ) ;
93
+ } ) ,
94
+ ) ;
95
+
87
96
// register keybinding commands
88
97
context . subscriptions . push (
89
98
instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_REVEAL_FILE_OS , ( node ?: DataNode ) => {
@@ -92,33 +101,21 @@ export class DependencyExplorer implements Disposable {
92
101
commands . executeCommand ( "revealFileInOS" , Uri . parse ( cmdNode . uri ) ) ;
93
102
}
94
103
} ) ,
95
- ) ;
96
-
97
- context . subscriptions . push (
98
104
instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_COPY_FILE_PATH , ( node ?: DataNode ) => {
99
105
const cmdNode = getCmdNode ( this . _dependencyViewer . selection [ 0 ] , node ) ;
100
106
if ( cmdNode . uri ) {
101
107
commands . executeCommand ( "copyFilePath" , Uri . parse ( cmdNode . uri ) ) ;
102
108
}
103
109
} ) ,
104
- ) ;
105
-
106
- context . subscriptions . push (
107
110
instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_COPY_RELATIVE_FILE_PATH , ( node ?: DataNode ) => {
108
111
const cmdNode = getCmdNode ( this . _dependencyViewer . selection [ 0 ] , node ) ;
109
112
if ( cmdNode . uri ) {
110
113
commands . executeCommand ( "copyRelativeFilePath" , Uri . parse ( cmdNode . uri ) ) ;
111
114
}
112
115
} ) ,
113
- ) ;
114
-
115
- context . subscriptions . push (
116
116
instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_RENAME_FILE , ( node ?: DataNode ) => {
117
117
renameFile ( getCmdNode ( this . _dependencyViewer . selection [ 0 ] , node ) ) ;
118
118
} ) ,
119
- ) ;
120
-
121
- context . subscriptions . push (
122
119
instrumentOperationAsVsCodeCommand ( Commands . VIEW_PACKAGE_MOVE_FILE_TO_TRASH , ( node ?: DataNode ) => {
123
120
deleteFiles ( getCmdNode ( this . _dependencyViewer . selection [ 0 ] , node ) ) ;
124
121
} ) ,
0 commit comments