Skip to content

Commit 7ab7287

Browse files
committed
Remove command prefix
This removes generating a command prefix for the language client connecting to terraform-ls. This also removes registering prefixed commands to terraform-ls.
1 parent a8b4cea commit 7ab7287

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

src/clientHandler.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { config } from './vscodeUtils';
1717
import { CustomSemanticTokens } from './semanticTokens';
1818

1919
export interface TerraformLanguageClient {
20-
commandPrefix: string;
2120
client: LanguageClient;
2221
}
2322

@@ -65,9 +64,7 @@ export class ClientHandler {
6564
}
6665

6766
private async createTerraformClient(): Promise<TerraformLanguageClient> {
68-
const commandPrefix = this.shortUid.seq();
69-
70-
const initializationOptions = this.getInitializationOptions(commandPrefix);
67+
const initializationOptions = this.getInitializationOptions();
7168

7269
const serverOptions = await this.getServerOptions();
7370

@@ -110,7 +107,7 @@ export class ClientHandler {
110107
}
111108
});
112109

113-
return { commandPrefix, client };
110+
return { client };
114111
}
115112

116113
private async getServerOptions(): Promise<ServerOptions> {
@@ -129,7 +126,7 @@ export class ClientHandler {
129126
return serverOptions;
130127
}
131128

132-
private getInitializationOptions(commandPrefix: string) {
129+
private getInitializationOptions() {
133130
const rootModulePaths = config('terraform-ls').get<string[]>('rootModules', []);
134131
const terraformExecPath = config('terraform-ls').get<string>('terraformExecPath', '');
135132
const terraformExecTimeout = config('terraform-ls').get<string>('terraformExecTimeout', '');
@@ -147,7 +144,6 @@ export class ClientHandler {
147144

148145
const experimentalFeatures = config('terraform-ls').get('experimentalFeatures');
149146
const initializationOptions = {
150-
commandPrefix,
151147
experimentalFeatures,
152148
ignoreSingleFileWarning,
153149
...(terraformExecPath.length > 0 && { terraformExecPath }),

src/extension.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
101101
if (selected && client) {
102102
const moduleUri = selected[0];
103103
const requestParams: ExecuteCommandParams = {
104-
command: `${client.commandPrefix}.terraform-ls.terraform.init`,
104+
command: `terraform-ls.terraform.init`,
105105
arguments: [`uri=${moduleUri}`],
106106
};
107107
await execWorkspaceCommand(client.client, requestParams);
@@ -164,7 +164,7 @@ export async function updateTerraformStatusBar(documentUri: vscode.Uri): Promise
164164
return;
165165
}
166166

167-
const initSupported = clientHandler.clientSupportsCommand(`${client.commandPrefix}.terraform-ls.terraform.init`);
167+
const initSupported = clientHandler.clientSupportsCommand(`terraform-ls.terraform.init`);
168168
if (!initSupported) {
169169
return;
170170
}
@@ -240,7 +240,7 @@ interface ModuleCallersResponse {
240240
// eslint-disable-next-line @typescript-eslint/no-explicit-any
241241
async function modulesCallersCommand(languageClient: TerraformLanguageClient, moduleUri: string): Promise<any> {
242242
const requestParams: ExecuteCommandParams = {
243-
command: `${languageClient.commandPrefix}.terraform-ls.module.callers`,
243+
command: `terraform-ls.module.callers`,
244244
arguments: [`uri=${moduleUri}`],
245245
};
246246
return execWorkspaceCommand(languageClient.client, requestParams);
@@ -288,7 +288,7 @@ async function terraformCommand(command: string, languageServerExec = true): Pro
288288

289289
if (languageServerExec && languageClient) {
290290
const requestParams: ExecuteCommandParams = {
291-
command: `${languageClient.commandPrefix}.terraform-ls.terraform.${command}`,
291+
command: `terraform-ls.terraform.${command}`,
292292
arguments: [`uri=${selectedModule}`],
293293
};
294294
return execWorkspaceCommand(languageClient.client, requestParams);

src/providers/moduleCalls.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export class ModuleCallsDataProvider implements vscode.TreeDataProvider<ModuleCa
7979

8080
constructor(ctx: vscode.ExtensionContext, public handler: ClientHandler) {
8181
this.svg = ctx.asAbsolutePath(path.join('assets', 'icons', 'terraform.svg'));
82+
8283
ctx.subscriptions.push(
8384
vscode.commands.registerCommand('terraform.modules.refreshList', () => this.refresh()),
8485
vscode.commands.registerCommand('terraform.modules.openDocumentation', (module: ModuleCallItem) => {
@@ -136,15 +137,13 @@ export class ModuleCallsDataProvider implements vscode.TreeDataProvider<ModuleCa
136137
}
137138

138139
return await handler.client.onReady().then(async () => {
139-
const moduleCallsSupported = this.handler.clientSupportsCommand(
140-
`${handler.commandPrefix}.terraform-ls.module.calls`,
141-
);
140+
const moduleCallsSupported = this.handler.clientSupportsCommand(`terraform-ls.module.calls`);
142141
if (!moduleCallsSupported) {
143142
return Promise.resolve([]);
144143
}
145144

146145
const params: ExecuteCommandParams = {
147-
command: `${handler.commandPrefix}.terraform-ls.module.calls`,
146+
command: `terraform-ls.module.calls`,
148147
arguments: [`uri=${documentURI}`],
149148
};
150149

src/providers/moduleProviders.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,13 @@ export class ModuleProvidersDataProvider implements vscode.TreeDataProvider<Modu
102102
}
103103
await handler.client.onReady();
104104

105-
const moduleCallsSupported = this.handler.clientSupportsCommand(
106-
`${handler.commandPrefix}.terraform-ls.module.providers`,
107-
);
105+
const moduleCallsSupported = this.handler.clientSupportsCommand(`terraform-ls.module.providers`);
108106
if (!moduleCallsSupported) {
109107
return [];
110108
}
111109

112110
const params: ExecuteCommandParams = {
113-
command: `${handler.commandPrefix}.terraform-ls.module.providers`,
111+
command: `terraform-ls.module.providers`,
114112
arguments: [`uri=${documentURI}`],
115113
};
116114

0 commit comments

Comments
 (0)