Skip to content
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
19 changes: 7 additions & 12 deletions editors/vscode/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ import { commands, ExtensionContext, window, workspace } from 'vscode';

import { OxcCommands } from './commands';
import { ConfigService } from './ConfigService';
import {
activate as activateLinter,
deactivate as deactivateLinter,
onConfigChange as onConfigChangeLinter,
restartClient,
toggleClient,
} from './linter';
import StatusBarItemHandler from './StatusBarItemHandler';
import Linter from './tools/linter';

const outputChannelName = 'Oxc';
const linter = new Linter();

export async function activate(context: ExtensionContext) {
const configService = new ConfigService();
Expand All @@ -21,7 +16,7 @@ export async function activate(context: ExtensionContext) {
});

const restartCommand = commands.registerCommand(OxcCommands.RestartServer, async () => {
await restartClient();
await linter.restartClient();
});

const showOutputCommand = commands.registerCommand(OxcCommands.ShowOutputChannel, () => {
Expand All @@ -31,7 +26,7 @@ export async function activate(context: ExtensionContext) {
const toggleEnable = commands.registerCommand(OxcCommands.ToggleEnable, async () => {
await configService.vsCodeConfig.updateEnable(!configService.vsCodeConfig.enable);

await toggleClient(configService);
await linter.toggleClient(configService);
});

const onDidChangeWorkspaceFoldersDispose = workspace.onDidChangeWorkspaceFolders(async (event) => {
Expand All @@ -56,14 +51,14 @@ export async function activate(context: ExtensionContext) {
);

configService.onConfigChange = async function onConfigChange(event) {
await onConfigChangeLinter(event, configService, statusBarItemHandler);
await linter.onConfigChange(event, configService, statusBarItemHandler);
};

await activateLinter(context, outputChannel, configService, statusBarItemHandler);
await linter.activate(context, outputChannel, configService, statusBarItemHandler);
// Show status bar item after activation
statusBarItemHandler.show();
}

export async function deactivate(): Promise<void> {
await deactivateLinter();
await linter.deactivate();
}
283 changes: 0 additions & 283 deletions editors/vscode/client/linter.ts

This file was deleted.

39 changes: 39 additions & 0 deletions editors/vscode/client/tools/ToolInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ConfigurationChangeEvent, ExtensionContext, LogOutputChannel } from 'vscode';
import { ConfigService } from '../ConfigService';
import StatusBarItemHandler from '../StatusBarItemHandler';

export default interface ToolInterface {
/**
* Activates the tool and initializes any necessary resources.
*/
activate(
context: ExtensionContext,
outputChannel: LogOutputChannel,
configService: ConfigService,
statusBarItemHandler: StatusBarItemHandler,
): Promise<void>;

/**
* Deactivates the tool and cleans up any resources.
*/
deactivate(): Promise<void>;

/**
* Toggles the tool's active state based on configuration.
*/
toggleClient(configService: ConfigService): Promise<void>;

/**
* Restart the tool.
*/
restartClient(): Promise<void>;

/**
* Handles configuration changes.
*/
onConfigChange(
event: ConfigurationChangeEvent,
configService: ConfigService,
statusBarItemHandler: StatusBarItemHandler,
): Promise<void>;
}
Loading
Loading