Skip to content

Commit e1528d7

Browse files
committed
Refactored templates folder
1 parent c92140f commit e1528d7

33 files changed

+412
-385
lines changed
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ import { Parameter } from '../context/semantic/Entity';
55
import { parseIdentifiable } from '../protocol/LspParser';
66
import { Identifiable } from '../protocol/LspTypes';
77
import { ServerComponents } from '../server/ServerComponents';
8-
import { LoggerFactory } from '../telemetry/LoggerFactory';
9-
import { parseTemplateActionParams, parseGetParametersParams } from '../templates/TemplateParser';
8+
import { parseStackActionParams, parseGetParametersParams } from '../stackActions/StackActionParser';
109
import {
1110
GetParametersParams,
1211
GetParametersResult,
13-
TemplateActionParams,
14-
TemplateActionResult,
15-
TemplateStatusResult,
16-
} from '../templates/TemplateRequestType';
12+
StackActionParams,
13+
StackActionResult,
14+
StackActionStatusResult,
15+
} from '../stackActions/StackActionRequestType';
16+
import { LoggerFactory } from '../telemetry/LoggerFactory';
1717
import { extractErrorMessage } from '../utils/Errors';
1818
import { parseWithPrettyError } from '../utils/ZodErrorWrapper';
1919

20-
const log = LoggerFactory.getLogger('TemplateHandler');
20+
const log = LoggerFactory.getLogger('StackActionHandler');
2121

