@djodjonx/wiredi 0.0.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.
Files changed (37) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +516 -0
  3. package/dist/index.cjs +931 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +1139 -0
  6. package/dist/index.d.cts.map +1 -0
  7. package/dist/index.d.mts +1139 -0
  8. package/dist/index.d.mts.map +1 -0
  9. package/dist/index.mjs +915 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/dist/plugin/ConfigurationAnalyzer.d.ts +59 -0
  12. package/dist/plugin/ConfigurationAnalyzer.d.ts.map +1 -0
  13. package/dist/plugin/ConfigurationAnalyzer.js +321 -0
  14. package/dist/plugin/ConfigurationAnalyzer.js.map +1 -0
  15. package/dist/plugin/DependencyAnalyzer.d.ts +54 -0
  16. package/dist/plugin/DependencyAnalyzer.d.ts.map +1 -0
  17. package/dist/plugin/DependencyAnalyzer.js +208 -0
  18. package/dist/plugin/DependencyAnalyzer.js.map +1 -0
  19. package/dist/plugin/TokenNormalizer.d.ts +51 -0
  20. package/dist/plugin/TokenNormalizer.d.ts.map +1 -0
  21. package/dist/plugin/TokenNormalizer.js +208 -0
  22. package/dist/plugin/TokenNormalizer.js.map +1 -0
  23. package/dist/plugin/ValidationEngine.d.ts +53 -0
  24. package/dist/plugin/ValidationEngine.d.ts.map +1 -0
  25. package/dist/plugin/ValidationEngine.js +250 -0
  26. package/dist/plugin/ValidationEngine.js.map +1 -0
  27. package/dist/plugin/index.d.ts +2 -0
  28. package/dist/plugin/index.d.ts.map +1 -0
  29. package/dist/plugin/index.js +144 -0
  30. package/dist/plugin/index.js.map +1 -0
  31. package/dist/plugin/package.json +6 -0
  32. package/dist/plugin/types.d.ts +152 -0
  33. package/dist/plugin/types.d.ts.map +1 -0
  34. package/dist/plugin/types.js +3 -0
  35. package/dist/plugin/types.js.map +1 -0
  36. package/package.json +95 -0
  37. package/plugin.js +1 -0
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationEngine = void 0;
4
+ const ConfigurationAnalyzer_1 = require("./ConfigurationAnalyzer");
5
+ const DependencyAnalyzer_1 = require("./DependencyAnalyzer");
6
+ /**
7
+ * Moteur de validation des dépendances DI
8
+ *
9
+ * Orchestre l'analyse des configurations et des classes pour
10
+ * détecter les dépendances manquantes.
11
+ */
12
+ class ValidationEngine {
13
+ constructor(typescript, checker, logger) {
14
+ this.checker = checker;
15
+ this.logger = logger;
16
+ this.typescript = typescript;
17
+ this.configAnalyzer = new ConfigurationAnalyzer_1.ConfigurationAnalyzer(typescript, checker, logger);
18
+ this.dependencyAnalyzer = new DependencyAnalyzer_1.DependencyAnalyzer(typescript, checker, logger);
19
+ }
20
+ /**
21
+ * Valide un programme TypeScript et retourne les erreurs
22
+ */
23
+ validate(program) {
24
+ const errors = [];
25
+ // Phase 1: Collecter toutes les configurations
26
+ const allConfigs = this.collectAllConfigs(program);
27
+ this.logger(`Trouvé ${allConfigs.size} configuration(s)`);
28
+ // Phase 2: Collecter toutes les classes analysées
29
+ const allClasses = this.collectAllClasses(program);
30
+ this.logger(`Trouvé ${allClasses.size} classe(s) avec dépendances`);
31
+ // Phase 3: Valider chaque configuration de type 'builder'
32
+ for (const [_symbol, config] of allConfigs) {
33
+ if (config.type !== 'builder')
34
+ continue;
35
+ const configErrors = this.validateConfig(config, allConfigs, allClasses);
36
+ errors.push(...configErrors);
37
+ }
38
+ return errors;
39
+ }
40
+ /**
41
+ * Collecte toutes les configurations du programme
42
+ */
43
+ collectAllConfigs(program) {
44
+ const configs = new Map();
45
+ for (const sourceFile of program.getSourceFiles()) {
46
+ if (sourceFile.isDeclarationFile)
47
+ continue;
48
+ const fileConfigs = this.configAnalyzer.analyzeSourceFile(sourceFile);
49
+ for (const config of fileConfigs) {
50
+ if (config.symbol) {
51
+ configs.set(config.symbol, config);
52
+ }
53
+ }
54
+ }
55
+ return configs;
56
+ }
57
+ /**
58
+ * Collecte toutes les classes analysées du programme
59
+ */
60
+ collectAllClasses(program) {
61
+ const classes = new Map();
62
+ for (const sourceFile of program.getSourceFiles()) {
63
+ if (sourceFile.isDeclarationFile)
64
+ continue;
65
+ const fileClasses = this.dependencyAnalyzer.analyzeSourceFile(sourceFile);
66
+ for (const cls of fileClasses) {
67
+ classes.set(cls.symbol, cls);
68
+ }
69
+ }
70
+ return classes;
71
+ }
72
+ /**
73
+ * Valide une configuration spécifique
74
+ */
75
+ validateConfig(config, allConfigs, allClasses) {
76
+ const errors = [];
77
+ const visitedSet = new Set();
78
+ // Résoudre tous les tokens fournis (avec héritage)
79
+ const providedTokens = this.configAnalyzer.resolveAllProvidedTokens(config, allConfigs, visitedSet);
80
+ this.logger(`Config "${config.builderId}": ${providedTokens.size} token(s) fournis`);
81
+ // Collecter toutes les classes à valider (providers)
82
+ const classesToValidate = this.collectClassesToValidate(config, allConfigs, new Set());
83
+ // Valider chaque classe
84
+ for (const [classSymbol, provider] of classesToValidate) {
85
+ const analyzedClass = allClasses.get(classSymbol);
86
+ if (!analyzedClass) {
87
+ // La classe n'a peut-être pas de dépendances ou n'a pas été analysée
88
+ continue;
89
+ }
90
+ const classErrors = this.validateClassDependencies(analyzedClass, providedTokens, provider, config);
91
+ errors.push(...classErrors);
92
+ }
93
+ return errors;
94
+ }
95
+ /**
96
+ * Collecte toutes les classes qui doivent être validées pour une configuration
97
+ */
98
+ collectClassesToValidate(config, allConfigs, visitedSet) {
99
+ const classes = new Map();
100
+ // Ajouter les providers locaux
101
+ for (const provider of config.localProviders) {
102
+ if (provider.providerClass) {
103
+ classes.set(provider.providerClass, provider);
104
+ }
105
+ }
106
+ // Ajouter les providers des configs parentes
107
+ for (const parentSymbol of config.parentConfigs) {
108
+ const parentConfig = allConfigs.get(parentSymbol);
109
+ if (parentConfig) {
110
+ const parentClasses = this.collectClassesToValidate(parentConfig, allConfigs, visitedSet);
111
+ for (const [classSymbol, provider] of parentClasses) {
112
+ if (!classes.has(classSymbol)) {
113
+ classes.set(classSymbol, provider);
114
+ }
115
+ }
116
+ }
117
+ }
118
+ return classes;
119
+ }
120
+ /**
121
+ * Valide les dépendances d'une classe contre les tokens fournis
122
+ */
123
+ validateClassDependencies(analyzedClass, providedTokens, provider, config) {
124
+ const errors = [];
125
+ for (const dependency of analyzedClass.dependencies) {
126
+ const registeredProvider = providedTokens.get(dependency.token.id);
127
+ if (!registeredProvider) {
128
+ // Token non enregistré
129
+ errors.push(this.createMissingDependencyError(analyzedClass, dependency, provider, config));
130
+ }
131
+ else {
132
+ // Vérifier la compatibilité de type
133
+ const typeError = this.checkTypeCompatibility(dependency, registeredProvider, analyzedClass, config);
134
+ if (typeError) {
135
+ errors.push(typeError);
136
+ }
137
+ }
138
+ }
139
+ return errors;
140
+ }
141
+ /**
142
+ * Vérifie la compatibilité de type entre le provider enregistré et le type attendu
143
+ */
144
+ checkTypeCompatibility(dependency, registeredProvider, analyzedClass, config) {
145
+ // Skip si pas de type attendu ou pas de type provider
146
+ if (!dependency.expectedType || !registeredProvider.providerType) {
147
+ return null;
148
+ }
149
+ // Skip pour les factories et values (type dynamique)
150
+ if (registeredProvider.registrationType === 'factory' ||
151
+ registeredProvider.registrationType === 'value') {
152
+ return null;
153
+ }
154
+ const expectedType = dependency.expectedType;
155
+ const providerType = registeredProvider.providerType;
156
+ // Vérifier si le type du provider est assignable au type attendu
157
+ // On utilise isTypeAssignableTo pour vérifier la compatibilité structurelle
158
+ const isCompatible = this.checker.isTypeAssignableTo(providerType, expectedType);
159
+ if (!isCompatible) {
160
+ const expectedTypeName = this.checker.typeToString(expectedType);
161
+ const providerTypeName = this.checker.typeToString(providerType);
162
+ const className = analyzedClass.name;
163
+ const tokenName = dependency.token.displayName;
164
+ const paramIndex = dependency.parameterIndex;
165
+ const _builderId = config.builderId || config.variableName || 'unknown';
166
+ // L'erreur est reportée sur le provider là où il est ENREGISTRÉ
167
+ // (peut être dans un partial différent du builder)
168
+ const errorNode = registeredProvider.node;
169
+ const errorSourceFile = errorNode.getSourceFile(); // Fichier où le provider est défini
170
+ return {
171
+ message: `[WireDI] Type mismatch: Provider doesn't match expected type\n\n` +
172
+ `Service '${className}' expects type '${expectedTypeName}' for '${tokenName}' (parameter #${paramIndex}),\n` +
173
+ `but the registered provider '${registeredProvider.providerClassName || 'unknown'}' ` +
174
+ `returns '${providerTypeName}'.\n\n` +
175
+ `💡 Fix: Register a provider that implements '${expectedTypeName}' or use a factory to adapt the type.`,
176
+ file: errorSourceFile,
177
+ start: errorNode.getStart(errorSourceFile),
178
+ length: errorNode.getWidth(errorSourceFile),
179
+ relatedInformation: [
180
+ {
181
+ file: dependency.parameterNode.getSourceFile(),
182
+ start: dependency.parameterNode.getStart(),
183
+ length: dependency.parameterNode.getWidth(),
184
+ message: `The type '${expectedTypeName}' is expected here`,
185
+ },
186
+ ],
187
+ };
188
+ }
189
+ return null;
190
+ }
191
+ /**
192
+ * Crée une erreur de dépendance manquante
193
+ */
194
+ createMissingDependencyError(analyzedClass, dependency, provider, config) {
195
+ const className = analyzedClass.name;
196
+ const tokenName = dependency.token.displayName;
197
+ const builderId = config.builderId || config.variableName || 'unknown';
198
+ const paramIndex = dependency.parameterIndex;
199
+ // L'erreur est reportée sur le provider dans la configuration
200
+ const errorNode = provider.node;
201
+ const errorSourceFile = config.sourceFile;
202
+ return {
203
+ message: `[WireDI] Missing dependency: '${className}' requires '${tokenName}' but it's not registered\n\n` +
204
+ `The service '${className}' expects '${tokenName}' as parameter #${paramIndex}, ` +
205
+ `but this token is not provided in the '${builderId}' configuration or its partials.\n\n` +
206
+ `💡 Fix: Add '{ token: ${tokenName} }' to your injections array.`,
207
+ file: errorSourceFile,
208
+ start: errorNode.getStart(errorSourceFile),
209
+ length: errorNode.getWidth(errorSourceFile),
210
+ relatedInformation: [
211
+ {
212
+ file: dependency.parameterNode.getSourceFile(),
213
+ start: dependency.parameterNode.getStart(),
214
+ length: dependency.parameterNode.getWidth(),
215
+ message: `The dependency '${tokenName}' is required here`,
216
+ },
217
+ ],
218
+ };
219
+ }
220
+ /**
221
+ * Convertit les erreurs de validation en diagnostics TypeScript
222
+ */
223
+ convertToDiagnostics(errors) {
224
+ const ts = this.typescript;
225
+ return errors.map(error => {
226
+ const diagnostic = {
227
+ file: error.file,
228
+ start: error.start,
229
+ length: error.length,
230
+ messageText: error.message,
231
+ category: ts.DiagnosticCategory.Error,
232
+ code: 90001, // Code arbitraire unique au plugin
233
+ source: 'di-validator',
234
+ };
235
+ if (error.relatedInformation && error.relatedInformation.length > 0) {
236
+ diagnostic.relatedInformation = error.relatedInformation.map(info => ({
237
+ file: info.file,
238
+ start: info.start,
239
+ length: info.length,
240
+ messageText: info.message,
241
+ category: ts.DiagnosticCategory.Message,
242
+ code: 90001,
243
+ }));
244
+ }
245
+ return diagnostic;
246
+ });
247
+ }
248
+ }
249
+ exports.ValidationEngine = ValidationEngine;
250
+ //# sourceMappingURL=ValidationEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValidationEngine.js","sourceRoot":"","sources":["../../src/LanguageServer/plugin/ValidationEngine.ts"],"names":[],"mappings":";;;AASA,mEAA+D;AAC/D,6DAAyD;AAEzD;;;;;GAKG;AACH,MAAa,gBAAgB;IAKzB,YACI,UAAqB,EACb,OAAuB,EACvB,MAA6B;QAD7B,YAAO,GAAP,OAAO,CAAgB;QACvB,WAAM,GAAN,MAAM,CAAuB;QAErC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,cAAc,GAAG,IAAI,6CAAqB,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;QAC5E,IAAI,CAAC,kBAAkB,GAAG,IAAI,uCAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IACjF,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAmB;QACxB,MAAM,MAAM,GAAwB,EAAE,CAAA;QAEtC,+C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OAAO;gBAC1B,QAAQ,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK;gBACrC,IAAI,EAAE,KAAK,EAAE,mCAAmC;gBAChD,MAAM,EAAE,cAAc;aACzB,CAAA;YAED,IAAI,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClE,UAAU,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAClE,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;oBACnB,WAAW,EAAE,IAAI,CAAC,OAAO;oBACzB,QAAQ,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO;oBACvC,IAAI,EAAE,KAAK;iBACd,CAAC,CAAC,CAAA;YACP,CAAC;YAED,OAAO,UAAU,CAAA;QACrB,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AA3UD,4CA2UC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/LanguageServer/plugin/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ValidationEngine_1 = require("./ValidationEngine");
4
+ /**
5
+ * Obtient la version d'un fichier source pour le cache
6
+ */
7
+ function getFileVersion(sourceFile) {
8
+ // Utiliser la version si disponible, sinon la longueur du texte
9
+ return sourceFile.version || sourceFile.getText().length.toString();
10
+ }
11
+ /**
12
+ * Fichiers externes que le plugin veut ajouter au projet
13
+ */
14
+ function getExternalFilesImpl() {
15
+ return [];
16
+ }
17
+ /**
18
+ * Appelé quand les fichiers du projet changent
19
+ */
20
+ function onConfigurationChangedImpl(_config) {
21
+ // Possibilité de mettre à jour la config à chaud
22
+ }
23
+ /**
24
+ * TypeScript Language Service Plugin pour la validation DI
25
+ *
26
+ * Ce plugin s'intègre au service de langage TypeScript pour fournir
27
+ * des diagnostics en temps réel sur les erreurs d'injection de dépendances.
28
+ *
29
+ * Architecture: Pattern Décorateur sur ts.LanguageService
30
+ *
31
+ * @see https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin
32
+ */
33
+ function init(modules) {
34
+ const typescript = modules.typescript;
35
+ function create(info) {
36
+ const config = info.config || {};
37
+ // Logger TOUJOURS - pour le diagnostic
38
+ const forceLog = (msg) => {
39
+ info.project.projectService.logger.info(`[DI-Validator] ${msg}`);
40
+ };
41
+ forceLog('===== Plugin initialisé =====');
42
+ forceLog(`Config: ${JSON.stringify(config)}`);
43
+ forceLog(`Project root: ${info.project.getCurrentDirectory()}`);
44
+ // Logger via le TSServer (verbose pour les détails)
45
+ const logger = (msg) => {
46
+ if (config.verbose) {
47
+ info.project.projectService.logger.info(`[DI-Validator] ${msg}`);
48
+ }
49
+ };
50
+ // Cache par fichier pour les performances
51
+ const fileCache = new Map();
52
+ // Créer le proxy du Language Service (Pattern Décorateur)
53
+ const proxy = Object.create(null);
54
+ const originalLS = info.languageService;
55
+ // Délégation par défaut de toutes les méthodes
56
+ for (const key of Object.keys(originalLS)) {
57
+ const method = originalLS[key];
58
+ if (typeof method === 'function') {
59
+ ;
60
+ proxy[key] = (...args) => method.apply(originalLS, args);
61
+ }
62
+ }
63
+ // ============================================================
64
+ // INTERCEPTION: getSemanticDiagnostics
65
+ // ============================================================
66
+ proxy.getSemanticDiagnostics = (fileName) => {
67
+ // Obtenir les diagnostics originaux de TypeScript
68
+ const originalDiagnostics = originalLS.getSemanticDiagnostics(fileName);
69
+ const program = originalLS.getProgram();
70
+ if (!program) {
71
+ logger('Pas de program disponible');
72
+ return originalDiagnostics;
73
+ }
74
+ const sourceFile = program.getSourceFile(fileName);
75
+ if (!sourceFile) {
76
+ return originalDiagnostics;
77
+ }
78
+ // Ne pas analyser les fichiers de déclaration
79
+ if (sourceFile.isDeclarationFile) {
80
+ return originalDiagnostics;
81
+ }
82
+ // Ne pas analyser les fichiers node_modules
83
+ if (fileName.includes('node_modules')) {
84
+ return originalDiagnostics;
85
+ }
86
+ try {
87
+ // Vérifier le cache
88
+ const version = getFileVersion(sourceFile);
89
+ const cached = fileCache.get(fileName);
90
+ if (cached && cached.version === version) {
91
+ // Utiliser le cache si la version n'a pas changé
92
+ // Note: On ne cache pas les diagnostics car ils dépendent du contexte global
93
+ }
94
+ // Effectuer la validation DI
95
+ const diDiagnostics = validateDI(program, sourceFile, logger);
96
+ // Fusion des diagnostics
97
+ return [...originalDiagnostics, ...diDiagnostics];
98
+ }
99
+ catch (error) {
100
+ logger(`Erreur lors de la validation: ${error}`);
101
+ return originalDiagnostics;
102
+ }
103
+ };
104
+ // ============================================================
105
+ // INTERCEPTION OPTIONNELLE: getQuickInfoAtPosition
106
+ // Affiche les infos DI au survol (future feature)
107
+ // ============================================================
108
+ // proxy.getQuickInfoAtPosition = (fileName: string, position: number) => {
109
+ // const original = originalLS.getQuickInfoAtPosition(fileName, position)
110
+ // // Ajouter des infos sur les dépendances...
111
+ // return original
112
+ // }
113
+ /**
114
+ * Valide les dépendances DI et retourne les diagnostics
115
+ */
116
+ function validateDI(program, currentFile, log) {
117
+ const checker = program.getTypeChecker();
118
+ const engine = new ValidationEngine_1.ValidationEngine(typescript, checker, log);
119
+ // Log des fichiers sources disponibles dans le program
120
+ const sourceFiles = program.getSourceFiles();
121
+ const projectFiles = sourceFiles.filter(sf => !sf.isDeclarationFile && !sf.fileName.includes('node_modules'));
122
+ info.project.projectService.logger.info(`[DI-Validator] Programme: ${projectFiles.length} fichier(s) source(s) projet`);
123
+ for (const sf of projectFiles.slice(0, 10)) {
124
+ info.project.projectService.logger.info(`[DI-Validator] - ${sf.fileName}`);
125
+ }
126
+ // Validation complète du programme
127
+ const errors = engine.validate(program);
128
+ info.project.projectService.logger.info(`[DI-Validator] Validation: ${errors.length} erreur(s) totale(s) trouvée(s)`);
129
+ // Filtrer les erreurs pour le fichier courant
130
+ const fileErrors = errors.filter(error => error.file.fileName === currentFile.fileName);
131
+ info.project.projectService.logger.info(`[DI-Validator] Fichier ${currentFile.fileName}: ${fileErrors.length} erreur(s)`);
132
+ return engine.convertToDiagnostics(fileErrors);
133
+ }
134
+ return proxy;
135
+ }
136
+ return {
137
+ create,
138
+ getExternalFiles: getExternalFilesImpl,
139
+ onConfigurationChanged: onConfigurationChangedImpl,
140
+ };
141
+ }
142
+ // Export CommonJS requis pour les plugins TypeScript
143
+ module.exports = init;
144
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/LanguageServer/plugin/index.ts"],"names":[],"mappings":";;AAEA,yDAAqD;AAErD;;GAEG;AACH,SAAS,cAAc,CAAC,UAAyB;IAC7C,gEAAgE;IAChE,OAAQ,UAAkB,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;AAChF,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB;IACzB,OAAO,EAAE,CAAA;AACb,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B,CAAC,OAAuB;IACvD,iDAAiD;AACrD,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,IAAI,CAAC,OAAkC;IAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;IAErC,SAAS,MAAM,CAAC,IAAgC;QAC5C,MAAM,MAAM,GAAmB,IAAI,CAAC,MAAM,IAAI,EAAE,CAAA;QAEhD,uCAAuC;QACvC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE;YAC7B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC,CAAA;QACpE,CAAC,CAAA;QAED,QAAQ,CAAC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nF,CAAA;YAED,OAAO,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAA;QAClD,CAAC;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,OAAO;QACH,MAAM;QACN,gBAAgB,EAAE,oBAAoB;QACtC,sBAAsB,EAAE,0BAA0B;KACrD,CAAA;AACL,CAAC;AAED,qDAAqD;AACrD,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA"}
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "diligent-plugin",
3
+ "type": "commonjs",
4
+ "main": "index.js"
5
+ }
6
+
@@ -0,0 +1,152 @@
1
+ import type ts from 'typescript';
2
+ /**
3
+ * Identifiant unique pour un token d'injection
4
+ * Format: "TYPE:path/to/file.ts:position" ou "STRING:literal" ou "CLASS:path:name"
5
+ */
6
+ export type TokenId = string;
7
+ /**
8
+ * Types de tokens supportés
9
+ */
10
+ export type TokenType = 'symbol' | 'class' | 'string' | 'unknown';
11
+ /**
12
+ * Représente un token d'injection normalisé
13
+ */
14
+ export interface NormalizedToken {
15
+ /** Identifiant unique calculé pour comparaison */
16
+ id: TokenId;
17
+ /** Type du token */
18
+ type: TokenType;
19
+ /** Nom lisible pour les messages d'erreur */
20
+ displayName: string;
21
+ /** Noeud AST original */
22
+ node: ts.Node;
23
+ /** Fichier source */
24
+ sourceFile: ts.SourceFile;
25
+ /** Position dans le fichier */
26
+ position: number;
27
+ /** Symbole TypeScript du token (pour vérification de type) */
28
+ symbol?: ts.Symbol;
29
+ }
30
+ /**
31
+ * Représente un provider enregistré dans une configuration
32
+ */
33
+ export interface RegisteredProvider {
34
+ /** Token sous lequel le provider est enregistré */
35
+ token: NormalizedToken;
36
+ /** Classe qui implémente le provider (si applicable) */
37
+ providerClass?: ts.Symbol;
38
+ /** Nom de la classe provider */
39
+ providerClassName?: string;
40
+ /** Type d'enregistrement */
41
+ registrationType: 'class' | 'symbol-provider' | 'value' | 'factory';
42
+ /** Noeud AST de l'enregistrement */
43
+ node: ts.Node;
44
+ /** Type TypeScript du provider (pour vérification de compatibilité) */
45
+ providerType?: ts.Type;
46
+ }
47
+ /**
48
+ * Représente une dépendance requise par un constructeur
49
+ */
50
+ export interface RequiredDependency {
51
+ /** Token requis */
52
+ token: NormalizedToken;
53
+ /** Index du paramètre dans le constructeur */
54
+ parameterIndex: number;
55
+ /** Noeud du paramètre */
56
+ parameterNode: ts.ParameterDeclaration;
57
+ /** Méthode d'injection: décorateur @inject ou type implicite */
58
+ injectionMethod: 'decorator' | 'type';
59
+ /** Type attendu de la dépendance */
60
+ expectedType?: ts.Type;
61
+ }
62
+ /**
63
+ * Représente l'analyse d'une classe injectable
64
+ */
65
+ export interface AnalyzedClass {
66
+ /** Symbole de la classe */
67
+ symbol: ts.Symbol;
68
+ /** Nom de la classe */
69
+ name: string;
70
+ /** Fichier source de la déclaration */
71
+ sourceFile: ts.SourceFile;
72
+ /** Noeud de déclaration */
73
+ declaration: ts.ClassDeclaration;
74
+ /** Dépendances du constructeur */
75
+ dependencies: RequiredDependency[];
76
+ }
77
+ /**
78
+ * Représente une configuration analysée (Builder ou Partial)
79
+ */
80
+ export interface AnalyzedConfig {
81
+ /** Type de configuration */
82
+ type: 'builder' | 'partial';
83
+ /** Identifiant du builder (si applicable) */
84
+ builderId?: string;
85
+ /** Nom de la variable (si assignée) */
86
+ variableName?: string;
87
+ /** Symbole de la variable de config */
88
+ symbol?: ts.Symbol;
89
+ /** Providers enregistrés directement dans cette config */
90
+ localProviders: RegisteredProvider[];
91
+ /** Tokens fournis (calculé avec héritage) */
92
+ providedTokens: Map<TokenId, RegisteredProvider>;
93
+ /** Références aux configs parentes (extends) */
94
+ parentConfigs: ts.Symbol[];
95
+ /** Noeud de l'appel defineBuilderConfig/definePartialConfig */
96
+ callNode: ts.CallExpression;
97
+ /** Fichier source */
98
+ sourceFile: ts.SourceFile;
99
+ }
100
+ /**
101
+ * Erreur de validation DI
102
+ */
103
+ export interface DIValidationError {
104
+ /** Message d'erreur */
105
+ message: string;
106
+ /** Fichier où reporter l'erreur */
107
+ file: ts.SourceFile;
108
+ /** Position de début */
109
+ start: number;
110
+ /** Longueur du span */
111
+ length: number;
112
+ /** Informations connexes (ex: où la dépendance est requise) */
113
+ relatedInformation?: Array<{
114
+ file: ts.SourceFile;
115
+ start: number;
116
+ length: number;
117
+ message: string;
118
+ }>;
119
+ }
120
+ /**
121
+ * Configuration du plugin
122
+ */
123
+ export interface DIPluginConfig {
124
+ /** Mode verbeux pour debug */
125
+ verbose?: boolean;
126
+ /** Nom des fonctions de config à détecter */
127
+ configFunctions?: {
128
+ builder: string;
129
+ partial: string;
130
+ };
131
+ }
132
+ /**
133
+ * Cache pour un fichier source
134
+ */
135
+ export interface FileCache {
136
+ /** Version du fichier (pour invalidation) */
137
+ version: string;
138
+ /** Classes analysées dans ce fichier */
139
+ analyzedClasses: Map<string, AnalyzedClass>;
140
+ /** Configs analysées dans ce fichier */
141
+ analyzedConfigs: AnalyzedConfig[];
142
+ }
143
+ /**
144
+ * État global du validateur
145
+ */
146
+ export interface ValidatorState {
147
+ /** Cache par fichier */
148
+ fileCache: Map<string, FileCache>;
149
+ /** Set des configs visitées (détection de cycles) */
150
+ visitedConfigs: Set<ts.Symbol>;
151
+ }
152
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/LanguageServer/plugin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAEhC;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAE5B;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAA;AAEjE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,kDAAkD;IAClD,EAAE,EAAE,OAAO,CAAA;IACX,oBAAoB;IACpB,IAAI,EAAE,SAAS,CAAA;IACf,6CAA6C;IAC7C,WAAW,EAA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,MAAM,CAAA;KAClB,CAAA;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAA;IACf,wCAAwC;IACxC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,wCAAwC;IACxC,eAAe,EAAE,cAAc,EAAE,CAAA;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,wBAAwB;IACxB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACjC,qDAAqD;IACrD,cAAc,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;CACjC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/LanguageServer/plugin/types.ts"],"names":[],"mappings":""}