generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCfnInfraCore.ts
More file actions
67 lines (58 loc) · 3.09 KB
/
CfnInfraCore.ts
File metadata and controls
67 lines (58 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { InitializeParams } from 'vscode-languageserver/node';
import { AwsCredentials } from '../auth/AwsCredentials';
import { ContextManager } from '../context/ContextManager';
import { FileContextManager } from '../context/FileContextManager';
import { SyntaxTreeManager } from '../context/syntaxtree/SyntaxTreeManager';
import { DataStoreFactoryProvider, MultiDataStoreFactoryProvider } from '../datastore/DataStore';
import { DocumentManager } from '../document/DocumentManager';
import { DocumentMetadata } from '../document/DocumentProtocol';
import { LspComponents } from '../protocol/LspComponents';
import { DiagnosticCoordinator } from '../services/DiagnosticCoordinator';
import { SettingsManager } from '../settings/SettingsManager';
import { ClientMessage } from '../telemetry/ClientMessage';
import { TelemetryService } from '../telemetry/TelemetryService';
import { Closeable, closeSafely } from '../utils/Closeable';
import { Configurable, Configurables } from '../utils/Configurable';
/**
* Core Infrastructure
* Only depends on LSP level components (or itself)
* LSP cannot function without these components
*/
export class CfnInfraCore implements Configurables, Closeable {
readonly dataStoreFactory: DataStoreFactoryProvider;
readonly clientMessage: ClientMessage;
readonly settingsManager: SettingsManager;
readonly syntaxTreeManager: SyntaxTreeManager;
readonly documentManager: DocumentManager;
readonly contextManager: ContextManager;
readonly fileContextManager: FileContextManager;
readonly awsCredentials: AwsCredentials;
readonly diagnosticCoordinator: DiagnosticCoordinator;
constructor(
lspComponents: LspComponents,
_initializeParams: InitializeParams,
overrides: Partial<CfnInfraCore> = {},
) {
this.dataStoreFactory = overrides.dataStoreFactory ?? new MultiDataStoreFactoryProvider();
this.clientMessage = overrides.clientMessage ?? new ClientMessage(lspComponents.communication);
this.settingsManager = overrides.settingsManager ?? new SettingsManager(lspComponents.workspace);
this.syntaxTreeManager = overrides.syntaxTreeManager ?? new SyntaxTreeManager();
this.documentManager =
overrides.documentManager ??
new DocumentManager(lspComponents.documents.documents, (docs: DocumentMetadata[]) => {
return lspComponents.documents.sendDocumentsMetadata(docs);
});
this.contextManager = overrides.contextManager ?? new ContextManager(this.syntaxTreeManager);
this.fileContextManager = overrides.fileContextManager ?? new FileContextManager(this.documentManager);
this.awsCredentials =
overrides.awsCredentials ?? new AwsCredentials(lspComponents.authHandlers, this.settingsManager);
this.diagnosticCoordinator =
overrides.diagnosticCoordinator ?? new DiagnosticCoordinator(lspComponents.diagnostics);
}
configurables(): Configurable[] {
return [this.documentManager];
}
async close() {
return await closeSafely(this.dataStoreFactory, TelemetryService.instance);
}
}