Skip to content

Commit

Permalink
remove some unused exports
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Ronde committed Oct 6, 2024
1 parent d9024c8 commit 7813169
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 85 deletions.
18 changes: 1 addition & 17 deletions client/src/lib/errorUtil.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
import { window, type ExtensionContext } from 'vscode';
import { ERROR_PREFIX, log } from './log';

const shownWarnings: Set<string> = 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;
Expand Down
4 changes: 2 additions & 2 deletions client/src/lib/multiStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,7 +79,7 @@ export class MultiStepEntry {
}
}

export class MultiStepper {
class MultiStepper {
private _currentStepIndex = 0;
private _disposables: Disposable[] = [];
private _values: (string | undefined)[] = [];
Expand Down
6 changes: 3 additions & 3 deletions client/src/lib/multiStepInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import { window, QuickInputButtons } from 'vscode';

export type InputStep = (input: MultiStepInput) => Thenable<InputStep | void>;

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;
Expand All @@ -25,7 +25,7 @@ export interface MultiStepInputParameters {
placeholder?: string;
}

export interface InputBoxParameters extends MultiStepInputParameters {
interface InputBoxParameters extends MultiStepInputParameters {
value: string;
prompt: string;
password?: boolean;
Expand Down
23 changes: 0 additions & 23 deletions server/src/lib/editorConfig.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -63,25 +62,3 @@ export async function getEditorConfiguration(
false,
};
}

export function onChangeEditorConfiguration<
K extends keyof Omit<ConfigSettingsWithoutPrefix, 'enableLanguageServer'>,
>(
classConfig: Pick<
ClassConfig,
'connection' | 'workspaceFolders' | 'editorConfigOverride'
>,
key: K,
handler: (
value: Omit<ConfigSettingsWithoutPrefix, 'enableLanguageServer'>[K]
) => void
): Disposable {
void getEditorConfiguration(classConfig).then((editorConfig) => {
handler(editorConfig[key]);
});
return classConfig.connection.onDidChangeConfiguration(() => {
void getEditorConfiguration(classConfig).then((editorConfig) => {
handler(editorConfig[key]);
});
});
}
2 changes: 1 addition & 1 deletion shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
41 changes: 2 additions & 39 deletions shared/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,6 @@ import { constants } from 'fs';
import * as path from 'path';
import * as os from 'os';

export function deepObjectJoin<A, B>(objA: A, objB: B): A & B {
const result: Partial<A & B> = {};
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
*/
Expand Down Expand Up @@ -131,13 +104,6 @@ export function toCheckablePromise<R>(promise: Promise<R>): {
};
}

export function normalizePath(filePath: string): string {
if (process.platform !== 'win32') {
return filePath;
}
return filePath.replace(/\\/g, '/');
}

export async function pathExists(filePath: string): Promise<boolean> {
try {
await fs.access(filePath, constants.R_OK);
Expand All @@ -147,7 +113,7 @@ export async function pathExists(filePath: string): Promise<boolean> {
}
}

export async function tryReadFile(filePath: string): Promise<string | null> {
async function tryReadFile(filePath: string): Promise<string | null> {
try {
const contents = await fs.readFile(filePath, 'utf-8');
return contents;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 7813169

Please sign in to comment.