88 errorType ,
99} from "../../../interfaces/DeepCodeInterfaces" ;
1010import DeepCodeAnalyzer from "../analyzer/DeepCodeAnalyzer" ;
11- import DeepCodeStatusBarItem from "../statusBarItem/DeepCodeStatusBarItem" ;
12- import DeepCodeFilesWatcher from "../watchers/DeepCodeFilesWatcher" ;
11+ import DeepCodeStatusBarItem from '../statusBarItem/DeepCodeStatusBarItem' ;
1312import DeepCodeEditorsWatcher from "../watchers/EditorsWatcher" ;
1413import DeepCodeSettingsWatcher from "../watchers/DeepCodeSettingsWatcher" ;
1514import { PendingTask , PendingTaskInterface } from "../../utils/pendingTask" ;
@@ -24,31 +23,30 @@ import { IFileBundle } from '@deepcode/tsc';
2423export default abstract class BaseDeepCodeModule implements BaseDeepCodeModuleInterface {
2524 analyzer : AnalyzerInterface ;
2625 statusBarItem : StatusBarItemInterface ;
27- filesWatcher : DeepCodeWatcherInterface ;
26+ filesWatcher : vscode . FileSystemWatcher ;
2827 editorsWatcher : DeepCodeWatcherInterface ;
2928 settingsWatcher : DeepCodeWatcherInterface ;
3029
3130 // Views and analysis progress
3231 refreshViewEmitter : vscode . EventEmitter < any > ;
33- analysisStatus = '' ;
32+ analysisStatus = '' ;
3433 analysisProgress = '' ;
3534 private initializedView : PendingTaskInterface ;
3635 private progressBadge : PendingTaskInterface | undefined ;
3736 private shouldShowProgressBadge = false ;
38- private viewContext : { [ key : string ] : unknown } ;
37+ private viewContext : { [ key : string ] : unknown } ;
3938
4039 remoteBundle : IFileBundle ;
40+ changedFiles : Set < string > = new Set ( ) ;
4141
4242 // These attributes are used in tests
4343 staticToken = '' ;
44- staticBaseURL = '' ;
4544 defaultBaseURL = 'https://www.deepcode.ai' ;
4645 staticUploadApproved = false ;
4746
4847 constructor ( ) {
4948 this . analyzer = new DeepCodeAnalyzer ( ) ;
5049 this . statusBarItem = new DeepCodeStatusBarItem ( ) ;
51- this . filesWatcher = new DeepCodeFilesWatcher ( ) ;
5250 this . editorsWatcher = new DeepCodeEditorsWatcher ( ) ;
5351 this . settingsWatcher = new DeepCodeSettingsWatcher ( ) ;
5452 this . refreshViewEmitter = new vscode . EventEmitter < any > ( ) ;
@@ -60,7 +58,7 @@ export default abstract class BaseDeepCodeModule implements BaseDeepCodeModuleIn
6058
6159 get baseURL ( ) : string {
6260 // @ts -ignore */}
63- return this . staticBaseURL || vscode . workspace . getConfiguration ( 'deepcode' ) . get ( 'url' ) || this . defaultBaseURL ;
61+ return vscode . workspace . getConfiguration ( 'deepcode' ) . get ( 'url' ) || this . defaultBaseURL ;
6462 }
6563
6664 get termsConditionsUrl ( ) : string {
@@ -72,7 +70,7 @@ export default abstract class BaseDeepCodeModule implements BaseDeepCodeModuleIn
7270 return this . staticToken || vscode . workspace . getConfiguration ( 'deepcode' ) . get ( 'token' ) ;
7371 }
7472
75- async setToken ( token : string ) : Promise < void > {
73+ async setToken ( token : string ) : Promise < void > {
7674 this . staticToken = '' ;
7775 await vscode . workspace . getConfiguration ( 'deepcode' ) . update ( 'token' , token , true ) ;
7876 }
@@ -82,7 +80,11 @@ export default abstract class BaseDeepCodeModule implements BaseDeepCodeModuleIn
8280 }
8381
8482 get uploadApproved ( ) : boolean {
85- return this . staticUploadApproved || this . source !== IDE_NAME || ! ! ( vscode . workspace . getConfiguration ( 'deepcode' ) . get < boolean > ( 'uploadApproved' ) ) ;
83+ return (
84+ this . staticUploadApproved ||
85+ this . source !== IDE_NAME ||
86+ ! ! vscode . workspace . getConfiguration ( 'deepcode' ) . get < boolean > ( 'uploadApproved' )
87+ ) ;
8688 }
8789
8890 async setUploadApproved ( value = true ) : Promise < void > {
@@ -110,7 +112,7 @@ export default abstract class BaseDeepCodeModule implements BaseDeepCodeModuleIn
110112 }
111113
112114 async setContext ( key : string , value : unknown ) : Promise < void > {
113- console . log ( " DeepCode context" , key , value ) ;
115+ console . log ( ' DeepCode context' , key , value ) ;
114116 const oldValue = this . viewContext [ key ] ;
115117 this . viewContext [ key ] = value ;
116118 await setContext ( key , value ) ;
@@ -119,10 +121,10 @@ export default abstract class BaseDeepCodeModule implements BaseDeepCodeModuleIn
119121 }
120122
121123 private trackContextChange ( key : string , value : unknown , oldValue : unknown ) {
122- let event = "" ;
124+ let event = '' ;
123125 let shouldWaitForView = true ;
124- let options : Record < string , any > | undefined ;
125- switch ( key ) {
126+ let options : Record < string , any > | undefined ;
127+ switch ( key ) {
126128 case DEEPCODE_CONTEXT . LOGGEDIN : {
127129 if ( oldValue !== undefined ) {
128130 if ( ! value && oldValue ) event = TELEMETRY_EVENTS . viewLoginView ;
@@ -157,21 +159,15 @@ export default abstract class BaseDeepCodeModule implements BaseDeepCodeModuleIn
157159 }
158160 // We want to fire the event only when the user actually sees the View
159161 if ( event ) {
160- if ( shouldWaitForView ) this . initializedView . waiter . then (
161- ( ) => this . processEvent ( event , options )
162- ) ;
162+ if ( shouldWaitForView ) this . initializedView . waiter . then ( ( ) => this . processEvent ( event , options ) ) ;
163163 else this . processEvent ( event , options ) ;
164164 }
165165 }
166166
167167 get shouldShowAnalysis ( ) : boolean {
168- return ! this . viewContext [
169- DEEPCODE_CONTEXT . ERROR
170- ] && [
171- DEEPCODE_CONTEXT . LOGGEDIN ,
172- DEEPCODE_CONTEXT . APPROVED ,
173- ] . every (
174- ( c ) => ! ! this . viewContext [ c ]
168+ return (
169+ ! this . viewContext [ DEEPCODE_CONTEXT . ERROR ] &&
170+ [ DEEPCODE_CONTEXT . LOGGEDIN , DEEPCODE_CONTEXT . APPROVED ] . every ( c => ! ! this . viewContext [ c ] )
175171 ) ;
176172 }
177173
@@ -189,17 +185,19 @@ export default abstract class BaseDeepCodeModule implements BaseDeepCodeModuleIn
189185 if ( value ) {
190186 // Using closure on this to allow partial binding in arbitrary positions
191187 const self = this ;
192- this . initializedView . waiter . then (
193- ( ) => vscode . window . withProgress (
194- { location : { viewId : DEEPCODE_VIEW_ANALYSIS } } ,
195- ( ) => self . getProgressBadgePromise ( )
188+ this . initializedView . waiter
189+ . then ( ( ) =>
190+ vscode . window . withProgress ( { location : { viewId : DEEPCODE_VIEW_ANALYSIS } } , ( ) =>
191+ self . getProgressBadgePromise ( ) ,
192+ ) ,
196193 )
197- ) . then (
198- ( ) => { } ,
199- ( error ) => self . processError ( error , {
200- message : errorsLogs . loadingBadge ,
201- } )
202- ) ;
194+ . then (
195+ ( ) => { } ,
196+ error =>
197+ self . processError ( error , {
198+ message : errorsLogs . loadingBadge ,
199+ } ) ,
200+ ) ;
203201 } else {
204202 if ( this . progressBadge && ! this . progressBadge . isCompleted ) {
205203 this . progressBadge . complete ( ) ;
@@ -216,18 +214,12 @@ export default abstract class BaseDeepCodeModule implements BaseDeepCodeModuleIn
216214 refreshViews = _ . throttle (
217215 ( content ?: any ) : void => this . refreshViewEmitter . fire ( content || undefined ) ,
218216 REFRESH_VIEW_DEBOUNCE_INTERVAL ,
219- { ' leading' : true }
217+ { leading : true } ,
220218 ) ;
221219
222- abstract processError (
223- error : errorType ,
224- options ?: { [ key : string ] : any }
225- ) : Promise < void > ;
220+ abstract processError ( error : errorType , options ?: { [ key : string ] : any } ) : Promise < void > ;
226221
227- abstract processEvent (
228- event : string ,
229- options ?: { [ key : string ] : any }
230- ) : Promise < void > ;
222+ abstract processEvent ( event : string , options ?: { [ key : string ] : any } ) : Promise < void > ;
231223
232224 abstract startExtension ( ) : Promise < void > ;
233225}
0 commit comments