@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.
- package/LICENSE +22 -0
- package/README.md +516 -0
- package/dist/index.cjs +931 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1139 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +1139 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +915 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugin/ConfigurationAnalyzer.d.ts +59 -0
- package/dist/plugin/ConfigurationAnalyzer.d.ts.map +1 -0
- package/dist/plugin/ConfigurationAnalyzer.js +321 -0
- package/dist/plugin/ConfigurationAnalyzer.js.map +1 -0
- package/dist/plugin/DependencyAnalyzer.d.ts +54 -0
- package/dist/plugin/DependencyAnalyzer.d.ts.map +1 -0
- package/dist/plugin/DependencyAnalyzer.js +208 -0
- package/dist/plugin/DependencyAnalyzer.js.map +1 -0
- package/dist/plugin/TokenNormalizer.d.ts +51 -0
- package/dist/plugin/TokenNormalizer.d.ts.map +1 -0
- package/dist/plugin/TokenNormalizer.js +208 -0
- package/dist/plugin/TokenNormalizer.js.map +1 -0
- package/dist/plugin/ValidationEngine.d.ts +53 -0
- package/dist/plugin/ValidationEngine.d.ts.map +1 -0
- package/dist/plugin/ValidationEngine.js +250 -0
- package/dist/plugin/ValidationEngine.js.map +1 -0
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +144 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/package.json +6 -0
- package/dist/plugin/types.d.ts +152 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin/types.js +3 -0
- package/dist/plugin/types.js.map +1 -0
- package/package.json +95 -0
- package/plugin.js +1 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DependencyAnalyzer = void 0;
|
|
4
|
+
const TokenNormalizer_1 = require("./TokenNormalizer");
|
|
5
|
+
/**
|
|
6
|
+
* Analyseur des dépendances de constructeur des classes injectables
|
|
7
|
+
*
|
|
8
|
+
* Détecte les dépendances via:
|
|
9
|
+
* - Décorateurs @inject(TOKEN)
|
|
10
|
+
* - Types des paramètres (injection implicite)
|
|
11
|
+
*/
|
|
12
|
+
class DependencyAnalyzer {
|
|
13
|
+
constructor(typescript, checker, logger) {
|
|
14
|
+
this.checker = checker;
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
this.typescript = typescript;
|
|
17
|
+
this.tokenNormalizer = new TokenNormalizer_1.TokenNormalizer(typescript, checker);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Analyse une classe pour extraire ses dépendances de constructeur
|
|
21
|
+
*/
|
|
22
|
+
analyzeClass(classSymbol) {
|
|
23
|
+
const declaration = this.getClassDeclaration(classSymbol);
|
|
24
|
+
if (!declaration)
|
|
25
|
+
return null;
|
|
26
|
+
const sourceFile = declaration.getSourceFile();
|
|
27
|
+
const dependencies = this.extractConstructorDependencies(declaration, sourceFile);
|
|
28
|
+
return {
|
|
29
|
+
symbol: classSymbol,
|
|
30
|
+
name: classSymbol.getName(),
|
|
31
|
+
sourceFile,
|
|
32
|
+
declaration,
|
|
33
|
+
dependencies,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Obtient la déclaration de classe depuis un symbole
|
|
38
|
+
*/
|
|
39
|
+
getClassDeclaration(symbol) {
|
|
40
|
+
const ts = this.typescript;
|
|
41
|
+
const declaration = symbol.valueDeclaration || symbol.declarations?.[0];
|
|
42
|
+
if (!declaration)
|
|
43
|
+
return null;
|
|
44
|
+
if (ts.isClassDeclaration(declaration)) {
|
|
45
|
+
return declaration;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Extrait les dépendances du constructeur d'une classe
|
|
51
|
+
*/
|
|
52
|
+
extractConstructorDependencies(classDecl, sourceFile) {
|
|
53
|
+
const ts = this.typescript;
|
|
54
|
+
const dependencies = [];
|
|
55
|
+
// Trouver le constructeur
|
|
56
|
+
const constructor = classDecl.members.find((member) => ts.isConstructorDeclaration(member));
|
|
57
|
+
if (!constructor) {
|
|
58
|
+
return dependencies;
|
|
59
|
+
}
|
|
60
|
+
// Analyser chaque paramètre
|
|
61
|
+
constructor.parameters.forEach((param, index) => {
|
|
62
|
+
const dependency = this.analyzeParameter(param, index, sourceFile);
|
|
63
|
+
if (dependency) {
|
|
64
|
+
dependencies.push(dependency);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return dependencies;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Analyse un paramètre de constructeur pour extraire sa dépendance
|
|
71
|
+
*/
|
|
72
|
+
analyzeParameter(param, index, sourceFile) {
|
|
73
|
+
// Capturer le type attendu du paramètre
|
|
74
|
+
const expectedType = param.type
|
|
75
|
+
? this.checker.getTypeFromTypeNode(param.type)
|
|
76
|
+
: undefined;
|
|
77
|
+
// Priorité 1: Décorateur @inject()
|
|
78
|
+
const injectDecorator = this.findInjectDecorator(param);
|
|
79
|
+
if (injectDecorator) {
|
|
80
|
+
const token = this.extractTokenFromDecorator(injectDecorator, sourceFile);
|
|
81
|
+
if (token) {
|
|
82
|
+
return {
|
|
83
|
+
token,
|
|
84
|
+
parameterIndex: index,
|
|
85
|
+
parameterNode: param,
|
|
86
|
+
injectionMethod: 'decorator',
|
|
87
|
+
expectedType,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Priorité 2: Type du paramètre (injection implicite)
|
|
92
|
+
if (param.type) {
|
|
93
|
+
const token = this.tokenNormalizer.normalizeFromType(param.type, sourceFile);
|
|
94
|
+
if (token && this.isInjectableType(token)) {
|
|
95
|
+
return {
|
|
96
|
+
token,
|
|
97
|
+
parameterIndex: index,
|
|
98
|
+
parameterNode: param,
|
|
99
|
+
injectionMethod: 'type',
|
|
100
|
+
expectedType,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Trouve le décorateur @inject sur un paramètre
|
|
108
|
+
*/
|
|
109
|
+
findInjectDecorator(param) {
|
|
110
|
+
const ts = this.typescript;
|
|
111
|
+
const decorators = ts.getDecorators(param);
|
|
112
|
+
if (!decorators)
|
|
113
|
+
return null;
|
|
114
|
+
for (const decorator of decorators) {
|
|
115
|
+
if (ts.isCallExpression(decorator.expression)) {
|
|
116
|
+
const callee = decorator.expression.expression;
|
|
117
|
+
if (ts.isIdentifier(callee) && callee.text === 'inject') {
|
|
118
|
+
// Vérifier sémantiquement que c'est bien @inject de tsyringe
|
|
119
|
+
if (this.isInjectFromTsyringe(callee)) {
|
|
120
|
+
return decorator;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Vérifie si un identifiant 'inject' provient de tsyringe
|
|
129
|
+
*/
|
|
130
|
+
isInjectFromTsyringe(node) {
|
|
131
|
+
const ts = this.typescript;
|
|
132
|
+
const symbol = this.checker.getSymbolAtLocation(node);
|
|
133
|
+
if (!symbol)
|
|
134
|
+
return true; // Assume true si pas de symbole
|
|
135
|
+
// Résoudre l'alias
|
|
136
|
+
let resolved = symbol;
|
|
137
|
+
while (resolved.flags & ts.SymbolFlags.Alias) {
|
|
138
|
+
try {
|
|
139
|
+
resolved = this.checker.getAliasedSymbol(resolved);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const declaration = resolved.valueDeclaration || resolved.declarations?.[0];
|
|
146
|
+
if (!declaration)
|
|
147
|
+
return true;
|
|
148
|
+
const fileName = declaration.getSourceFile().fileName;
|
|
149
|
+
return fileName.includes('tsyringe') || !fileName.includes('node_modules');
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Extrait le token depuis un décorateur @inject(TOKEN)
|
|
153
|
+
*/
|
|
154
|
+
extractTokenFromDecorator(decorator, sourceFile) {
|
|
155
|
+
const ts = this.typescript;
|
|
156
|
+
if (!ts.isCallExpression(decorator.expression)) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const args = decorator.expression.arguments;
|
|
160
|
+
if (args.length === 0) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
return this.tokenNormalizer.normalize(args[0], sourceFile);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Vérifie si un token représente un type injectable (pas primitif)
|
|
167
|
+
*/
|
|
168
|
+
isInjectableType(token) {
|
|
169
|
+
if (!token)
|
|
170
|
+
return false;
|
|
171
|
+
// Exclure les types primitifs et built-in
|
|
172
|
+
const nonInjectableTypes = new Set([
|
|
173
|
+
'string', 'number', 'boolean', 'object', 'any', 'unknown',
|
|
174
|
+
'never', 'void', 'null', 'undefined', 'symbol', 'bigint',
|
|
175
|
+
'String', 'Number', 'Boolean', 'Object', 'Function',
|
|
176
|
+
'Array', 'Map', 'Set', 'Promise', 'Date', 'RegExp', 'Error',
|
|
177
|
+
]);
|
|
178
|
+
// Vérifier par le nom d'affichage
|
|
179
|
+
if (nonInjectableTypes.has(token.displayName)) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
// Seules les classes sont injectables implicitement
|
|
183
|
+
return token.type === 'class';
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Analyse toutes les classes d'un fichier source
|
|
187
|
+
*/
|
|
188
|
+
analyzeSourceFile(sourceFile) {
|
|
189
|
+
const classes = [];
|
|
190
|
+
this.visitNode(sourceFile, classes);
|
|
191
|
+
return classes;
|
|
192
|
+
}
|
|
193
|
+
visitNode(node, classes) {
|
|
194
|
+
const ts = this.typescript;
|
|
195
|
+
if (ts.isClassDeclaration(node) && node.name) {
|
|
196
|
+
const symbol = this.checker.getSymbolAtLocation(node.name);
|
|
197
|
+
if (symbol) {
|
|
198
|
+
const analyzed = this.analyzeClass(symbol);
|
|
199
|
+
if (analyzed && analyzed.dependencies.length > 0) {
|
|
200
|
+
classes.push(analyzed);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
ts.forEachChild(node, (child) => this.visitNode(child, classes));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
exports.DependencyAnalyzer = DependencyAnalyzer;
|
|
208
|
+
//# sourceMappingURL=DependencyAnalyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DependencyAnalyzer.js","sourceRoot":"","sources":["../../src/LanguageServer/plugin/DependencyAnalyzer.ts"],"names":[],"mappings":";;;AAEA,uDAAmD;AAEnD;;;;;;GAMG;AACH,MAAa,kBAAkB;IAI3B,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,eAAe,GAAG,IAAI,iCAAe,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACnE,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,WAAsB;QAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAA;QACzD,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAA;QAE7B,MAAM,UAAU,GAAG,WAAW,CAAC,aAAa,EAAE,CAAA;QAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,8BAA8B,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;QAEjF,OAAO;YACH,MAAM,EAAE,WAAW;YACnB,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE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,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QACnC,OAAO,OAAO,CAAA;IAClB,CAAC;IAEO,SAAS,CAAC,IAAa,EAAE,OAAwB;QACrD,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAA;QAE1B,IAAI,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC1D,IAAI,MAAM,EAAE,CAAC;gBACT,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;gBAC1C,IAAI,QAAQ,IAAI,QAAQ,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC/C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;gBAC1B,CAAC;YACL,CAAC;QACL,CAAC;QAED,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;IAC7E,CAAC;CACJ;AAjPD,gDAiPC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type ts from 'typescript';
|
|
2
|
+
import type { NormalizedToken } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Service de normalisation des tokens d'injection
|
|
5
|
+
*
|
|
6
|
+
* Génère des identifiants uniques pour comparer les tokens,
|
|
7
|
+
* qu'ils soient des symboles, des classes ou des chaînes.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TokenNormalizer {
|
|
10
|
+
private checker;
|
|
11
|
+
private typescript;
|
|
12
|
+
constructor(typescript: typeof ts, checker: ts.TypeChecker);
|
|
13
|
+
/**
|
|
14
|
+
* Normalise un token depuis un noeud AST
|
|
15
|
+
* Supporte: Symbol, Class, String literal, MemberExpression (TOKENS.X)
|
|
16
|
+
*/
|
|
17
|
+
normalize(node: ts.Node, sourceFile: ts.SourceFile): NormalizedToken | null;
|
|
18
|
+
/**
|
|
19
|
+
* Normalise un identifiant (classe ou variable symbol)
|
|
20
|
+
*/
|
|
21
|
+
private normalizeIdentifier;
|
|
22
|
+
/**
|
|
23
|
+
* Normalise un accès membre (TOKENS.Logger)
|
|
24
|
+
*/
|
|
25
|
+
private normalizeMemberExpression;
|
|
26
|
+
/**
|
|
27
|
+
* Normalise un appel Symbol('name')
|
|
28
|
+
*/
|
|
29
|
+
private normalizeCallExpression;
|
|
30
|
+
/**
|
|
31
|
+
* Crée un token normalisé depuis un symbole TypeScript
|
|
32
|
+
*/
|
|
33
|
+
private createTokenFromSymbol;
|
|
34
|
+
/**
|
|
35
|
+
* Détermine le type d'un token depuis son symbole
|
|
36
|
+
*/
|
|
37
|
+
private determineTokenType;
|
|
38
|
+
/**
|
|
39
|
+
* Résout les alias d'import pour obtenir le symbole original
|
|
40
|
+
*/
|
|
41
|
+
private resolveAlias;
|
|
42
|
+
/**
|
|
43
|
+
* Compare deux tokens pour vérifier s'ils sont identiques
|
|
44
|
+
*/
|
|
45
|
+
areTokensEqual(token1: NormalizedToken, token2: NormalizedToken): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Normalise un token depuis un type (pour injection implicite par type)
|
|
48
|
+
*/
|
|
49
|
+
normalizeFromType(typeNode: ts.TypeNode, sourceFile: ts.SourceFile): NormalizedToken | null;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=TokenNormalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenNormalizer.d.ts","sourceRoot":"","sources":["../../src/LanguageServer/plugin/TokenNormalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAEzD;;;;;GAKG;AACH,qBAAa,eAAe;IAKpB,OAAO,CAAC,OAAO;IAJnB,OAAO,CAAC,UAAU,CAAW;gBAGzB,UAAU,EAAE,OAAO,EAAE,EACb,OAAO,EAAE,EAAE,CAAC,WAAW;IAKnC;;;OAGG;IACH,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,eAAe,GAAG,IAAI;IAiC3E;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAc3B;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAgBjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAyB/B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAyB7B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAyC1B;;OAEG;IACH,OAAO,CAAC,YAAY;IAyBpB;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO;IAIzE;;OAEG;IACH,iBAAiB,CACb,QAAQ,EAAE,EAAE,CAAC,QAAQ,EACrB,UAAU,EAAE,EAAE,CAAC,UAAU,GAC1B,eAAe,GAAG,IAAI;CA0B5B"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenNormalizer = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Service de normalisation des tokens d'injection
|
|
6
|
+
*
|
|
7
|
+
* Génère des identifiants uniques pour comparer les tokens,
|
|
8
|
+
* qu'ils soient des symboles, des classes ou des chaînes.
|
|
9
|
+
*/
|
|
10
|
+
class TokenNormalizer {
|
|
11
|
+
constructor(typescript, checker) {
|
|
12
|
+
this.checker = checker;
|
|
13
|
+
this.typescript = typescript;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Normalise un token depuis un noeud AST
|
|
17
|
+
* Supporte: Symbol, Class, String literal, MemberExpression (TOKENS.X)
|
|
18
|
+
*/
|
|
19
|
+
normalize(node, sourceFile) {
|
|
20
|
+
const ts = this.typescript;
|
|
21
|
+
// Cas 1: String literal - @inject('API_KEY')
|
|
22
|
+
if (ts.isStringLiteral(node)) {
|
|
23
|
+
return {
|
|
24
|
+
id: `STRING:${node.text}`,
|
|
25
|
+
type: 'string',
|
|
26
|
+
displayName: `"${node.text}"`,
|
|
27
|
+
node,
|
|
28
|
+
sourceFile,
|
|
29
|
+
position: node.getStart(sourceFile),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// Cas 2: Identifier simple - @inject(MyClass) ou @inject(MY_TOKEN)
|
|
33
|
+
if (ts.isIdentifier(node)) {
|
|
34
|
+
return this.normalizeIdentifier(node, sourceFile);
|
|
35
|
+
}
|
|
36
|
+
// Cas 3: Member expression - @inject(TOKENS.Logger)
|
|
37
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
38
|
+
return this.normalizeMemberExpression(node, sourceFile);
|
|
39
|
+
}
|
|
40
|
+
// Cas 4: Call expression - Symbol('name')
|
|
41
|
+
if (ts.isCallExpression(node)) {
|
|
42
|
+
return this.normalizeCallExpression(node, sourceFile);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Normalise un identifiant (classe ou variable symbol)
|
|
48
|
+
*/
|
|
49
|
+
normalizeIdentifier(node, sourceFile) {
|
|
50
|
+
const symbol = this.checker.getSymbolAtLocation(node);
|
|
51
|
+
if (!symbol)
|
|
52
|
+
return null;
|
|
53
|
+
// Résoudre les alias (imports)
|
|
54
|
+
const resolvedSymbol = this.resolveAlias(symbol);
|
|
55
|
+
if (!resolvedSymbol)
|
|
56
|
+
return null;
|
|
57
|
+
return this.createTokenFromSymbol(resolvedSymbol, node, sourceFile);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Normalise un accès membre (TOKENS.Logger)
|
|
61
|
+
*/
|
|
62
|
+
normalizeMemberExpression(node, sourceFile) {
|
|
63
|
+
const symbol = this.checker.getSymbolAtLocation(node);
|
|
64
|
+
if (!symbol)
|
|
65
|
+
return null;
|
|
66
|
+
const resolvedSymbol = this.resolveAlias(symbol);
|
|
67
|
+
if (!resolvedSymbol)
|
|
68
|
+
return null;
|
|
69
|
+
// Construire le nom d'affichage complet
|
|
70
|
+
const displayName = node.getText(sourceFile);
|
|
71
|
+
return this.createTokenFromSymbol(resolvedSymbol, node, sourceFile, displayName);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Normalise un appel Symbol('name')
|
|
75
|
+
*/
|
|
76
|
+
normalizeCallExpression(node, sourceFile) {
|
|
77
|
+
const ts = this.typescript;
|
|
78
|
+
// Vérifier si c'est Symbol(...)
|
|
79
|
+
if (ts.isIdentifier(node.expression) && node.expression.text === 'Symbol') {
|
|
80
|
+
const arg = node.arguments[0];
|
|
81
|
+
if (arg && ts.isStringLiteral(arg)) {
|
|
82
|
+
// Symbol('name') inline - utiliser la position comme ID unique
|
|
83
|
+
return {
|
|
84
|
+
id: `INLINE_SYMBOL:${sourceFile.fileName}:${node.getStart(sourceFile)}`,
|
|
85
|
+
type: 'symbol',
|
|
86
|
+
displayName: `Symbol('${arg.text}')`,
|
|
87
|
+
node,
|
|
88
|
+
sourceFile,
|
|
89
|
+
position: node.getStart(sourceFile),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Crée un token normalisé depuis un symbole TypeScript
|
|
97
|
+
*/
|
|
98
|
+
createTokenFromSymbol(symbol, originalNode, sourceFile, displayNameOverride) {
|
|
99
|
+
const declaration = symbol.valueDeclaration || symbol.declarations?.[0];
|
|
100
|
+
if (!declaration)
|
|
101
|
+
return null;
|
|
102
|
+
const declSourceFile = declaration.getSourceFile();
|
|
103
|
+
const type = this.determineTokenType(symbol, declaration);
|
|
104
|
+
// ID unique basé sur le fichier et la position de déclaration
|
|
105
|
+
const id = `${type.toUpperCase()}:${declSourceFile.fileName}:${declaration.getStart(declSourceFile)}`;
|
|
106
|
+
return {
|
|
107
|
+
id,
|
|
108
|
+
type,
|
|
109
|
+
displayName: displayNameOverride || symbol.getName(),
|
|
110
|
+
node: originalNode,
|
|
111
|
+
sourceFile,
|
|
112
|
+
position: originalNode.getStart(sourceFile),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Détermine le type d'un token depuis son symbole
|
|
117
|
+
*/
|
|
118
|
+
determineTokenType(symbol, declaration) {
|
|
119
|
+
const ts = this.typescript;
|
|
120
|
+
// Vérifier si c'est une classe
|
|
121
|
+
if (ts.isClassDeclaration(declaration)) {
|
|
122
|
+
return 'class';
|
|
123
|
+
}
|
|
124
|
+
// Vérifier si c'est un symbole (variable initialisée avec Symbol())
|
|
125
|
+
if (ts.isVariableDeclaration(declaration)) {
|
|
126
|
+
const varDecl = declaration;
|
|
127
|
+
if (varDecl.initializer && ts.isCallExpression(varDecl.initializer)) {
|
|
128
|
+
const callExpr = varDecl.initializer;
|
|
129
|
+
if (ts.isIdentifier(callExpr.expression) && callExpr.expression.text === 'Symbol') {
|
|
130
|
+
return 'symbol';
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Vérifier si c'est une propriété d'objet avec Symbol()
|
|
135
|
+
if (ts.isPropertyAssignment(declaration)) {
|
|
136
|
+
const propDecl = declaration;
|
|
137
|
+
if (propDecl.initializer && ts.isCallExpression(propDecl.initializer)) {
|
|
138
|
+
const callExpr = propDecl.initializer;
|
|
139
|
+
if (ts.isIdentifier(callExpr.expression) && callExpr.expression.text === 'Symbol') {
|
|
140
|
+
return 'symbol';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Vérifier le type via le TypeChecker
|
|
145
|
+
const type = this.checker.getTypeOfSymbolAtLocation(symbol, declaration);
|
|
146
|
+
const typeString = this.checker.typeToString(type);
|
|
147
|
+
if (typeString === 'symbol' || typeString.includes('unique symbol')) {
|
|
148
|
+
return 'symbol';
|
|
149
|
+
}
|
|
150
|
+
return 'unknown';
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Résout les alias d'import pour obtenir le symbole original
|
|
154
|
+
*/
|
|
155
|
+
resolveAlias(symbol) {
|
|
156
|
+
const ts = this.typescript;
|
|
157
|
+
// Suivre la chaîne d'alias
|
|
158
|
+
let current = symbol;
|
|
159
|
+
const visited = new Set();
|
|
160
|
+
while (current.flags & ts.SymbolFlags.Alias) {
|
|
161
|
+
if (visited.has(current)) {
|
|
162
|
+
// Cycle détecté
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
visited.add(current);
|
|
166
|
+
try {
|
|
167
|
+
current = this.checker.getAliasedSymbol(current);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
// Erreur de résolution
|
|
171
|
+
return current;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return current;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Compare deux tokens pour vérifier s'ils sont identiques
|
|
178
|
+
*/
|
|
179
|
+
areTokensEqual(token1, token2) {
|
|
180
|
+
return token1.id === token2.id;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Normalise un token depuis un type (pour injection implicite par type)
|
|
184
|
+
*/
|
|
185
|
+
normalizeFromType(typeNode, sourceFile) {
|
|
186
|
+
const ts = this.typescript;
|
|
187
|
+
if (!ts.isTypeReferenceNode(typeNode)) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const typeName = typeNode.typeName;
|
|
191
|
+
if (ts.isIdentifier(typeName)) {
|
|
192
|
+
return this.normalizeIdentifier(typeName, sourceFile);
|
|
193
|
+
}
|
|
194
|
+
if (ts.isQualifiedName(typeName)) {
|
|
195
|
+
// Pour les types qualifiés comme Namespace.Type
|
|
196
|
+
const symbol = this.checker.getSymbolAtLocation(typeName);
|
|
197
|
+
if (symbol) {
|
|
198
|
+
const resolvedSymbol = this.resolveAlias(symbol);
|
|
199
|
+
if (resolvedSymbol) {
|
|
200
|
+
return this.createTokenFromSymbol(resolvedSymbol, typeNode, sourceFile);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
exports.TokenNormalizer = TokenNormalizer;
|
|
208
|
+
//# sourceMappingURL=TokenNormalizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenNormalizer.js","sourceRoot":"","sources":["../../src/LanguageServer/plugin/TokenNormalizer.ts"],"names":[],"mappings":";;;AAGA;;;;;GAKG;AACH,MAAa,eAAe;IAGxB,YACI,UAAqB,EACb,OAAuB;QAAvB,YAAO,GAAP,OAAO,CAAgB;QAE/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAChC,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,IAAa,EAAE,UAAyB;QAC9C,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAA;QAE1B,6CAA6C;QAC7C,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,OAAO;gBACH,EAAE,EAAE,UAAU,IAAI,CAAC,IAAI,EAAE;gBACzB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,IAAI,CAAC,IAAI,GAAG;gBAC7B,IAAI;gBACJ,UAAU;gBACV,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;aACtC,CAAA;QACL,CAAC;QAED,mEAAmE;QACnE,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;QACrD,CAAC;QAED,oDAAoD;QACpD,IAAI,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,CAAC;YACtC,OAAO,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AAA;QAE1B,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACpC,OAAO,IAAI,CAAA;QACf,CAAC;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA;QAElC,IAAI,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QACzD,CAAC;QAED,IAAI,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,gDAAgD;YAChD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAA;YACzD,IAAI,MAAM,EAAE,CAAC;gBACT,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;gBAChD,IAAI,cAAc,EAAE,CAAC;oBACjB,OAAO,IAAI,CAAC,qBAAqB,CAAC,cAAc,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;gBAC3E,CAAC;YACL,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AA1PD,0CA0PC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type ts from 'typescript';
|
|
2
|
+
import type { DIValidationError } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Moteur de validation des dépendances DI
|
|
5
|
+
*
|
|
6
|
+
* Orchestre l'analyse des configurations et des classes pour
|
|
7
|
+
* détecter les dépendances manquantes.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ValidationEngine {
|
|
10
|
+
private checker;
|
|
11
|
+
private logger;
|
|
12
|
+
private configAnalyzer;
|
|
13
|
+
private dependencyAnalyzer;
|
|
14
|
+
private typescript;
|
|
15
|
+
constructor(typescript: typeof ts, checker: ts.TypeChecker, logger: (msg: string) => void);
|
|
16
|
+
/**
|
|
17
|
+
* Valide un programme TypeScript et retourne les erreurs
|
|
18
|
+
*/
|
|
19
|
+
validate(program: ts.Program): DIValidationError[];
|
|
20
|
+
/**
|
|
21
|
+
* Collecte toutes les configurations du programme
|
|
22
|
+
*/
|
|
23
|
+
private collectAllConfigs;
|
|
24
|
+
/**
|
|
25
|
+
* Collecte toutes les classes analysées du programme
|
|
26
|
+
*/
|
|
27
|
+
private collectAllClasses;
|
|
28
|
+
/**
|
|
29
|
+
* Valide une configuration spécifique
|
|
30
|
+
*/
|
|
31
|
+
private validateConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Collecte toutes les classes qui doivent être validées pour une configuration
|
|
34
|
+
*/
|
|
35
|
+
private collectClassesToValidate;
|
|
36
|
+
/**
|
|
37
|
+
* Valide les dépendances d'une classe contre les tokens fournis
|
|
38
|
+
*/
|
|
39
|
+
private validateClassDependencies;
|
|
40
|
+
/**
|
|
41
|
+
* Vérifie la compatibilité de type entre le provider enregistré et le type attendu
|
|
42
|
+
*/
|
|
43
|
+
private checkTypeCompatibility;
|
|
44
|
+
/**
|
|
45
|
+
* Crée une erreur de dépendance manquante
|
|
46
|
+
*/
|
|
47
|
+
private createMissingDependencyError;
|
|
48
|
+
/**
|
|
49
|
+
* Convertit les erreurs de validation en diagnostics TypeScript
|
|
50
|
+
*/
|
|
51
|
+
convertToDiagnostics(errors: DIValidationError[]): ts.Diagnostic[];
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=ValidationEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationEngine.d.ts","sourceRoot":"","sources":["../../src/LanguageServer/plugin/ValidationEngine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAChC,OAAO,KAAK,EAGR,iBAAiB,EAIpB,MAAM,SAAS,CAAA;AAIhB;;;;;GAKG;AACH,qBAAa,gBAAgB;IAOrB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IAPlB,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,kBAAkB,CAAoB;IAC9C,OAAO,CAAC,UAAU,CAAW;gBAGzB,UAAU,EAAE,OAAO,EAAE,EACb,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI;IAOzC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,GAAG,iBAAiB,EAAE;IAsBlD;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiBzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAezB;;OAEG;IACH,OAAO,CAAC,cAAc;IAyCtB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAkChC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAoCjC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA6D9B;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAmCpC;;OAEG;IACH,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE;CA4BrE"}
|