22-
export function templateParametersHandler(
22+
export function stackActionParametersHandler(
2323
components: ServerComponents,
2424
): ServerRequestHandler<GetParametersParams, GetParametersResult, never, void> {
2525
return (rawParams, _token, _workDoneProgress, _resultProgress) => {
26-
log.debug({ Handler: 'TemplateParameters', rawParams });
26+
log.debug({ Handler: 'StackActionParameters', rawParams });
2727

2828
try {
2929
const params = parseWithPrettyError(parseGetParametersParams, rawParams);
@@ -42,72 +42,72 @@ export function templateParametersHandler(
4242
parameters: [],
4343
};
4444
} catch (error) {
45-
handleTemplateError(error, 'Failed to get parameters');
45+
handleStackActionError(error, 'Failed to get parameters');
4646
}
4747
};
4848
}
4949

50-
export function templateValidationCreateHandler(
50+
export function stackActionValidationCreateHandler(
5151
components: ServerComponents,
52-
): ServerRequestHandler<TemplateActionParams, TemplateActionResult, never, void> {
52+
): ServerRequestHandler<StackActionParams, StackActionResult, never, void> {
5353
return async (rawParams) => {
54-
log.debug({ Handler: 'TemplateValidationCreate', rawParams });
54+
log.debug({ Handler: 'StackActionValidationCreate', rawParams });
5555

5656
try {
57-
const params = parseWithPrettyError(parseTemplateActionParams, rawParams);
57+
const params = parseWithPrettyError(parseStackActionParams, rawParams);
5858
return await components.validationWorkflowService.start(params);
5959
} catch (error) {
60-
handleTemplateError(error, 'Failed to start validation workflow');
60+
handleStackActionError(error, 'Failed to start validation workflow');
6161
}
6262
};
6363
}
6464

65-
export function templateDeploymentCreateHandler(
65+
export function stackActionDeploymentCreateHandler(
6666
components: ServerComponents,
67-
): ServerRequestHandler<TemplateActionParams, TemplateActionResult, never, void> {
67+
): ServerRequestHandler<StackActionParams, StackActionResult, never, void> {
6868
return async (rawParams) => {
69-
log.debug({ Handler: 'TemplateDeploymentCreate', rawParams });
69+
log.debug({ Handler: 'StackActionDeploymentCreate', rawParams });
7070

7171
try {
72-
const params = parseWithPrettyError(parseTemplateActionParams, rawParams);
72+
const params = parseWithPrettyError(parseStackActionParams, rawParams);
7373
return await components.deploymentWorkflowService.start(params);
7474
} catch (error) {
75-
handleTemplateError(error, 'Failed to start deployment workflow');
75+
handleStackActionError(error, 'Failed to start deployment workflow');
7676
}
7777
};
7878
}
7979

80-
export function templateValidationStatusHandler(
80+
export function stackActionValidationStatusHandler(
8181
components: ServerComponents,
82-
): ServerRequestHandler<Identifiable, TemplateStatusResult, never, void> {
82+
): ServerRequestHandler<Identifiable, StackActionStatusResult, never, void> {
8383
return (rawParams) => {
84-
log.debug({ Handler: 'TemplateValidationStatus', rawParams });
84+
log.debug({ Handler: 'StackActionValidationStatus', rawParams });
8585

8686
try {
8787
const params = parseWithPrettyError(parseIdentifiable, rawParams);
8888
return components.validationWorkflowService.getStatus(params);
8989
} catch (error) {
90-
handleTemplateError(error, 'Failed to get validation status');
90+
handleStackActionError(error, 'Failed to get validation status');
9191
}
9292
};
9393
}
9494

95-
export function templateDeploymentStatusHandler(
95+
export function stackActionDeploymentStatusHandler(
9696
components: ServerComponents,
97-
): ServerRequestHandler<Identifiable, TemplateStatusResult, never, void> {
97+
): ServerRequestHandler<Identifiable, StackActionStatusResult, never, void> {
9898
return (rawParams) => {
99-
log.debug({ Handler: 'TemplateDeploymentStatus', rawParams });
99+
log.debug({ Handler: 'StackActionDeploymentStatus', rawParams });
100100

101101
try {
102102
const params = parseWithPrettyError(parseIdentifiable, rawParams);
103103
return components.deploymentWorkflowService.getStatus(params);
104104
} catch (error) {
105-
handleTemplateError(error, 'Failed to get deployment status');
105+
handleStackActionError(error, 'Failed to get deployment status');
106106
}
107107
};
108108
}
109109

110-
function handleTemplateError(error: unknown, contextMessage: string): never {
110+
function handleStackActionError(error: unknown, contextMessage: string): never {
111111
if (error instanceof ResponseError) {
112112
throw error;
113113
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ListStacksParams, ListStacksResult } from '../stacks/StackRequestType';
44
import { LoggerFactory } from '../telemetry/LoggerFactory';
55
import { extractErrorMessage } from '../utils/Errors';
66

7-
const log = LoggerFactory.getLogger('StackHandler');
7+
const log = LoggerFactory.getLogger('StackQueryHandler');
88

99
export function listStacksHandler(
1010
components: ServerComponents,

src/protocol/LspConnection.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { LspDiagnostics } from './LspDiagnostics';
1414
import { LspDocuments } from './LspDocuments';
1515
import { LspHandlers } from './LspHandlers';
1616
import { LspResourceHandlers } from './LspResourceHandlers';
17-
import { LspStackHandlers } from './LspStackHandlers';
18-
import { LspTemplateHandlers } from './LspTemplateHandlers';
17+
import { LspStackActionHandlers } from './LspStackActionHandlers';
18+
import { LspStackQueryHandlers } from './LspStackQueryHandlers';
1919
import { LspWorkspace } from './LspWorkspace';
2020

2121
type LspConnectionHandlers = {
@@ -32,8 +32,8 @@ export type LspFeatures = {
3232
communication: LspCommunication;
3333
handlers: LspHandlers;
3434
authHandlers: LspAuthHandlers;
35-
templateHandlers: LspTemplateHandlers;
36-
stackHandlers: LspStackHandlers;
35+
stackActionHandlers: LspStackActionHandlers;
36+
stackQueryHandlers: LspStackQueryHandlers;
3737
resourceHandlers: LspResourceHandlers;
3838
};
3939

@@ -44,8 +44,8 @@ export class LspConnection {
4444
private readonly communication: LspCommunication;
4545
private readonly handlers: LspHandlers;
4646
private readonly authHandlers: LspAuthHandlers;
47-
private readonly templateHandlers: LspTemplateHandlers;
48-
private readonly stackHandlers: LspStackHandlers;
47+
private readonly stackActionHandlers: LspStackActionHandlers;
48+
private readonly stackHandlers: LspStackQueryHandlers;
4949
private readonly resourceHandlers: LspResourceHandlers;
5050

5151
private initializeParams?: InitializeParams;
@@ -67,8 +67,8 @@ export class LspConnection {
6767
this.communication = new LspCommunication(this.connection);
6868
this.handlers = new LspHandlers(this.connection);
6969
this.authHandlers = new LspAuthHandlers(this.connection);
70-
this.templateHandlers = new LspTemplateHandlers(this.connection);
71-
this.stackHandlers = new LspStackHandlers(this.connection);
70+
this.stackActionHandlers = new LspStackActionHandlers(this.connection);
71+
this.stackHandlers = new LspStackQueryHandlers(this.connection);
7272
this.resourceHandlers = new LspResourceHandlers(this.connection);
7373

7474
this.connection.onInitialize((params: InitializeParams): InitializeResult => {
@@ -102,8 +102,8 @@ export class LspConnection {
102102
communication: this.communication,
103103
handlers: this.handlers,
104104
authHandlers: this.authHandlers,
105-
templateHandlers: this.templateHandlers,
106-
stackHandlers: this.stackHandlers,
105+
stackActionHandlers: this.stackActionHandlers,
106+
stackQueryHandlers: this.stackHandlers,
107107
resourceHandlers: this.resourceHandlers,
108108
};
109109
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
import { Connection, ServerRequestHandler } from 'vscode-languageserver';
22
import {
3-
TemplateActionParams,
4-
TemplateActionResult,
53
TemplateValidationCreateRequest,
64
TemplateDeploymentCreateRequest,
75
TemplateDeploymentStatusRequest,
8-
TemplateStatusResult,
96
TemplateValidationStatusRequest,
10-
GetParametersParams,
117
GetParametersRequest,
8+
} from '../stackActions/StackActionProtocol';
9+
import {
10+
StackActionParams,
11+
StackActionResult,
12+
StackActionStatusResult,
13+
GetParametersParams,
1214
GetParametersResult,
13-
} from '../templates/TemplateRequestType';
15+
} from '../stackActions/StackActionRequestType';
1416
import { Identifiable } from './LspTypes';
1517

16-
export class LspTemplateHandlers {
18+
export class LspStackActionHandlers {
1719
constructor(private readonly connection: Connection) {}
1820

19-
onTemplateValidationCreate(handler: ServerRequestHandler<TemplateActionParams, TemplateActionResult, never, void>) {
21+
onTemplateValidationCreate(handler: ServerRequestHandler<StackActionParams, StackActionResult, never, void>) {
2022
this.connection.onRequest(TemplateValidationCreateRequest.method, handler);
2123
}
2224

23-
onTemplateDeploymentCreate(handler: ServerRequestHandler<TemplateActionParams, TemplateActionResult, never, void>) {
25+
onTemplateDeploymentCreate(handler: ServerRequestHandler<StackActionParams, StackActionResult, never, void>) {
2426
this.connection.onRequest(TemplateDeploymentCreateRequest.method, handler);
2527
}
2628

27-
onTemplateValidationStatus(handler: ServerRequestHandler<Identifiable, TemplateStatusResult, never, void>) {
29+
onTemplateValidationStatus(handler: ServerRequestHandler<Identifiable, StackActionStatusResult, never, void>) {
2830
this.connection.onRequest(TemplateValidationStatusRequest.method, handler);
2931
}
3032

31-
onTemplateDeploymentStatus(handler: ServerRequestHandler<Identifiable, TemplateStatusResult, never, void>) {
33+
onTemplateDeploymentStatus(handler: ServerRequestHandler<Identifiable, StackActionStatusResult, never, void>) {
3234
this.connection.onRequest(TemplateDeploymentStatusRequest.method, handler);
3335
}
3436

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Connection, ServerRequestHandler } from 'vscode-languageserver';
22
import { ListStacksParams, ListStacksResult, ListStacksRequest } from '../stacks/StackRequestType';
33

4-
export class LspStackHandlers {
4+
export class LspStackQueryHandlers {
55
constructor(private readonly connection: Connection) {}
66

77
onListStacks(handler: ServerRequestHandler<ListStacksParams, ListStacksResult, never, void>) {

src/server/CfnServer.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import {
2323
importResourceStateHandler,
2424
refreshResourceListHandler,
2525
} from '../handlers/ResourceHandler';
26-
import { listStacksHandler } from '../handlers/StackHandler';
2726
import {
28-
templateValidationCreateHandler,
29-
templateDeploymentCreateHandler,
30-
templateValidationStatusHandler,
31-
templateDeploymentStatusHandler,
32-
templateParametersHandler,
33-
} from '../handlers/TemplateHandler';
27+
stackActionValidationCreateHandler,
28+
stackActionDeploymentCreateHandler,
29+
stackActionValidationStatusHandler,
30+
stackActionDeploymentStatusHandler,
31+
stackActionParametersHandler,
32+
} from '../handlers/StackActionHandler';
33+
import { listStacksHandler } from '../handlers/StackQueryHandler';
3434
import { LspFeatures } from '../protocol/LspConnection';
3535
import { ServerComponents } from './ServerComponents';
3636

@@ -68,13 +68,21 @@ export class CfnServer {
6868
this.features.authHandlers.onBearerCredentialsDelete(bearerCredentialsDeleteHandler(this.components));
6969
this.features.authHandlers.onSsoTokenChanged(ssoTokenChangedHandler(this.components));
7070

71-
this.features.templateHandlers.onGetParameters(templateParametersHandler(this.components));
72-
this.features.templateHandlers.onTemplateValidationCreate(templateValidationCreateHandler(this.components));
73-
this.features.templateHandlers.onTemplateDeploymentCreate(templateDeploymentCreateHandler(this.components));
74-
this.features.templateHandlers.onTemplateValidationStatus(templateValidationStatusHandler(this.components));
75-
this.features.templateHandlers.onTemplateDeploymentStatus(templateDeploymentStatusHandler(this.components));
71+
this.features.stackActionHandlers.onGetParameters(stackActionParametersHandler(this.components));
72+
this.features.stackActionHandlers.onTemplateValidationCreate(
73+
stackActionValidationCreateHandler(this.components),
74+
);
75+
this.features.stackActionHandlers.onTemplateDeploymentCreate(
76+
stackActionDeploymentCreateHandler(this.components),
77+
);
78+
this.features.stackActionHandlers.onTemplateValidationStatus(
79+
stackActionValidationStatusHandler(this.components),
80+
);
81+
this.features.stackActionHandlers.onTemplateDeploymentStatus(
82+
stackActionDeploymentStatusHandler(this.components),
83+
);
7684

77-
this.features.stackHandlers.onListStacks(listStacksHandler(this.components));
85+
this.features.stackQueryHandlers.onListStacks(listStacksHandler(this.components));
7886

7987
this.features.resourceHandlers.onListResources(listResourcesHandler(this.components));
8088
this.features.resourceHandlers.onRefreshResourceList(refreshResourceListHandler(this.components));

src/server/ServerComponents.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ import { DiagnosticCoordinator } from '../services/DiagnosticCoordinator';
3434
import { GuardService } from '../services/guard/GuardService';
3535
import { IacGeneratorService } from '../services/IacGeneratorService';
3636
import { SettingsManager } from '../settings/SettingsManager';
37+
import { DeploymentWorkflow } from '../stackActions/DeploymentWorkflow';
38+
import { ValidationManager } from '../stackActions/ValidationManager';
39+
import { ValidationWorkflow } from '../stackActions/ValidationWorkflow';
3740
import { ClientMessage } from '../telemetry/ClientMessage';
3841
import { StdOutLogger, LoggerFactory } from '../telemetry/LoggerFactory';
3942
import { TelemetryService } from '../telemetry/TelemetryService';
40-
import { DeploymentWorkflow } from '../templates/DeploymentWorkflow';
41-
import { ValidationManager } from '../templates/ValidationManager';
42-
import { ValidationWorkflow } from '../templates/ValidationWorkflow';
4343

4444
export interface Configurable {
4545
configure(settingsManager: SettingsManager): void | Promise<void>;
@@ -110,7 +110,7 @@ export class ServerComponents {
110110
private closeableComponents: Closeable[] = [];
111111

112112
constructor(
113-
features: Omit<LspFeatures, 'handlers' | 'templateHandlers' | 'stackHandlers' | 'resourceHandlers'>,
113+
features: Omit<LspFeatures, 'handlers' | 'stackActionHandlers' | 'stackQueryHandlers' | 'resourceHandlers'>,
114114
overrides: Partial<ServerComponents> = {},
115115
) {
116116
this.diagnostics = features.diagnostics;

src/services/CodeActionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import { NodeType } from '../context/syntaxtree/utils/NodeType';
1414
import { DocumentManager } from '../document/DocumentManager';
1515
import { ANALYZE_DIAGNOSTIC } from '../handlers/ExecutionHandler';
1616
import { ServerComponents } from '../server/ServerComponents';
17+
import { CFN_VALIDATION_SOURCE } from '../stackActions/ValidationWorkflow';
1718
import { ClientMessage } from '../telemetry/ClientMessage';
1819
import { LoggerFactory } from '../telemetry/LoggerFactory';
19-
import { CFN_VALIDATION_SOURCE } from '../templates/ValidationWorkflow';
2020
import { extractErrorMessage } from '../utils/Errors';
2121
import { pointToPosition } from '../utils/TypeConverters';
2222
import { DiagnosticCoordinator } from './DiagnosticCoordinator';

src/services/DiagnosticCoordinator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Diagnostic, PublishDiagnosticsParams } from 'vscode-languageserver';
22
import { LspDiagnostics } from '../protocol/LspDiagnostics';
3+
import { CFN_VALIDATION_SOURCE } from '../stackActions/ValidationWorkflow';
34
import { LoggerFactory } from '../telemetry/LoggerFactory';
4-
import { CFN_VALIDATION_SOURCE } from '../templates/ValidationWorkflow';
55
import { extractErrorMessage } from '../utils/Errors';
66

77
type SourceToDiagnostics = Map<string, Diagnostic[]>;

0 commit comments

Comments
 (0)