Skip to content

Commit a478613

Browse files
authored
Remove unused code (#15718)
1 parent 8312254 commit a478613

File tree

39 files changed

+7
-898
lines changed

39 files changed

+7
-898
lines changed

news/3 Code Health/15717.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove unused code from extension.

src/client/activation/types.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ export interface ILanguageServerPackageService {
135135
getLanguageServerDownloadChannel(): LanguageServerDownloadChannels;
136136
}
137137

138-
export const MajorLanguageServerVersion = Symbol('MajorLanguageServerVersion');
139138
export const IDownloadChannelRule = Symbol('IDownloadChannelRule');
140139
export interface IDownloadChannelRule {
141140
shouldLookForNewLanguageServer(currentFolder?: FolderVersionPair): Promise<boolean>;
@@ -144,11 +143,7 @@ export const ILanguageServerCompatibilityService = Symbol('ILanguageServerCompat
144143
export interface ILanguageServerCompatibilityService {
145144
isSupported(): Promise<boolean>;
146145
}
147-
export enum LanguageClientFactory {
148-
base = 'base',
149-
simple = 'simple',
150-
downloaded = 'downloaded',
151-
}
146+
152147
export const ILanguageClientFactory = Symbol('ILanguageClientFactory');
153148
export interface ILanguageClientFactory {
154149
createLanguageClient(

src/client/application/diagnostics/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ export enum DiagnosticScope {
1313
WorkspaceFolder = 'WorkspaceFolder',
1414
}
1515

16-
export enum DiagnosticIgnoreScope {
17-
always = 'always',
18-
session = 'session',
19-
}
20-
2116
export interface IDiagnostic {
2217
readonly code: DiagnosticCodes;
2318
readonly message: string;

src/client/common/constants.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
export const PYTHON_LANGUAGE = 'python';
2-
export const MARKDOWN_LANGUAGE = 'markdown';
3-
export const JUPYTER_LANGUAGE = 'jupyter';
4-
52
export const PYTHON_WARNINGS = 'PYTHONWARNINGS';
63

74
export const NotebookCellScheme = 'vscode-notebook-cell';
@@ -11,7 +8,6 @@ export const PYTHON = [
118
{ scheme: 'vscode-notebook', language: PYTHON_LANGUAGE },
129
{ scheme: NotebookCellScheme, language: PYTHON_LANGUAGE },
1310
];
14-
export const PYTHON_ALLFILES = [{ language: PYTHON_LANGUAGE }];
1511

1612
export const PVSC_EXTENSION_ID = 'ms-python.python';
1713
export const CODE_RUNNER_EXTENSION_ID = 'formulahendry.code-runner';
@@ -115,7 +111,6 @@ export function isUnitTestExecution(): boolean {
115111

116112
// Temporary constant, used to indicate whether we're using custom editor api or not.
117113
export const UseCustomEditorApi = Symbol('USE_CUSTOM_EDITOR');
118-
export const UseVSCodeNotebookEditorApi = Symbol('USE_NATIVEEDITOR');
119114
export const UseProposedApi = Symbol('USE_VSC_PROPOSED_API');
120115

121116
export * from '../constants';

src/client/common/editor.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,7 @@ export function getWorkspaceEditsFromPatch(
158158

159159
return workspaceEdit;
160160
}
161-
export function getTextEdits(before: string, after: string): TextEdit[] {
162-
const dmp = require('diff-match-patch') as typeof import('diff-match-patch');
163-
const d = new dmp.diff_match_patch();
164-
const diffs = d.diff_main(before, after);
165-
return getTextEditsInternal(before, diffs).map((edit) => edit.apply());
166-
}
161+
167162
function getTextEditsInternal(before: string, diffs: [number, string][], startLine: number = 0): Edit[] {
168163
let line = startLine;
169164
let character = 0;

src/client/common/helpers.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
'use strict';
55

6-
import { isTestExecution } from './constants';
76
import { ModuleNotInstalledError } from './errors/moduleNotInstalledError';
87

98
export function isNotInstalledError(error: Error): boolean {
@@ -20,19 +19,3 @@ export function isNotInstalledError(error: Error): boolean {
2019
const isModuleNoInstalledError = error.message.indexOf('No module named') >= 0;
2120
return errorObj.code === 'ENOENT' || errorObj.code === 127 || isModuleNoInstalledError;
2221
}
23-
24-
export function skipIfTest(isAsyncFunction: boolean) {
25-
return function (_: Object, __: string, descriptor: TypedPropertyDescriptor<any>) {
26-
const originalMethod = descriptor.value;
27-
28-
descriptor.value = function (...args: any[]) {
29-
if (isTestExecution()) {
30-
return isAsyncFunction ? Promise.resolve() : undefined;
31-
}
32-
33-
return originalMethod.apply(this, args);
34-
};
35-
36-
return descriptor;
37-
};
38-
}

src/client/common/open.ts

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/client/common/platform/errors.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,3 @@ export function isNoPermissionsError(err: Error): boolean | undefined {
140140
}
141141
return isSystemError(err, 'EACCES');
142142
}
143-
144-
// Return true if the given error is ENOTEMPTY.
145-
export function isDirNotEmptyError(err: Error): boolean | undefined {
146-
return isSystemError(err, 'ENOTEMPTY');
147-
}

src/client/common/platform/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ export interface IRegistry {
2424
//= ==========================
2525
// platform
2626

27-
export const IsWindows = Symbol('IS_WINDOWS');
28-
2927
export const IPlatformService = Symbol('IPlatformService');
3028
export interface IPlatformService {
3129
readonly osType: OSType;
@@ -45,7 +43,6 @@ export interface IPlatformService {
4543
// temp FS
4644

4745
export type TemporaryFile = { filePath: string } & vscode.Disposable;
48-
export type TemporaryDirectory = { path: string } & vscode.Disposable;
4946

5047
export interface ITempFileSystem {
5148
createFile(suffix: string, mode?: number): Promise<TemporaryFile>;

src/client/common/process/internal/scripts/index.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -297,20 +297,6 @@ export function printEnvVariables(): [string[], (out: string) => NodeJS.ProcessE
297297
return [args, parse];
298298
}
299299

300-
//============================
301-
// printEnvVariablesToFile.py
302-
303-
export function printEnvVariablesToFile(filename: string): [string[], (out: string) => NodeJS.ProcessEnv] {
304-
const script = path.join(SCRIPTS_DIR, 'printEnvVariablesToFile.py');
305-
const args = maybeIsolated([script, filename.fileToCommandArgument()]);
306-
307-
function parse(out: string): NodeJS.ProcessEnv {
308-
return JSON.parse(out);
309-
}
310-
311-
return [args, parse];
312-
}
313-
314300
//============================
315301
// shell_exec.py
316302

src/client/common/process/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { CancellationToken, Uri } from 'vscode';
77
import { PythonExecInfo } from '../../pythonEnvironments/exec';
88
import { InterpreterInformation, PythonEnvironment } from '../../pythonEnvironments/info';
99
import { ExecutionInfo, IDisposable } from '../types';
10-
import { EnvironmentVariables } from '../variables/types';
1110

1211
export const IBufferDecoder = Symbol('IBufferDecoder');
1312
export interface IBufferDecoder {
@@ -105,10 +104,6 @@ export class StdErrError extends Error {
105104
}
106105
}
107106

108-
export interface IExecutionEnvironmentVariablesService {
109-
getEnvironmentVariables(resource?: Uri): Promise<EnvironmentVariables | undefined>;
110-
}
111-
112107
export const IPythonToolExecutionService = Symbol('IPythonToolRunnerService');
113108

114109
export interface IPythonToolExecutionService {

src/client/common/refBool.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/client/common/types.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ export interface IPersistentState<T> {
4141
readonly value: T;
4242
updateValue(value: T): Promise<void>;
4343
}
44-
export type Version = {
45-
raw: string;
46-
major: number;
47-
minor: number;
48-
patch: number;
49-
build: string[];
50-
prerelease: string[];
51-
};
5244

5345
export type ReadWrite<T> = {
5446
-readonly [P in keyof T]: T[P];
@@ -348,12 +340,6 @@ export interface IAnalysisSettings {
348340
readonly logLevel: AnalysisSettingsLogLevel;
349341
}
350342

351-
export interface IVariableQuery {
352-
language: string;
353-
query: string;
354-
parseExpr: string;
355-
}
356-
357343
export const IConfigurationService = Symbol('IConfigurationService');
358344
export interface IConfigurationService {
359345
getSettings(resource?: Uri): IPythonSettings;

src/client/common/utils/async.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,6 @@ export async function sleep(timeout: number): Promise<number> {
99
});
1010
}
1111

12-
export async function waitForPromise<T>(promise: Promise<T>, timeout: number): Promise<T | null> {
13-
// Set a timer that will resolve with null
14-
return new Promise<T | null>((resolve, reject) => {
15-
const timer = setTimeout(() => resolve(null), timeout);
16-
promise
17-
.then((result) => {
18-
// When the promise resolves, make sure to clear the timer or
19-
// the timer may stick around causing tests to wait
20-
clearTimeout(timer);
21-
resolve(result);
22-
})
23-
.catch((e) => {
24-
clearTimeout(timer);
25-
reject(e);
26-
});
27-
});
28-
}
29-
3012
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
3113
export function isThenable<T>(v: any): v is Thenable<T> {
3214
return typeof v?.then === 'function';

src/client/common/utils/decorators.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { ProgressLocation, ProgressOptions, window } from 'vscode';
21
import '../../common/extensions';
32
import { isTestExecution } from '../constants';
43
import { traceError, traceVerbose } from '../logger';
@@ -187,24 +186,6 @@ export function swallowExceptions(scopeName?: string) {
187186
};
188187
}
189188

190-
type PromiseFunction = (...any: any[]) => Promise<any>;
191-
192-
export function displayProgress(title: string, location = ProgressLocation.Window) {
193-
return function (_target: Object, _propertyName: string, descriptor: TypedPropertyDescriptor<PromiseFunction>) {
194-
const originalMethod = descriptor.value!;
195-
196-
descriptor.value = async function (...args: any[]) {
197-
const progressOptions: ProgressOptions = { location, title };
198-
199-
const promise = originalMethod.apply(this, args);
200-
if (!isTestExecution()) {
201-
window.withProgress(progressOptions, () => promise);
202-
}
203-
return promise;
204-
};
205-
};
206-
}
207-
208189
// Information about a function/method call.
209190
export type CallInfo = {
210191
kind: string; // "Class", etc.

0 commit comments

Comments
 (0)