From 78131699687e5b176648152475d38439b47c7902 Mon Sep 17 00:00:00 2001 From: Sander Ronde Date: Sun, 6 Oct 2024 14:39:12 +0200 Subject: [PATCH] remove some unused exports --- client/src/lib/errorUtil.ts | 18 +------------- client/src/lib/multiStep.ts | 4 ++-- client/src/lib/multiStepInput.ts | 6 ++--- server/src/lib/editorConfig.ts | 23 ------------------ shared/constants.ts | 2 +- shared/util.ts | 41 ++------------------------------ 6 files changed, 9 insertions(+), 85 deletions(-) diff --git a/client/src/lib/errorUtil.ts b/client/src/lib/errorUtil.ts index ed8bdb6..f789e80 100644 --- a/client/src/lib/errorUtil.ts +++ b/client/src/lib/errorUtil.ts @@ -1,20 +1,4 @@ -import { window, type ExtensionContext } from 'vscode'; -import { ERROR_PREFIX, log } from './log'; - -const shownWarnings: Set = new Set(); - -export function showErrorOnce( - context: ExtensionContext, - message: string, - ...extra: string[] -): void { - log(context, ERROR_PREFIX, message, ...extra); - if (shownWarnings.has(message)) { - return; - } - showError(message); - shownWarnings.add(message); -} +import { window } from 'vscode'; interface ErrorOption { title: string; diff --git a/client/src/lib/multiStep.ts b/client/src/lib/multiStep.ts index cd18b1d..7863f07 100644 --- a/client/src/lib/multiStep.ts +++ b/client/src/lib/multiStep.ts @@ -3,7 +3,7 @@ import type { Disposable, InputBox } from 'vscode'; type GettableValue = string | ((stepper: MultiStepper) => string); -export class MultiStepEntry { +class MultiStepEntry { public constructor( public settings: { placeHolder?: GettableValue; @@ -79,7 +79,7 @@ export class MultiStepEntry { } } -export class MultiStepper { +class MultiStepper { private _currentStepIndex = 0; private _disposables: Disposable[] = []; private _values: (string | undefined)[] = []; diff --git a/client/src/lib/multiStepInput.ts b/client/src/lib/multiStepInput.ts index b9cf457..4dd2755 100644 --- a/client/src/lib/multiStepInput.ts +++ b/client/src/lib/multiStepInput.ts @@ -8,14 +8,14 @@ import { window, QuickInputButtons } from 'vscode'; export type InputStep = (input: MultiStepInput) => Thenable; -export class InputFlowAction { +class InputFlowAction { private constructor() {} public static Back = new InputFlowAction(); public static Cancel = new InputFlowAction(); public static Resume = new InputFlowAction(); } -export interface MultiStepInputParameters { +interface MultiStepInputParameters { title: string; step?: number; totalSteps?: number; @@ -25,7 +25,7 @@ export interface MultiStepInputParameters { placeholder?: string; } -export interface InputBoxParameters extends MultiStepInputParameters { +interface InputBoxParameters extends MultiStepInputParameters { value: string; prompt: string; password?: boolean; diff --git a/server/src/lib/editorConfig.ts b/server/src/lib/editorConfig.ts index 82d85cb..f9cfe8c 100644 --- a/server/src/lib/editorConfig.ts +++ b/server/src/lib/editorConfig.ts @@ -1,6 +1,5 @@ import { replaceHomeDir, replaceVariables } from '../../../shared/variables'; import type { ConfigSettingsWithoutPrefix } from '../../../shared/config'; -import type { Disposable } from 'vscode-languageserver'; import { fromEntries } from '../../../shared/util'; import type { ClassConfig } from './types'; @@ -63,25 +62,3 @@ export async function getEditorConfiguration( false, }; } - -export function onChangeEditorConfiguration< - K extends keyof Omit, ->( - classConfig: Pick< - ClassConfig, - 'connection' | 'workspaceFolders' | 'editorConfigOverride' - >, - key: K, - handler: ( - value: Omit[K] - ) => void -): Disposable { - void getEditorConfiguration(classConfig).then((editorConfig) => { - handler(editorConfig[key]); - }); - return classConfig.connection.onDidChangeConfiguration(() => { - void getEditorConfiguration(classConfig).then((editorConfig) => { - handler(editorConfig[key]); - }); - }); -} diff --git a/shared/constants.ts b/shared/constants.ts index 6807f98..0e9eafb 100644 --- a/shared/constants.ts +++ b/shared/constants.ts @@ -5,7 +5,7 @@ export const EXTENSION_ID = 'sanderronde.phpstan-vscode'; // through an action as VSCode cancels long-running operations export const NO_CANCEL_OPERATIONS = false; // This file will end up in root/out/ so it's just one level back -export const ROOT_FOLDER = path.join(__dirname, '..'); +const ROOT_FOLDER = path.join(__dirname, '..'); export const MAX_HOVER_WAIT_TIME = 60000; export const HOVER_WAIT_CHUNK_TIME = 50; export const TREE_FETCHER_FILE = path.join(ROOT_FOLDER, 'php/TreeFetcher.php'); diff --git a/shared/util.ts b/shared/util.ts index c184f9e..13e5fe9 100644 --- a/shared/util.ts +++ b/shared/util.ts @@ -11,33 +11,6 @@ import { constants } from 'fs'; import * as path from 'path'; import * as os from 'os'; -export function deepObjectJoin(objA: A, objB: B): A & B { - const result: Partial = {}; - for (const key in objA) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - result[key] = objA[key] as any; - } - for (const key in objB) { - if (key in result) { - // Already set - if (typeof objB[key] === 'object' && objB[key]) { - result[key] = deepObjectJoin( - objA[key as unknown as keyof A], - objB[key] - // eslint-disable-next-line @typescript-eslint/no-explicit-any - ) as any; - } else { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - result[key] = objB[key] as any; - } - } else { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - result[key] = objB[key] as any; - } - } - return result as A & B; -} - /** * Assert that forces TS to check whether a route is reachable */ @@ -131,13 +104,6 @@ export function toCheckablePromise(promise: Promise): { }; } -export function normalizePath(filePath: string): string { - if (process.platform !== 'win32') { - return filePath; - } - return filePath.replace(/\\/g, '/'); -} - export async function pathExists(filePath: string): Promise { try { await fs.access(filePath, constants.R_OK); @@ -147,7 +113,7 @@ export async function pathExists(filePath: string): Promise { } } -export async function tryReadFile(filePath: string): Promise { +async function tryReadFile(filePath: string): Promise { try { const contents = await fs.readFile(filePath, 'utf-8'); return contents; @@ -195,10 +161,7 @@ export async function getConfigFile( return null; } -export function getAbsolutePath( - filePath: string | null, - cwd?: string -): string | null { +function getAbsolutePath(filePath: string | null, cwd?: string): string | null { if (!filePath) { return null; }