Skip to content

Remove unused code #15718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/3 Code Health/15717.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unused code from extension.
7 changes: 1 addition & 6 deletions src/client/activation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ export interface ILanguageServerPackageService {
getLanguageServerDownloadChannel(): LanguageServerDownloadChannels;
}

export const MajorLanguageServerVersion = Symbol('MajorLanguageServerVersion');
export const IDownloadChannelRule = Symbol('IDownloadChannelRule');
export interface IDownloadChannelRule {
shouldLookForNewLanguageServer(currentFolder?: FolderVersionPair): Promise<boolean>;
Expand All @@ -144,11 +143,7 @@ export const ILanguageServerCompatibilityService = Symbol('ILanguageServerCompat
export interface ILanguageServerCompatibilityService {
isSupported(): Promise<boolean>;
}
export enum LanguageClientFactory {
base = 'base',
simple = 'simple',
downloaded = 'downloaded',
}

export const ILanguageClientFactory = Symbol('ILanguageClientFactory');
export interface ILanguageClientFactory {
createLanguageClient(
Expand Down
5 changes: 0 additions & 5 deletions src/client/application/diagnostics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ export enum DiagnosticScope {
WorkspaceFolder = 'WorkspaceFolder',
}

export enum DiagnosticIgnoreScope {
always = 'always',
session = 'session',
}

export interface IDiagnostic {
readonly code: DiagnosticCodes;
readonly message: string;
Expand Down
5 changes: 0 additions & 5 deletions src/client/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
export const PYTHON_LANGUAGE = 'python';
export const MARKDOWN_LANGUAGE = 'markdown';
export const JUPYTER_LANGUAGE = 'jupyter';

export const PYTHON_WARNINGS = 'PYTHONWARNINGS';

export const NotebookCellScheme = 'vscode-notebook-cell';
Expand All @@ -11,7 +8,6 @@ export const PYTHON = [
{ scheme: 'vscode-notebook', language: PYTHON_LANGUAGE },
{ scheme: NotebookCellScheme, language: PYTHON_LANGUAGE },
];
export const PYTHON_ALLFILES = [{ language: PYTHON_LANGUAGE }];

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

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

export * from '../constants';
7 changes: 1 addition & 6 deletions src/client/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,7 @@ export function getWorkspaceEditsFromPatch(

return workspaceEdit;
}
export function getTextEdits(before: string, after: string): TextEdit[] {
const dmp = require('diff-match-patch') as typeof import('diff-match-patch');
const d = new dmp.diff_match_patch();
const diffs = d.diff_main(before, after);
return getTextEditsInternal(before, diffs).map((edit) => edit.apply());
}

function getTextEditsInternal(before: string, diffs: [number, string][], startLine: number = 0): Edit[] {
let line = startLine;
let character = 0;
Expand Down
17 changes: 0 additions & 17 deletions src/client/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

'use strict';

import { isTestExecution } from './constants';
import { ModuleNotInstalledError } from './errors/moduleNotInstalledError';

export function isNotInstalledError(error: Error): boolean {
Expand All @@ -20,19 +19,3 @@ export function isNotInstalledError(error: Error): boolean {
const isModuleNoInstalledError = error.message.indexOf('No module named') >= 0;
return errorObj.code === 'ENOENT' || errorObj.code === 127 || isModuleNoInstalledError;
}

export function skipIfTest(isAsyncFunction: boolean) {
return function (_: Object, __: string, descriptor: TypedPropertyDescriptor<any>) {
const originalMethod = descriptor.value;

descriptor.value = function (...args: any[]) {
if (isTestExecution()) {
return isAsyncFunction ? Promise.resolve() : undefined;
}

return originalMethod.apply(this, args);
};

return descriptor;
};
}
84 changes: 0 additions & 84 deletions src/client/common/open.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/client/common/platform/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,3 @@ export function isNoPermissionsError(err: Error): boolean | undefined {
}
return isSystemError(err, 'EACCES');
}

// Return true if the given error is ENOTEMPTY.
export function isDirNotEmptyError(err: Error): boolean | undefined {
return isSystemError(err, 'ENOTEMPTY');
}
3 changes: 0 additions & 3 deletions src/client/common/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export interface IRegistry {
//= ==========================
// platform

export const IsWindows = Symbol('IS_WINDOWS');

export const IPlatformService = Symbol('IPlatformService');
export interface IPlatformService {
readonly osType: OSType;
Expand All @@ -45,7 +43,6 @@ export interface IPlatformService {
// temp FS

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

export interface ITempFileSystem {
createFile(suffix: string, mode?: number): Promise<TemporaryFile>;
Expand Down
14 changes: 0 additions & 14 deletions src/client/common/process/internal/scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,20 +297,6 @@ export function printEnvVariables(): [string[], (out: string) => NodeJS.ProcessE
return [args, parse];
}

//============================
// printEnvVariablesToFile.py

export function printEnvVariablesToFile(filename: string): [string[], (out: string) => NodeJS.ProcessEnv] {
const script = path.join(SCRIPTS_DIR, 'printEnvVariablesToFile.py');
const args = maybeIsolated([script, filename.fileToCommandArgument()]);

function parse(out: string): NodeJS.ProcessEnv {
return JSON.parse(out);
}

return [args, parse];
}

//============================
// shell_exec.py

Expand Down
5 changes: 0 additions & 5 deletions src/client/common/process/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { CancellationToken, Uri } from 'vscode';
import { PythonExecInfo } from '../../pythonEnvironments/exec';
import { InterpreterInformation, PythonEnvironment } from '../../pythonEnvironments/info';
import { ExecutionInfo, IDisposable } from '../types';
import { EnvironmentVariables } from '../variables/types';

export const IBufferDecoder = Symbol('IBufferDecoder');
export interface IBufferDecoder {
Expand Down Expand Up @@ -105,10 +104,6 @@ export class StdErrError extends Error {
}
}

export interface IExecutionEnvironmentVariablesService {
getEnvironmentVariables(resource?: Uri): Promise<EnvironmentVariables | undefined>;
}

export const IPythonToolExecutionService = Symbol('IPythonToolRunnerService');

export interface IPythonToolExecutionService {
Expand Down
11 changes: 0 additions & 11 deletions src/client/common/refBool.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ export interface IPersistentState<T> {
readonly value: T;
updateValue(value: T): Promise<void>;
}
export type Version = {
raw: string;
major: number;
minor: number;
patch: number;
build: string[];
prerelease: string[];
};

export type ReadWrite<T> = {
-readonly [P in keyof T]: T[P];
Expand Down Expand Up @@ -349,12 +341,6 @@ export interface IAnalysisSettings {
readonly logLevel: AnalysisSettingsLogLevel;
}

export interface IVariableQuery {
language: string;
query: string;
parseExpr: string;
}

export const IConfigurationService = Symbol('IConfigurationService');
export interface IConfigurationService {
getSettings(resource?: Uri): IPythonSettings;
Expand Down
18 changes: 0 additions & 18 deletions src/client/common/utils/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@ export async function sleep(timeout: number): Promise<number> {
});
}

export async function waitForPromise<T>(promise: Promise<T>, timeout: number): Promise<T | null> {
// Set a timer that will resolve with null
return new Promise<T | null>((resolve, reject) => {
const timer = setTimeout(() => resolve(null), timeout);
promise
.then((result) => {
// When the promise resolves, make sure to clear the timer or
// the timer may stick around causing tests to wait
clearTimeout(timer);
resolve(result);
})
.catch((e) => {
clearTimeout(timer);
reject(e);
});
});
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
export function isThenable<T>(v: any): v is Thenable<T> {
return typeof v?.then === 'function';
Expand Down
19 changes: 0 additions & 19 deletions src/client/common/utils/decorators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ProgressLocation, ProgressOptions, window } from 'vscode';
import '../../common/extensions';
import { isTestExecution } from '../constants';
import { traceError, traceVerbose } from '../logger';
Expand Down Expand Up @@ -187,24 +186,6 @@ export function swallowExceptions(scopeName?: string) {
};
}

type PromiseFunction = (...any: any[]) => Promise<any>;

export function displayProgress(title: string, location = ProgressLocation.Window) {
return function (_target: Object, _propertyName: string, descriptor: TypedPropertyDescriptor<PromiseFunction>) {
const originalMethod = descriptor.value!;

descriptor.value = async function (...args: any[]) {
const progressOptions: ProgressOptions = { location, title };

const promise = originalMethod.apply(this, args);
if (!isTestExecution()) {
window.withProgress(progressOptions, () => promise);
}
return promise;
};
};
}

// Information about a function/method call.
export type CallInfo = {
kind: string; // "Class", etc.
Expand Down
Loading