File tree Expand file tree Collapse file tree 5 files changed +14
-26
lines changed Expand file tree Collapse file tree 5 files changed +14
-26
lines changed Original file line number Diff line number Diff line change 11const commandPrefix = 'oxc' ;
22
33export const enum OxcCommands {
4- RestartServer = `${ commandPrefix } .restartServer` ,
54 ShowOutputChannel = `${ commandPrefix } .showOutputChannel` ,
6- ToggleEnable = `${ commandPrefix } .toggleEnable` ,
75 // only for linter.ts usage
6+ RestartServer = `${ commandPrefix } .restartServer` ,
7+ ToggleEnable = `${ commandPrefix } .toggleEnable` ,
88 ApplyAllFixesFile = `${ commandPrefix } .applyAllFixesFile` ,
99}
Original file line number Diff line number Diff line change @@ -15,20 +15,10 @@ export async function activate(context: ExtensionContext) {
1515 log : true ,
1616 } ) ;
1717
18- const restartCommand = commands . registerCommand ( OxcCommands . RestartServer , async ( ) => {
19- await linter . restartClient ( ) ;
20- } ) ;
21-
2218 const showOutputCommand = commands . registerCommand ( OxcCommands . ShowOutputChannel , ( ) => {
2319 outputChannel . show ( ) ;
2420 } ) ;
2521
26- const toggleEnable = commands . registerCommand ( OxcCommands . ToggleEnable , async ( ) => {
27- await configService . vsCodeConfig . updateEnable ( ! configService . vsCodeConfig . enable ) ;
28-
29- await linter . toggleClient ( configService ) ;
30- } ) ;
31-
3222 const onDidChangeWorkspaceFoldersDispose = workspace . onDidChangeWorkspaceFolders ( async ( event ) => {
3323 for ( const folder of event . added ) {
3424 configService . addWorkspaceConfig ( folder ) ;
@@ -41,9 +31,7 @@ export async function activate(context: ExtensionContext) {
4131 const statusBarItemHandler = new StatusBarItemHandler ( context . extension . packageJSON ?. version ) ;
4232
4333 context . subscriptions . push (
44- restartCommand ,
4534 showOutputCommand ,
46- toggleEnable ,
4735 configService ,
4836 outputChannel ,
4937 onDidChangeWorkspaceFoldersDispose ,
Original file line number Diff line number Diff line change @@ -27,16 +27,6 @@ export default interface ToolInterface {
2727 */
2828 deactivate ( ) : Promise < void > ;
2929
30- /**
31- * Toggles the tool's active state based on configuration.
32- */
33- toggleClient ( configService : ConfigService ) : Promise < void > ;
34-
35- /**
36- * Restart the tool.
37- */
38- restartClient ( ) : Promise < void > ;
39-
4030 /**
4131 * Handles configuration changes.
4232 */
Original file line number Diff line number Diff line change @@ -58,6 +58,16 @@ export default class LinterTool implements ToolInterface {
5858 ? ( await workspace . findFiles ( `**/.oxlintrc.json` , '**/node_modules/**' , 1 ) ) . length > 0
5959 : true ;
6060
61+ const restartCommand = commands . registerCommand ( OxcCommands . RestartServer , async ( ) => {
62+ await this . restartClient ( ) ;
63+ } ) ;
64+
65+ const toggleEnable = commands . registerCommand ( OxcCommands . ToggleEnable , async ( ) => {
66+ await configService . vsCodeConfig . updateEnable ( ! configService . vsCodeConfig . enable ) ;
67+
68+ await this . toggleClient ( configService ) ;
69+ } ) ;
70+
6171 const applyAllFixesFile = commands . registerCommand ( OxcCommands . ApplyAllFixesFile , async ( ) => {
6272 if ( ! this . client ) {
6373 window . showErrorMessage ( 'oxc client not found' ) ;
@@ -81,7 +91,7 @@ export default class LinterTool implements ToolInterface {
8191 await this . client . sendRequest ( ExecuteCommandRequest . type , params ) ;
8292 } ) ;
8393
84- context . subscriptions . push ( applyAllFixesFile ) ;
94+ context . subscriptions . push ( restartCommand , toggleEnable , applyAllFixesFile ) ;
8595
8696 const run : Executable = runExecutable ( binaryPath , configService . vsCodeConfig . nodePath ) ;
8797 const serverOptions : ServerOptions = {
Original file line number Diff line number Diff line change @@ -36,8 +36,8 @@ suite('commands', () => {
3636 ] ;
3737
3838 deepStrictEqual ( [
39- 'oxc.restartServer' ,
4039 'oxc.showOutputChannel' ,
40+ 'oxc.restartServer' ,
4141 'oxc.toggleEnable' ,
4242 'oxc.applyAllFixesFile' , // TODO: only if linter tests are enabled
4343 ...extraCommands ,
You can’t perform that action at this time.
0 commit comments