1- import * as vscode from " vscode" ;
2- import * as open from " open" ;
1+ import * as vscode from ' vscode' ;
2+ import open from ' open' ;
33
4- import DeepCode from " ../interfaces/DeepCodeInterfaces" ;
5- import DeepCodeLib from " ./lib/modules/DeepCodeLib" ;
4+ import { ExtensionInterface } from ' ../interfaces/DeepCodeInterfaces' ;
5+ import DeepCodeLib from ' ./lib/modules/DeepCodeLib' ;
66
77import {
88 DEEPCODE_START_COMMAND ,
@@ -14,25 +14,15 @@ import {
1414 DEEPCODE_OPEN_BROWSER_COMMAND ,
1515 DEEPCODE_OPEN_LOCAL_COMMAND ,
1616 DEEPCODE_OPEN_ISSUE_COMMAND ,
17- } from "./constants/commands" ;
18- import {
19- openDeepcodeSettingsCommand ,
20- createDCIgnoreCommand ,
21- } from "./utils/vscodeCommandsUtils" ;
17+ } from './constants/commands' ;
18+ import { openDeepcodeSettingsCommand , createDCIgnoreCommand } from './utils/vscodeCommandsUtils' ;
2219import { errorsLogs } from './messages/errorsServerLogMessages' ;
23- import {
24- DEEPCODE_VIEW_SUPPORT ,
25- DEEPCODE_VIEW_ANALYSIS ,
26- } from "./constants/views" ;
27- import { SupportProvider } from "./view/SupportProvider" ;
28- import { IssueProvider } from "./view/IssueProvider" ;
29-
30- class DeepCodeExtension extends DeepCodeLib implements DeepCode . ExtensionInterface {
31- private async executeCommand (
32- name : string ,
33- fn : ( ...args : any [ ] ) => Promise < any > ,
34- ...args : any [ ]
35- ) : Promise < any > {
20+ import { DEEPCODE_VIEW_SUPPORT , DEEPCODE_VIEW_ANALYSIS } from './constants/views' ;
21+ import { SupportProvider } from './view/SupportProvider' ;
22+ import { IssueProvider } from './view/IssueProvider' ;
23+
24+ class DeepCodeExtension extends DeepCodeLib implements ExtensionInterface {
25+ private async executeCommand ( name : string , fn : ( ...args : any [ ] ) => Promise < any > , ...args : any [ ] ) : Promise < any > {
3626 try {
3727 await fn ( ...args ) ;
3828 } catch ( error ) {
@@ -48,81 +38,56 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
4838 context . subscriptions . push (
4939 vscode . commands . registerCommand (
5040 DEEPCODE_OPEN_BROWSER_COMMAND ,
51- this . executeCommand . bind (
52- this ,
53- DEEPCODE_OPEN_BROWSER_COMMAND ,
54- ( url : string ) => open ( url )
55- )
56- )
41+ this . executeCommand . bind ( this , DEEPCODE_OPEN_BROWSER_COMMAND , ( url : string ) => open ( url ) ) ,
42+ ) ,
5743 ) ;
5844
5945 context . subscriptions . push (
60- vscode . commands . registerCommand (
61- DEEPCODE_OPEN_LOCAL_COMMAND ,
62- ( path : vscode . Uri , range ?: vscode . Range ) => {
63- vscode . window . showTextDocument ( path , { selection : range } ) . then (
64- // no need to wait for processError since then is called asynchronously as well
65- ( ) => { } , ( err ) => this . processError ( err , {
46+ vscode . commands . registerCommand ( DEEPCODE_OPEN_LOCAL_COMMAND , ( path : vscode . Uri , range ?: vscode . Range ) => {
47+ vscode . window . showTextDocument ( path , { selection : range } ) . then (
48+ // no need to wait for processError since then is called asynchronously as well
49+ ( ) => { } ,
50+ err =>
51+ this . processError ( err , {
6652 message : errorsLogs . command ( DEEPCODE_OPEN_LOCAL_COMMAND ) ,
67- } )
68- ) ;
69- }
70- )
53+ } ) ,
54+ ) ;
55+ } ) ,
7156 ) ;
7257
7358 context . subscriptions . push (
7459 vscode . commands . registerCommand (
7560 DEEPCODE_LOGIN_COMMAND ,
76- this . executeCommand . bind (
77- this ,
78- DEEPCODE_LOGIN_COMMAND ,
79- this . initiateLogin . bind ( this )
80- )
81- )
61+ this . executeCommand . bind ( this , DEEPCODE_LOGIN_COMMAND , this . initiateLogin . bind ( this ) ) ,
62+ ) ,
8263 ) ;
8364
8465 context . subscriptions . push (
8566 vscode . commands . registerCommand (
8667 DEEPCODE_APPROVE_COMMAND ,
87- this . executeCommand . bind (
88- this ,
89- DEEPCODE_APPROVE_COMMAND ,
90- this . approveUpload . bind ( this )
91- )
92- )
68+ this . executeCommand . bind ( this , DEEPCODE_APPROVE_COMMAND , this . approveUpload . bind ( this ) ) ,
69+ ) ,
9370 ) ;
9471
9572 context . subscriptions . push (
9673 vscode . commands . registerCommand (
9774 DEEPCODE_START_COMMAND ,
98- this . executeCommand . bind (
99- this ,
100- DEEPCODE_START_COMMAND ,
101- this . startExtension . bind ( this )
102- )
103- )
75+ this . executeCommand . bind ( this , DEEPCODE_START_COMMAND , this . startExtension . bind ( this ) ) ,
76+ ) ,
10477 ) ;
10578
10679 context . subscriptions . push (
10780 vscode . commands . registerCommand (
10881 DEEPCODE_SETMODE_COMMAND ,
109- this . executeCommand . bind (
110- this ,
111- DEEPCODE_SETMODE_COMMAND ,
112- this . setMode . bind ( this )
113- )
114- )
82+ this . executeCommand . bind ( this , DEEPCODE_SETMODE_COMMAND , this . setMode . bind ( this ) ) ,
83+ ) ,
11584 ) ;
11685
11786 context . subscriptions . push (
11887 vscode . commands . registerCommand (
11988 DEEPCODE_SETTINGS_COMMAND ,
120- this . executeCommand . bind (
121- this ,
122- DEEPCODE_SETTINGS_COMMAND ,
123- openDeepcodeSettingsCommand
124- )
125- )
89+ this . executeCommand . bind ( this , DEEPCODE_SETTINGS_COMMAND , openDeepcodeSettingsCommand ) ,
90+ ) ,
12691 ) ;
12792
12893 context . subscriptions . push (
@@ -131,54 +96,42 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
13196 this . executeCommand . bind (
13297 this ,
13398 DEEPCODE_OPEN_ISSUE_COMMAND ,
134- async (
135- issueId : string ,
136- severity : number ,
137- uri : vscode . Uri ,
138- range : vscode . Range ,
139- ) => {
140- await vscode . commands . executeCommand (
141- DEEPCODE_OPEN_LOCAL_COMMAND , uri , range
142- ) ;
99+ async ( issueId : string , severity : number , uri : vscode . Uri , range : vscode . Range ) => {
100+ await vscode . commands . executeCommand ( DEEPCODE_OPEN_LOCAL_COMMAND , uri , range ) ;
143101 await this . trackViewSuggestion ( issueId , severity ) ;
144- }
145- )
146- )
102+ } ,
103+ ) ,
104+ ) ,
147105 ) ;
148106
149107 context . subscriptions . push (
150108 vscode . commands . registerCommand (
151109 DEEPCODE_DCIGNORE_COMMAND ,
152- this . executeCommand . bind (
153- this ,
154- DEEPCODE_DCIGNORE_COMMAND ,
155- createDCIgnoreCommand
156- )
157- )
110+ this . executeCommand . bind ( this , DEEPCODE_DCIGNORE_COMMAND , createDCIgnoreCommand ) ,
111+ ) ,
158112 ) ;
159113
160- vscode . window . registerTreeDataProvider (
161- DEEPCODE_VIEW_SUPPORT ,
162- new SupportProvider ( this )
163- ) ;
114+ vscode . window . registerTreeDataProvider ( DEEPCODE_VIEW_SUPPORT , new SupportProvider ( this ) ) ;
164115
165- vscode . window . registerTreeDataProvider (
166- DEEPCODE_VIEW_ANALYSIS ,
167- new IssueProvider ( this )
168- ) ;
116+ vscode . window . registerTreeDataProvider ( DEEPCODE_VIEW_ANALYSIS , new IssueProvider ( this ) ) ;
169117
170118 this . activateAll ( ) ;
171- this . startExtension ( ) . catch ( ( err ) => this . processError ( err , {
172- message : errorsLogs . failedExecution ,
173- } ) ) ;
174- this . checkWelcomeNotification ( ) . catch ( ( err ) => this . processError ( err , {
175- message : errorsLogs . welcomeNotification ,
176- } ) ) ;
177- this . checkAdvancedMode ( ) . catch ( ( err ) => this . processError ( err , {
178- message : errorsLogs . checkAdvancedMode ,
179- } ) ) ;
119+ this . startExtension ( ) . catch ( err =>
120+ this . processError ( err , {
121+ message : errorsLogs . failedExecution ,
122+ } ) ,
123+ ) ;
124+ this . checkWelcomeNotification ( ) . catch ( err =>
125+ this . processError ( err , {
126+ message : errorsLogs . welcomeNotification ,
127+ } ) ,
128+ ) ;
129+ this . checkAdvancedMode ( ) . catch ( err =>
130+ this . processError ( err , {
131+ message : errorsLogs . checkAdvancedMode ,
132+ } ) ,
133+ ) ;
180134 }
181-
182135}
183136
184137export default DeepCodeExtension ;
0 commit comments