@@ -32,15 +32,15 @@ import { getPathFromPythonCommand } from './common/utils';
32
32
import { JupyterProvider } from './jupyter/provider' ;
33
33
import { activateGoToObjectDefinitionProvider } from './providers/objectDefinitionProvider' ;
34
34
35
- const PYTHON : vscode . DocumentFilter = { language : 'python' , scheme : 'file' } ;
35
+ const PYTHON : vscode . DocumentFilter = { language : 'python' } ;
36
36
let unitTestOutChannel : vscode . OutputChannel ;
37
37
let formatOutChannel : vscode . OutputChannel ;
38
38
let lintingOutChannel : vscode . OutputChannel ;
39
39
let jupMain : jup . Jupyter ;
40
40
export function activate ( context : vscode . ExtensionContext ) {
41
- let pythonSettings = settings . PythonSettings . getInstance ( ) ;
42
- let pythonExt = new PythonExt ( ) ;
43
- const hasPySparkInCompletionPath = pythonSettings . autoComplete . extraPaths . some ( p => p . toLowerCase ( ) . indexOf ( 'spark' ) >= 0 ) ;
41
+ const pythonSettings = settings . PythonSettings . getInstance ( ) ;
42
+ const pythonExt = new PythonExt ( ) ;
43
+ context . subscriptions . push ( pythonExt ) ;
44
44
// telemetryHelper.sendTelemetryEvent(telemetryContracts.EVENT_LOAD, {
45
45
// CodeComplete_Has_ExtraPaths: pythonSettings.autoComplete.extraPaths.length > 0 ? 'true' : 'false',
46
46
// Format_Has_Custom_Python_Path: pythonSettings.pythonPath.length !== 'python'.length ? 'true' : 'false',
@@ -149,42 +149,39 @@ export function activate(context: vscode.ExtensionContext) {
149
149
context . subscriptions . push ( activateSingleFileDebug ( ) ) ;
150
150
}
151
151
152
- // this method is called when your extension is deactivated
153
- export function deactivate ( ) {
154
- }
155
- class PythonExt {
152
+ class PythonExt implements vscode . Disposable {
156
153
157
- private _isDjangoProject : ContextKey ;
154
+ private isDjangoProject : ContextKey ;
158
155
159
156
constructor ( ) {
160
- this . _isDjangoProject = new ContextKey ( 'python.isDjangoProject' ) ;
161
- this . _ensureState ( ) ;
157
+ this . isDjangoProject = new ContextKey ( 'python.isDjangoProject' ) ;
158
+ this . ensureState ( ) ;
162
159
}
163
-
164
- private _ensureState ( ) : void {
160
+ public dispose ( ) {
161
+ this . isDjangoProject = null ;
162
+ }
163
+ private ensureState ( ) : void {
165
164
// context: python.isDjangoProject
166
165
if ( typeof vscode . workspace . rootPath === 'string' ) {
167
- this . _isDjangoProject . set ( fs . existsSync ( vscode . workspace . rootPath . concat ( "/manage.py" ) ) ) ;
166
+ this . isDjangoProject . set ( fs . existsSync ( vscode . workspace . rootPath . concat ( "/manage.py" ) ) ) ;
168
167
}
169
168
else {
170
- this . _isDjangoProject . set ( false ) ;
169
+ this . isDjangoProject . set ( false ) ;
171
170
}
172
171
}
173
172
}
174
173
175
174
class ContextKey {
176
- private _name : string ;
177
- private _lastValue : boolean ;
175
+ private lastValue : boolean ;
178
176
179
- constructor ( name : string ) {
180
- this . _name = name ;
177
+ constructor ( private name : string ) {
181
178
}
182
179
183
180
public set ( value : boolean ) : void {
184
- if ( this . _lastValue === value ) {
181
+ if ( this . lastValue === value ) {
185
182
return ;
186
183
}
187
- this . _lastValue = value ;
188
- vscode . commands . executeCommand ( 'setContext' , this . _name , this . _lastValue ) ;
184
+ this . lastValue = value ;
185
+ vscode . commands . executeCommand ( 'setContext' , this . name , this . lastValue ) ;
189
186
}
190
187
}
0 commit comments