driftdetect-vscode 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-test.log +138 -0
- package/.vscode/launch.json +17 -0
- package/.vscode/tasks.json +15 -0
- package/LICENSE +121 -0
- package/dist/activation/activation-controller.d.ts +61 -0
- package/dist/activation/activation-controller.d.ts.map +1 -0
- package/dist/activation/activation-controller.js +235 -0
- package/dist/activation/activation-controller.js.map +1 -0
- package/dist/activation/activation-phases.d.ts +28 -0
- package/dist/activation/activation-phases.d.ts.map +1 -0
- package/dist/activation/activation-phases.js +80 -0
- package/dist/activation/activation-phases.js.map +1 -0
- package/dist/activation/index.d.ts +6 -0
- package/dist/activation/index.d.ts.map +1 -0
- package/dist/activation/index.js +6 -0
- package/dist/activation/index.js.map +1 -0
- package/dist/client/connection-config.d.ts +50 -0
- package/dist/client/connection-config.d.ts.map +1 -0
- package/dist/client/connection-config.js +56 -0
- package/dist/client/connection-config.js.map +1 -0
- package/dist/client/connection-manager.d.ts +70 -0
- package/dist/client/connection-manager.d.ts.map +1 -0
- package/dist/client/connection-manager.js +214 -0
- package/dist/client/connection-manager.js.map +1 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +8 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/language-client-factory.d.ts +29 -0
- package/dist/client/language-client-factory.d.ts.map +1 -0
- package/dist/client/language-client-factory.js +76 -0
- package/dist/client/language-client-factory.js.map +1 -0
- package/dist/client/request-middleware.d.ts +38 -0
- package/dist/client/request-middleware.d.ts.map +1 -0
- package/dist/client/request-middleware.js +85 -0
- package/dist/client/request-middleware.js.map +1 -0
- package/dist/commands/command-definitions.d.ts +53 -0
- package/dist/commands/command-definitions.d.ts.map +1 -0
- package/dist/commands/command-definitions.js +212 -0
- package/dist/commands/command-definitions.js.map +1 -0
- package/dist/commands/command-router.d.ts +80 -0
- package/dist/commands/command-router.d.ts.map +1 -0
- package/dist/commands/command-router.js +127 -0
- package/dist/commands/command-router.js.map +1 -0
- package/dist/commands/handlers/connection-handlers.d.ts +14 -0
- package/dist/commands/handlers/connection-handlers.d.ts.map +1 -0
- package/dist/commands/handlers/connection-handlers.js +57 -0
- package/dist/commands/handlers/connection-handlers.js.map +1 -0
- package/dist/commands/handlers/constants-handlers.d.ts +11 -0
- package/dist/commands/handlers/constants-handlers.d.ts.map +1 -0
- package/dist/commands/handlers/constants-handlers.js +84 -0
- package/dist/commands/handlers/constants-handlers.js.map +1 -0
- package/dist/commands/handlers/index.d.ts +10 -0
- package/dist/commands/handlers/index.d.ts.map +1 -0
- package/dist/commands/handlers/index.js +10 -0
- package/dist/commands/handlers/index.js.map +1 -0
- package/dist/commands/handlers/pattern-handlers.d.ts +13 -0
- package/dist/commands/handlers/pattern-handlers.d.ts.map +1 -0
- package/dist/commands/handlers/pattern-handlers.js +127 -0
- package/dist/commands/handlers/pattern-handlers.js.map +1 -0
- package/dist/commands/handlers/scan-handlers.d.ts +15 -0
- package/dist/commands/handlers/scan-handlers.d.ts.map +1 -0
- package/dist/commands/handlers/scan-handlers.js +74 -0
- package/dist/commands/handlers/scan-handlers.js.map +1 -0
- package/dist/commands/handlers/ui-handlers.d.ts +12 -0
- package/dist/commands/handlers/ui-handlers.d.ts.map +1 -0
- package/dist/commands/handlers/ui-handlers.js +74 -0
- package/dist/commands/handlers/ui-handlers.js.map +1 -0
- package/dist/commands/handlers/violation-handlers.d.ts +13 -0
- package/dist/commands/handlers/violation-handlers.d.ts.map +1 -0
- package/dist/commands/handlers/violation-handlers.js +76 -0
- package/dist/commands/handlers/violation-handlers.js.map +1 -0
- package/dist/commands/index.d.ts +7 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +7 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/middleware/connection-check-middleware.d.ts +12 -0
- package/dist/commands/middleware/connection-check-middleware.d.ts.map +1 -0
- package/dist/commands/middleware/connection-check-middleware.js +34 -0
- package/dist/commands/middleware/connection-check-middleware.js.map +1 -0
- package/dist/commands/middleware/index.d.ts +7 -0
- package/dist/commands/middleware/index.d.ts.map +1 -0
- package/dist/commands/middleware/index.js +7 -0
- package/dist/commands/middleware/index.js.map +1 -0
- package/dist/commands/middleware/logging-middleware.d.ts +12 -0
- package/dist/commands/middleware/logging-middleware.d.ts.map +1 -0
- package/dist/commands/middleware/logging-middleware.js +24 -0
- package/dist/commands/middleware/logging-middleware.js.map +1 -0
- package/dist/commands/middleware/telemetry-middleware.d.ts +22 -0
- package/dist/commands/middleware/telemetry-middleware.d.ts.map +1 -0
- package/dist/commands/middleware/telemetry-middleware.js +30 -0
- package/dist/commands/middleware/telemetry-middleware.js.map +1 -0
- package/dist/config/config-manager.d.ts +53 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +178 -0
- package/dist/config/config-manager.js.map +1 -0
- package/dist/config/defaults.d.ts +11 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +43 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +7 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/validator.d.ts +22 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +93 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/extension.d.ts +32 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +50 -0
- package/dist/extension.js.map +1 -0
- package/dist/infrastructure/disposable-manager.d.ts +43 -0
- package/dist/infrastructure/disposable-manager.d.ts.map +1 -0
- package/dist/infrastructure/disposable-manager.js +75 -0
- package/dist/infrastructure/disposable-manager.js.map +1 -0
- package/dist/infrastructure/event-bus.d.ts +85 -0
- package/dist/infrastructure/event-bus.d.ts.map +1 -0
- package/dist/infrastructure/event-bus.js +74 -0
- package/dist/infrastructure/event-bus.js.map +1 -0
- package/dist/infrastructure/index.d.ts +10 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +10 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/infrastructure/logger.d.ts +37 -0
- package/dist/infrastructure/logger.d.ts.map +1 -0
- package/dist/infrastructure/logger.js +86 -0
- package/dist/infrastructure/logger.js.map +1 -0
- package/dist/infrastructure/service-container.d.ts +68 -0
- package/dist/infrastructure/service-container.d.ts.map +1 -0
- package/dist/infrastructure/service-container.js +94 -0
- package/dist/infrastructure/service-container.js.map +1 -0
- package/dist/state/index.d.ts +7 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +7 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/initial-state.d.ts +11 -0
- package/dist/state/initial-state.d.ts.map +1 -0
- package/dist/state/initial-state.js +58 -0
- package/dist/state/initial-state.js.map +1 -0
- package/dist/state/selectors.d.ts +41 -0
- package/dist/state/selectors.d.ts.map +1 -0
- package/dist/state/selectors.js +61 -0
- package/dist/state/selectors.js.map +1 -0
- package/dist/state/state-manager.d.ts +54 -0
- package/dist/state/state-manager.d.ts.map +1 -0
- package/dist/state/state-manager.js +166 -0
- package/dist/state/state-manager.js.map +1 -0
- package/dist/types/config-types.d.ts +69 -0
- package/dist/types/config-types.d.ts.map +1 -0
- package/dist/types/config-types.js +5 -0
- package/dist/types/config-types.js.map +1 -0
- package/dist/types/extension-types.d.ts +45 -0
- package/dist/types/extension-types.d.ts.map +1 -0
- package/dist/types/extension-types.js +5 -0
- package/dist/types/extension-types.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/lsp-types.d.ts +70 -0
- package/dist/types/lsp-types.d.ts.map +1 -0
- package/dist/types/lsp-types.js +5 -0
- package/dist/types/lsp-types.js.map +1 -0
- package/dist/types/state-types.d.ts +82 -0
- package/dist/types/state-types.d.ts.map +1 -0
- package/dist/types/state-types.js +5 -0
- package/dist/types/state-types.js.map +1 -0
- package/dist/types/vscode-types.d.ts +36 -0
- package/dist/types/vscode-types.d.ts.map +1 -0
- package/dist/types/vscode-types.js +7 -0
- package/dist/types/vscode-types.js.map +1 -0
- package/dist/ui/decorations/decoration-controller.d.ts +45 -0
- package/dist/ui/decorations/decoration-controller.d.ts.map +1 -0
- package/dist/ui/decorations/decoration-controller.js +198 -0
- package/dist/ui/decorations/decoration-controller.js.map +1 -0
- package/dist/ui/decorations/decoration-types.d.ts +28 -0
- package/dist/ui/decorations/decoration-types.d.ts.map +1 -0
- package/dist/ui/decorations/decoration-types.js +98 -0
- package/dist/ui/decorations/decoration-types.js.map +1 -0
- package/dist/ui/decorations/index.d.ts +7 -0
- package/dist/ui/decorations/index.d.ts.map +1 -0
- package/dist/ui/decorations/index.js +6 -0
- package/dist/ui/decorations/index.js.map +1 -0
- package/dist/ui/index.d.ts +7 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +7 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/notifications/index.d.ts +5 -0
- package/dist/ui/notifications/index.d.ts.map +1 -0
- package/dist/ui/notifications/index.js +5 -0
- package/dist/ui/notifications/index.js.map +1 -0
- package/dist/ui/notifications/notification-service.d.ts +66 -0
- package/dist/ui/notifications/notification-service.d.ts.map +1 -0
- package/dist/ui/notifications/notification-service.js +103 -0
- package/dist/ui/notifications/notification-service.js.map +1 -0
- package/dist/ui/status-bar/index.d.ts +6 -0
- package/dist/ui/status-bar/index.d.ts.map +1 -0
- package/dist/ui/status-bar/index.js +6 -0
- package/dist/ui/status-bar/index.js.map +1 -0
- package/dist/ui/status-bar/status-bar-controller.d.ts +37 -0
- package/dist/ui/status-bar/status-bar-controller.d.ts.map +1 -0
- package/dist/ui/status-bar/status-bar-controller.js +111 -0
- package/dist/ui/status-bar/status-bar-controller.js.map +1 -0
- package/dist/ui/status-bar/status-bar-modes.d.ts +26 -0
- package/dist/ui/status-bar/status-bar-modes.d.ts.map +1 -0
- package/dist/ui/status-bar/status-bar-modes.js +97 -0
- package/dist/ui/status-bar/status-bar-modes.js.map +1 -0
- package/dist/views/base-tree-provider.d.ts +74 -0
- package/dist/views/base-tree-provider.d.ts.map +1 -0
- package/dist/views/base-tree-provider.js +95 -0
- package/dist/views/base-tree-provider.js.map +1 -0
- package/dist/views/constants-tree-provider.d.ts +112 -0
- package/dist/views/constants-tree-provider.d.ts.map +1 -0
- package/dist/views/constants-tree-provider.js +344 -0
- package/dist/views/constants-tree-provider.js.map +1 -0
- package/dist/views/files-tree-provider.d.ts +37 -0
- package/dist/views/files-tree-provider.d.ts.map +1 -0
- package/dist/views/files-tree-provider.js +98 -0
- package/dist/views/files-tree-provider.js.map +1 -0
- package/dist/views/index.d.ts +10 -0
- package/dist/views/index.d.ts.map +1 -0
- package/dist/views/index.js +10 -0
- package/dist/views/index.js.map +1 -0
- package/dist/views/patterns-tree-provider.d.ts +39 -0
- package/dist/views/patterns-tree-provider.d.ts.map +1 -0
- package/dist/views/patterns-tree-provider.js +139 -0
- package/dist/views/patterns-tree-provider.js.map +1 -0
- package/dist/views/violations-tree-provider.d.ts +46 -0
- package/dist/views/violations-tree-provider.d.ts.map +1 -0
- package/dist/views/violations-tree-provider.js +158 -0
- package/dist/views/violations-tree-provider.js.map +1 -0
- package/dist/webview/index.d.ts +7 -0
- package/dist/webview/index.d.ts.map +1 -0
- package/dist/webview/index.js +7 -0
- package/dist/webview/index.js.map +1 -0
- package/dist/webview/webview-manager.d.ts +57 -0
- package/dist/webview/webview-manager.d.ts.map +1 -0
- package/dist/webview/webview-manager.js +167 -0
- package/dist/webview/webview-manager.js.map +1 -0
- package/package.json +405 -0
- package/resources/drift-icon.png +0 -0
- package/resources/drift-icon.svg +5 -0
- package/resources/icons/error.svg +4 -0
- package/resources/icons/info.svg +4 -0
- package/resources/icons/lightbulb.svg +4 -0
- package/resources/icons/warning.svg +4 -0
- package/src/activation/activation-controller.ts +320 -0
- package/src/activation/activation-phases.ts +96 -0
- package/src/activation/index.ts +6 -0
- package/src/client/connection-config.ts +64 -0
- package/src/client/connection-manager.ts +263 -0
- package/src/client/index.ts +8 -0
- package/src/client/language-client-factory.ts +111 -0
- package/src/client/request-middleware.ts +117 -0
- package/src/commands/command-definitions.ts +243 -0
- package/src/commands/command-router.ts +194 -0
- package/src/commands/handlers/connection-handlers.ts +74 -0
- package/src/commands/handlers/constants-handlers.ts +99 -0
- package/src/commands/handlers/index.ts +10 -0
- package/src/commands/handlers/pattern-handlers.ts +167 -0
- package/src/commands/handlers/scan-handlers.ts +107 -0
- package/src/commands/handlers/ui-handlers.ts +88 -0
- package/src/commands/handlers/violation-handlers.ts +97 -0
- package/src/commands/index.ts +7 -0
- package/src/commands/middleware/connection-check-middleware.ts +46 -0
- package/src/commands/middleware/index.ts +7 -0
- package/src/commands/middleware/logging-middleware.ts +28 -0
- package/src/commands/middleware/telemetry-middleware.ts +46 -0
- package/src/config/config-manager.ts +213 -0
- package/src/config/defaults.ts +45 -0
- package/src/config/index.ts +7 -0
- package/src/config/validator.ts +118 -0
- package/src/extension.ts +57 -0
- package/src/infrastructure/disposable-manager.ts +87 -0
- package/src/infrastructure/event-bus.ts +121 -0
- package/src/infrastructure/index.ts +10 -0
- package/src/infrastructure/logger.ts +108 -0
- package/src/infrastructure/service-container.ts +123 -0
- package/src/state/index.ts +7 -0
- package/src/state/initial-state.ts +60 -0
- package/src/state/selectors.ts +126 -0
- package/src/state/state-manager.ts +198 -0
- package/src/types/config-types.ts +77 -0
- package/src/types/extension-types.ts +58 -0
- package/src/types/index.ts +12 -0
- package/src/types/lsp-types.ts +77 -0
- package/src/types/state-types.ts +92 -0
- package/src/types/vscode-types.ts +40 -0
- package/src/ui/decorations/decoration-controller.ts +252 -0
- package/src/ui/decorations/decoration-types.ts +129 -0
- package/src/ui/decorations/index.ts +7 -0
- package/src/ui/index.ts +7 -0
- package/src/ui/notifications/index.ts +5 -0
- package/src/ui/notifications/notification-service.ts +167 -0
- package/src/ui/status-bar/index.ts +6 -0
- package/src/ui/status-bar/status-bar-controller.ts +135 -0
- package/src/ui/status-bar/status-bar-modes.ts +119 -0
- package/src/views/base-tree-provider.ts +127 -0
- package/src/views/constants-tree-provider.ts +525 -0
- package/src/views/files-tree-provider.ts +140 -0
- package/src/views/index.ts +10 -0
- package/src/views/patterns-tree-provider.ts +179 -0
- package/src/views/violations-tree-provider.ts +210 -0
- package/src/webview/index.ts +7 -0
- package/src/webview/webview-manager.ts +238 -0
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActivationController - Extension lifecycle orchestrator
|
|
3
|
+
*
|
|
4
|
+
* Single responsibility: Orchestrate phased extension activation.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as vscode from 'vscode';
|
|
8
|
+
|
|
9
|
+
import { getPhasesByType } from './activation-phases.js';
|
|
10
|
+
import { createConnectionManager, type ConnectionManager } from '../client/index.js';
|
|
11
|
+
import { createCommandRouter } from '../commands/command-router.js';
|
|
12
|
+
import {
|
|
13
|
+
createConnectionHandlers,
|
|
14
|
+
createScanHandlers,
|
|
15
|
+
createPatternHandlers,
|
|
16
|
+
createViolationHandlers,
|
|
17
|
+
createUIHandlers,
|
|
18
|
+
} from '../commands/handlers/index.js';
|
|
19
|
+
import {
|
|
20
|
+
createLoggingMiddleware,
|
|
21
|
+
createConnectionCheckMiddleware,
|
|
22
|
+
} from '../commands/middleware/index.js';
|
|
23
|
+
import { createConfigManager, type ConfigManager } from '../config/index.js';
|
|
24
|
+
import {
|
|
25
|
+
createLogger,
|
|
26
|
+
createDisposableManager,
|
|
27
|
+
createServiceContainer,
|
|
28
|
+
createEventBus,
|
|
29
|
+
ServiceKeys,
|
|
30
|
+
type Logger,
|
|
31
|
+
type DisposableManager,
|
|
32
|
+
type ServiceContainer,
|
|
33
|
+
type EventBus,
|
|
34
|
+
} from '../infrastructure/index.js';
|
|
35
|
+
import { createStateManager, type StateManager } from '../state/index.js';
|
|
36
|
+
import { createDecorationController } from '../ui/decorations/index.js';
|
|
37
|
+
import { createNotificationService } from '../ui/notifications/index.js';
|
|
38
|
+
import { createStatusBar } from '../ui/status-bar/index.js';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Phase timing data
|
|
42
|
+
*/
|
|
43
|
+
interface PhaseTiming {
|
|
44
|
+
name: string;
|
|
45
|
+
duration: number;
|
|
46
|
+
success: boolean;
|
|
47
|
+
error?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Activation controller
|
|
52
|
+
*/
|
|
53
|
+
export class ActivationController implements vscode.Disposable {
|
|
54
|
+
private readonly disposables: DisposableManager;
|
|
55
|
+
private readonly services: ServiceContainer;
|
|
56
|
+
private readonly phaseTimings: PhaseTiming[] = [];
|
|
57
|
+
private activated = false;
|
|
58
|
+
|
|
59
|
+
constructor(private readonly context: vscode.ExtensionContext) {
|
|
60
|
+
this.disposables = createDisposableManager();
|
|
61
|
+
this.services = createServiceContainer();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Activate the extension
|
|
66
|
+
*/
|
|
67
|
+
async activate(): Promise<void> {
|
|
68
|
+
if (this.activated) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const startTime = performance.now();
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
// Phase 1: Immediate (blocking)
|
|
76
|
+
await this.runImmediatePhase();
|
|
77
|
+
|
|
78
|
+
// Phase 2: Deferred (non-blocking)
|
|
79
|
+
setImmediate(() => {
|
|
80
|
+
this.runDeferredPhase().catch(error => {
|
|
81
|
+
this.getLogger().error('Deferred activation failed:', error);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
this.activated = true;
|
|
86
|
+
|
|
87
|
+
const totalTime = performance.now() - startTime;
|
|
88
|
+
this.getLogger().info(`Extension activated in ${totalTime.toFixed(2)}ms`);
|
|
89
|
+
|
|
90
|
+
} catch (error) {
|
|
91
|
+
this.getLogger().error('Activation failed:', error);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Deactivate the extension
|
|
98
|
+
*/
|
|
99
|
+
async deactivate(): Promise<void> {
|
|
100
|
+
this.getLogger().info('Deactivating extension...');
|
|
101
|
+
|
|
102
|
+
// Disconnect from server
|
|
103
|
+
const connectionManager = this.services.tryGet<ConnectionManager>(ServiceKeys.ConnectionManager);
|
|
104
|
+
if (connectionManager) {
|
|
105
|
+
await connectionManager.disconnect();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Dispose all resources
|
|
109
|
+
this.disposables.dispose();
|
|
110
|
+
this.services.clear();
|
|
111
|
+
|
|
112
|
+
this.activated = false;
|
|
113
|
+
this.getLogger().info('Extension deactivated');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Dispose resources
|
|
118
|
+
*/
|
|
119
|
+
dispose(): void {
|
|
120
|
+
this.deactivate().catch(() => {});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get phase timings for telemetry
|
|
125
|
+
*/
|
|
126
|
+
getPhaseTimings(): PhaseTiming[] {
|
|
127
|
+
return [...this.phaseTimings];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private async runImmediatePhase(): Promise<void> {
|
|
131
|
+
const phases = getPhasesByType('immediate');
|
|
132
|
+
|
|
133
|
+
for (const phase of phases) {
|
|
134
|
+
await this.runPhase(phase.name, () => this.initializePhase(phase.name));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private async runDeferredPhase(): Promise<void> {
|
|
139
|
+
const phases = getPhasesByType('deferred');
|
|
140
|
+
|
|
141
|
+
for (const phase of phases) {
|
|
142
|
+
await this.runPhase(phase.name, () => this.initializePhase(phase.name));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Register lazy providers
|
|
146
|
+
this.registerLazyProviders();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private async runPhase(name: string, fn: () => Promise<void>): Promise<void> {
|
|
150
|
+
const startTime = performance.now();
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
await fn();
|
|
154
|
+
|
|
155
|
+
this.phaseTimings.push({
|
|
156
|
+
name,
|
|
157
|
+
duration: performance.now() - startTime,
|
|
158
|
+
success: true,
|
|
159
|
+
});
|
|
160
|
+
} catch (error) {
|
|
161
|
+
this.phaseTimings.push({
|
|
162
|
+
name,
|
|
163
|
+
duration: performance.now() - startTime,
|
|
164
|
+
success: false,
|
|
165
|
+
error: error instanceof Error ? error.message : String(error),
|
|
166
|
+
});
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private async initializePhase(name: string): Promise<void> {
|
|
172
|
+
switch (name) {
|
|
173
|
+
case 'infrastructure':
|
|
174
|
+
await this.initializeInfrastructure();
|
|
175
|
+
break;
|
|
176
|
+
case 'state':
|
|
177
|
+
await this.initializeState();
|
|
178
|
+
break;
|
|
179
|
+
case 'config':
|
|
180
|
+
await this.initializeConfig();
|
|
181
|
+
break;
|
|
182
|
+
case 'statusBar':
|
|
183
|
+
await this.initializeStatusBar();
|
|
184
|
+
break;
|
|
185
|
+
case 'connection':
|
|
186
|
+
await this.initializeConnection();
|
|
187
|
+
break;
|
|
188
|
+
case 'commands':
|
|
189
|
+
await this.initializeCommands();
|
|
190
|
+
break;
|
|
191
|
+
case 'decorations':
|
|
192
|
+
await this.initializeDecorations();
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private async initializeInfrastructure(): Promise<void> {
|
|
198
|
+
// Create logger
|
|
199
|
+
const logger = createLogger('Drift', 'info');
|
|
200
|
+
this.services.register(ServiceKeys.Logger, logger);
|
|
201
|
+
this.disposables.add(logger);
|
|
202
|
+
|
|
203
|
+
// Create event bus
|
|
204
|
+
const eventBus = createEventBus();
|
|
205
|
+
this.services.register('eventBus', eventBus);
|
|
206
|
+
this.disposables.add(eventBus);
|
|
207
|
+
|
|
208
|
+
logger.info('Infrastructure initialized');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
private async initializeState(): Promise<void> {
|
|
212
|
+
const stateManager = createStateManager(this.context);
|
|
213
|
+
this.services.register(ServiceKeys.StateManager, stateManager);
|
|
214
|
+
this.disposables.add(stateManager);
|
|
215
|
+
|
|
216
|
+
this.getLogger().debug('State manager initialized');
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private async initializeConfig(): Promise<void> {
|
|
220
|
+
const configManager = createConfigManager(this.getLogger());
|
|
221
|
+
this.services.register(ServiceKeys.ConfigManager, configManager);
|
|
222
|
+
this.disposables.add(configManager);
|
|
223
|
+
|
|
224
|
+
this.getLogger().debug('Config manager initialized');
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private async initializeStatusBar(): Promise<void> {
|
|
228
|
+
const stateManager = this.services.get<StateManager>(ServiceKeys.StateManager);
|
|
229
|
+
const statusBar = createStatusBar(stateManager);
|
|
230
|
+
this.services.register(ServiceKeys.StatusBar, statusBar);
|
|
231
|
+
this.disposables.add(statusBar);
|
|
232
|
+
|
|
233
|
+
this.getLogger().debug('Status bar initialized');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private async initializeConnection(): Promise<void> {
|
|
237
|
+
const configManager = this.services.get<ConfigManager>(ServiceKeys.ConfigManager);
|
|
238
|
+
const eventBus = this.services.get<EventBus>('eventBus');
|
|
239
|
+
const stateManager = this.services.get<StateManager>(ServiceKeys.StateManager);
|
|
240
|
+
|
|
241
|
+
const connectionManager = createConnectionManager(
|
|
242
|
+
this.context,
|
|
243
|
+
this.getLogger(),
|
|
244
|
+
eventBus,
|
|
245
|
+
configManager.get('server')
|
|
246
|
+
);
|
|
247
|
+
this.services.register(ServiceKeys.ConnectionManager, connectionManager);
|
|
248
|
+
this.disposables.add(connectionManager);
|
|
249
|
+
|
|
250
|
+
// Update state on connection changes
|
|
251
|
+
connectionManager.onStateChange(status => {
|
|
252
|
+
stateManager.update(draft => {
|
|
253
|
+
draft.connection.status = status;
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// Start connection
|
|
258
|
+
await connectionManager.connect();
|
|
259
|
+
|
|
260
|
+
this.getLogger().debug('Connection manager initialized');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
private async initializeCommands(): Promise<void> {
|
|
264
|
+
const stateManager = this.services.get<StateManager>(ServiceKeys.StateManager);
|
|
265
|
+
const connectionManager = this.services.get<ConnectionManager>(ServiceKeys.ConnectionManager);
|
|
266
|
+
const eventBus = this.services.get<EventBus>('eventBus');
|
|
267
|
+
|
|
268
|
+
// Create notification service
|
|
269
|
+
const notifications = createNotificationService(this.getLogger());
|
|
270
|
+
|
|
271
|
+
// Create command router
|
|
272
|
+
const router = createCommandRouter(this.context, this.getLogger(), stateManager);
|
|
273
|
+
this.services.register(ServiceKeys.CommandRouter, router);
|
|
274
|
+
this.disposables.add(router);
|
|
275
|
+
|
|
276
|
+
// Add middleware
|
|
277
|
+
router
|
|
278
|
+
.use(createLoggingMiddleware(this.getLogger()))
|
|
279
|
+
.use(createConnectionCheckMiddleware(stateManager));
|
|
280
|
+
|
|
281
|
+
// Register command handlers
|
|
282
|
+
createConnectionHandlers(router, connectionManager, stateManager, notifications);
|
|
283
|
+
createScanHandlers(router, connectionManager, stateManager, notifications, eventBus);
|
|
284
|
+
createPatternHandlers(router, connectionManager, notifications);
|
|
285
|
+
createViolationHandlers(router, connectionManager, notifications);
|
|
286
|
+
createUIHandlers(router, notifications);
|
|
287
|
+
|
|
288
|
+
this.getLogger().debug('Commands initialized');
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
private async initializeDecorations(): Promise<void> {
|
|
292
|
+
const configManager = this.services.get<ConfigManager>(ServiceKeys.ConfigManager);
|
|
293
|
+
|
|
294
|
+
const decorationController = createDecorationController(this.context, configManager);
|
|
295
|
+
this.services.register(ServiceKeys.DecorationController, decorationController);
|
|
296
|
+
this.disposables.add(decorationController);
|
|
297
|
+
|
|
298
|
+
this.getLogger().debug('Decorations initialized');
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private registerLazyProviders(): void {
|
|
302
|
+
// Tree views and webviews are registered but not initialized until accessed
|
|
303
|
+
// This keeps activation fast while still registering the providers
|
|
304
|
+
|
|
305
|
+
this.getLogger().debug('Lazy providers registered');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private getLogger(): Logger {
|
|
309
|
+
return this.services.get<Logger>(ServiceKeys.Logger);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Factory function for creating activation controller
|
|
315
|
+
*/
|
|
316
|
+
export function createActivationController(
|
|
317
|
+
context: vscode.ExtensionContext
|
|
318
|
+
): ActivationController {
|
|
319
|
+
return new ActivationController(context);
|
|
320
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activation phases configuration
|
|
3
|
+
*
|
|
4
|
+
* Single responsibility: Define activation phase order and timing.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ActivationPhase } from '../types/index.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Phase configuration
|
|
11
|
+
*/
|
|
12
|
+
export interface PhaseConfig {
|
|
13
|
+
name: string;
|
|
14
|
+
phase: ActivationPhase;
|
|
15
|
+
timeout: number;
|
|
16
|
+
critical: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Activation phases in order
|
|
21
|
+
*/
|
|
22
|
+
export const ActivationPhases: PhaseConfig[] = [
|
|
23
|
+
// Immediate phase - must complete before activate() returns
|
|
24
|
+
{
|
|
25
|
+
name: 'infrastructure',
|
|
26
|
+
phase: 'immediate',
|
|
27
|
+
timeout: 50,
|
|
28
|
+
critical: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'state',
|
|
32
|
+
phase: 'immediate',
|
|
33
|
+
timeout: 50,
|
|
34
|
+
critical: true,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'config',
|
|
38
|
+
phase: 'immediate',
|
|
39
|
+
timeout: 50,
|
|
40
|
+
critical: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'statusBar',
|
|
44
|
+
phase: 'immediate',
|
|
45
|
+
timeout: 50,
|
|
46
|
+
critical: false,
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
// Deferred phase - runs after activate() returns
|
|
50
|
+
{
|
|
51
|
+
name: 'connection',
|
|
52
|
+
phase: 'deferred',
|
|
53
|
+
timeout: 10000,
|
|
54
|
+
critical: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'commands',
|
|
58
|
+
phase: 'deferred',
|
|
59
|
+
timeout: 100,
|
|
60
|
+
critical: true,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'decorations',
|
|
64
|
+
phase: 'deferred',
|
|
65
|
+
timeout: 100,
|
|
66
|
+
critical: false,
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// Lazy phase - activated on demand
|
|
70
|
+
{
|
|
71
|
+
name: 'treeViews',
|
|
72
|
+
phase: 'lazy',
|
|
73
|
+
timeout: 500,
|
|
74
|
+
critical: false,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'webviews',
|
|
78
|
+
phase: 'lazy',
|
|
79
|
+
timeout: 500,
|
|
80
|
+
critical: false,
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Get phases by type
|
|
86
|
+
*/
|
|
87
|
+
export function getPhasesByType(type: ActivationPhase): PhaseConfig[] {
|
|
88
|
+
return ActivationPhases.filter(p => p.phase === type);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get critical phases
|
|
93
|
+
*/
|
|
94
|
+
export function getCriticalPhases(): PhaseConfig[] {
|
|
95
|
+
return ActivationPhases.filter(p => p.critical);
|
|
96
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection configuration constants
|
|
3
|
+
*
|
|
4
|
+
* Single responsibility: Define connection-related constants.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Connection configuration
|
|
9
|
+
*/
|
|
10
|
+
export const CONNECTION_CONFIG = {
|
|
11
|
+
/**
|
|
12
|
+
* Maximum restart attempts before giving up
|
|
13
|
+
*/
|
|
14
|
+
maxRestarts: 5,
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Base delay between restarts (ms)
|
|
18
|
+
*/
|
|
19
|
+
restartDelay: 1000,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Exponential backoff multiplier
|
|
23
|
+
*/
|
|
24
|
+
backoffMultiplier: 2,
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Maximum backoff delay (ms)
|
|
28
|
+
*/
|
|
29
|
+
maxBackoffDelay: 30000,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Health check interval (ms)
|
|
33
|
+
*/
|
|
34
|
+
healthCheckInterval: 30000,
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Server initialization timeout (ms)
|
|
38
|
+
*/
|
|
39
|
+
initializeTimeout: 10000,
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Individual request timeout (ms)
|
|
43
|
+
*/
|
|
44
|
+
requestTimeout: 5000,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Graceful shutdown timeout (ms)
|
|
48
|
+
*/
|
|
49
|
+
shutdownTimeout: 2000,
|
|
50
|
+
} as const;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Document selectors for the language client
|
|
54
|
+
*/
|
|
55
|
+
export const DOCUMENT_SELECTORS = [
|
|
56
|
+
{ scheme: 'file', language: 'typescript' },
|
|
57
|
+
{ scheme: 'file', language: 'typescriptreact' },
|
|
58
|
+
{ scheme: 'file', language: 'javascript' },
|
|
59
|
+
{ scheme: 'file', language: 'javascriptreact' },
|
|
60
|
+
{ scheme: 'file', language: 'python' },
|
|
61
|
+
{ scheme: 'file', language: 'csharp' },
|
|
62
|
+
{ scheme: 'file', language: 'java' },
|
|
63
|
+
{ scheme: 'file', language: 'php' },
|
|
64
|
+
];
|