@effect/language-service 0.29.0 → 0.31.0
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/README.md +3 -24
- package/cli.js +467 -3
- package/cli.js.map +1 -1
- package/index.js +502 -38
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +467 -3
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -2339,6 +2339,36 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2339
2339
|
"TypeParser.effectSubtype",
|
|
2340
2340
|
(type) => type
|
|
2341
2341
|
);
|
|
2342
|
+
const importedSchemaModule = cachedBy(
|
|
2343
|
+
fn("TypeParser.importedSchemaModule")(function* (node) {
|
|
2344
|
+
const type = typeChecker.getTypeAtLocation(node);
|
|
2345
|
+
const propertySymbol = typeChecker.getPropertyOfType(type, "Class");
|
|
2346
|
+
if (!propertySymbol) {
|
|
2347
|
+
return yield* typeParserIssue("Type has no 'Class' property", type, node);
|
|
2348
|
+
}
|
|
2349
|
+
if (!ts.isExpression(node)) {
|
|
2350
|
+
return yield* typeParserIssue("Node is not an expression", type, node);
|
|
2351
|
+
}
|
|
2352
|
+
return node;
|
|
2353
|
+
}),
|
|
2354
|
+
"TypeParser.importedSchemaModule",
|
|
2355
|
+
(node) => node
|
|
2356
|
+
);
|
|
2357
|
+
const importedContextModule = cachedBy(
|
|
2358
|
+
fn("TypeParser.importedContextModule")(function* (node) {
|
|
2359
|
+
const type = typeChecker.getTypeAtLocation(node);
|
|
2360
|
+
const propertySymbol = typeChecker.getPropertyOfType(type, "Tag");
|
|
2361
|
+
if (!propertySymbol) {
|
|
2362
|
+
return yield* typeParserIssue("Type has no 'Tag' property", type, node);
|
|
2363
|
+
}
|
|
2364
|
+
if (!ts.isExpression(node)) {
|
|
2365
|
+
return yield* typeParserIssue("Node is not an expression", type, node);
|
|
2366
|
+
}
|
|
2367
|
+
return node;
|
|
2368
|
+
}),
|
|
2369
|
+
"TypeParser.importedContextModule",
|
|
2370
|
+
(node) => node
|
|
2371
|
+
);
|
|
2342
2372
|
const importedEffectModule = cachedBy(
|
|
2343
2373
|
fn("TypeParser.importedEffectModule")(function* (node) {
|
|
2344
2374
|
const type = typeChecker.getTypeAtLocation(node);
|
|
@@ -2695,6 +2725,226 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2695
2725
|
"TypeParser.promiseLike",
|
|
2696
2726
|
(type) => type
|
|
2697
2727
|
);
|
|
2728
|
+
const extendsSchemaClass = cachedBy(
|
|
2729
|
+
fn("TypeParser.extendsSchemaClass")(function* (atLocation) {
|
|
2730
|
+
if (!atLocation.name) {
|
|
2731
|
+
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
2732
|
+
}
|
|
2733
|
+
const heritageClauses = atLocation.heritageClauses;
|
|
2734
|
+
if (!heritageClauses) {
|
|
2735
|
+
return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
|
|
2736
|
+
}
|
|
2737
|
+
for (const heritageClause of heritageClauses) {
|
|
2738
|
+
for (const typeX of heritageClause.types) {
|
|
2739
|
+
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
2740
|
+
const expression = typeX.expression;
|
|
2741
|
+
if (ts.isCallExpression(expression)) {
|
|
2742
|
+
const schemaCall = expression.expression;
|
|
2743
|
+
if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
|
|
2744
|
+
const selfTypeNode = schemaCall.typeArguments[0];
|
|
2745
|
+
const schemaIdentifier = schemaCall.expression;
|
|
2746
|
+
if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && schemaIdentifier.name.text === "Class") {
|
|
2747
|
+
const parsedSchemaModule = yield* pipe(
|
|
2748
|
+
importedSchemaModule(schemaIdentifier.expression),
|
|
2749
|
+
option
|
|
2750
|
+
);
|
|
2751
|
+
if (isSome2(parsedSchemaModule)) {
|
|
2752
|
+
return {
|
|
2753
|
+
className: atLocation.name,
|
|
2754
|
+
selfTypeNode,
|
|
2755
|
+
Schema: parsedSchemaModule.value
|
|
2756
|
+
};
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
return yield* typeParserIssue("Class does not extend Schema.Class", void 0, atLocation);
|
|
2765
|
+
}),
|
|
2766
|
+
"TypeParser.extendsSchemaClass",
|
|
2767
|
+
(atLocation) => atLocation
|
|
2768
|
+
);
|
|
2769
|
+
const extendsSchemaTaggedClass = cachedBy(
|
|
2770
|
+
fn("TypeParser.extendsSchemaTaggedClass")(function* (atLocation) {
|
|
2771
|
+
if (!atLocation.name) {
|
|
2772
|
+
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
2773
|
+
}
|
|
2774
|
+
const heritageClauses = atLocation.heritageClauses;
|
|
2775
|
+
if (!heritageClauses) {
|
|
2776
|
+
return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
|
|
2777
|
+
}
|
|
2778
|
+
for (const heritageClause of heritageClauses) {
|
|
2779
|
+
for (const typeX of heritageClause.types) {
|
|
2780
|
+
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
2781
|
+
const expression = typeX.expression;
|
|
2782
|
+
if (ts.isCallExpression(expression)) {
|
|
2783
|
+
const tagCall = expression.expression;
|
|
2784
|
+
if (ts.isCallExpression(tagCall)) {
|
|
2785
|
+
const schemaCall = tagCall.expression;
|
|
2786
|
+
if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
|
|
2787
|
+
const selfTypeNode = schemaCall.typeArguments[0];
|
|
2788
|
+
const schemaIdentifier = schemaCall.expression;
|
|
2789
|
+
if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && schemaIdentifier.name.text === "TaggedClass") {
|
|
2790
|
+
const parsedSchemaModule = yield* pipe(
|
|
2791
|
+
importedSchemaModule(schemaIdentifier.expression),
|
|
2792
|
+
option
|
|
2793
|
+
);
|
|
2794
|
+
if (isSome2(parsedSchemaModule)) {
|
|
2795
|
+
return {
|
|
2796
|
+
className: atLocation.name,
|
|
2797
|
+
selfTypeNode,
|
|
2798
|
+
Schema: parsedSchemaModule.value
|
|
2799
|
+
};
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
return yield* typeParserIssue("Class does not extend Schema.TaggedClass", void 0, atLocation);
|
|
2809
|
+
}),
|
|
2810
|
+
"TypeParser.extendsSchemaTaggedClass",
|
|
2811
|
+
(atLocation) => atLocation
|
|
2812
|
+
);
|
|
2813
|
+
const extendsSchemaTaggedError = cachedBy(
|
|
2814
|
+
fn("TypeParser.extendsSchemaTaggedError")(function* (atLocation) {
|
|
2815
|
+
if (!atLocation.name) {
|
|
2816
|
+
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
2817
|
+
}
|
|
2818
|
+
const heritageClauses = atLocation.heritageClauses;
|
|
2819
|
+
if (!heritageClauses) {
|
|
2820
|
+
return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
|
|
2821
|
+
}
|
|
2822
|
+
for (const heritageClause of heritageClauses) {
|
|
2823
|
+
for (const typeX of heritageClause.types) {
|
|
2824
|
+
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
2825
|
+
const expression = typeX.expression;
|
|
2826
|
+
if (ts.isCallExpression(expression)) {
|
|
2827
|
+
const tagCall = expression.expression;
|
|
2828
|
+
if (ts.isCallExpression(tagCall)) {
|
|
2829
|
+
const schemaCall = tagCall.expression;
|
|
2830
|
+
if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
|
|
2831
|
+
const selfTypeNode = schemaCall.typeArguments[0];
|
|
2832
|
+
const schemaIdentifier = schemaCall.expression;
|
|
2833
|
+
if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && schemaIdentifier.name.text === "TaggedError") {
|
|
2834
|
+
const parsedSchemaModule = yield* pipe(
|
|
2835
|
+
importedSchemaModule(schemaIdentifier.expression),
|
|
2836
|
+
option
|
|
2837
|
+
);
|
|
2838
|
+
if (isSome2(parsedSchemaModule)) {
|
|
2839
|
+
return {
|
|
2840
|
+
className: atLocation.name,
|
|
2841
|
+
selfTypeNode,
|
|
2842
|
+
Schema: parsedSchemaModule.value
|
|
2843
|
+
};
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
return yield* typeParserIssue("Class does not extend Schema.TaggedError", void 0, atLocation);
|
|
2853
|
+
}),
|
|
2854
|
+
"TypeParser.extendsSchemaTaggedError",
|
|
2855
|
+
(atLocation) => atLocation
|
|
2856
|
+
);
|
|
2857
|
+
const extendsSchemaTaggedRequest = cachedBy(
|
|
2858
|
+
fn("TypeParser.extendsSchemaTaggedRequest")(function* (atLocation) {
|
|
2859
|
+
if (!atLocation.name) {
|
|
2860
|
+
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
2861
|
+
}
|
|
2862
|
+
const heritageClauses = atLocation.heritageClauses;
|
|
2863
|
+
if (!heritageClauses) {
|
|
2864
|
+
return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
|
|
2865
|
+
}
|
|
2866
|
+
for (const heritageClause of heritageClauses) {
|
|
2867
|
+
for (const typeX of heritageClause.types) {
|
|
2868
|
+
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
2869
|
+
const expression = typeX.expression;
|
|
2870
|
+
if (ts.isCallExpression(expression)) {
|
|
2871
|
+
const tagCall = expression.expression;
|
|
2872
|
+
if (ts.isCallExpression(tagCall)) {
|
|
2873
|
+
const schemaCall = tagCall.expression;
|
|
2874
|
+
if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
|
|
2875
|
+
const selfTypeNode = schemaCall.typeArguments[0];
|
|
2876
|
+
const schemaIdentifier = schemaCall.expression;
|
|
2877
|
+
if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && schemaIdentifier.name.text === "TaggedRequest") {
|
|
2878
|
+
const parsedSchemaModule = yield* pipe(
|
|
2879
|
+
importedSchemaModule(schemaIdentifier.expression),
|
|
2880
|
+
option
|
|
2881
|
+
);
|
|
2882
|
+
if (isSome2(parsedSchemaModule)) {
|
|
2883
|
+
return {
|
|
2884
|
+
className: atLocation.name,
|
|
2885
|
+
selfTypeNode,
|
|
2886
|
+
Schema: parsedSchemaModule.value
|
|
2887
|
+
};
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
return yield* typeParserIssue("Class does not extend Schema.TaggedRequest", void 0, atLocation);
|
|
2897
|
+
}),
|
|
2898
|
+
"TypeParser.extendsSchemaTaggedRequest",
|
|
2899
|
+
(atLocation) => atLocation
|
|
2900
|
+
);
|
|
2901
|
+
const extendsContextTag = cachedBy(
|
|
2902
|
+
fn("TypeParser.extendsContextTag")(function* (atLocation) {
|
|
2903
|
+
if (!atLocation.name) {
|
|
2904
|
+
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
2905
|
+
}
|
|
2906
|
+
const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
|
|
2907
|
+
if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
|
|
2908
|
+
const type = typeChecker.getTypeOfSymbol(classSym);
|
|
2909
|
+
const heritageClauses = atLocation.heritageClauses;
|
|
2910
|
+
if (!heritageClauses) {
|
|
2911
|
+
return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
|
|
2912
|
+
}
|
|
2913
|
+
for (const heritageClause of heritageClauses) {
|
|
2914
|
+
for (const typeX of heritageClause.types) {
|
|
2915
|
+
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
2916
|
+
const wholeCall = typeX.expression;
|
|
2917
|
+
if (ts.isCallExpression(wholeCall)) {
|
|
2918
|
+
const contextTagCall = wholeCall.expression;
|
|
2919
|
+
if (ts.isCallExpression(contextTagCall) && wholeCall.typeArguments && wholeCall.typeArguments.length > 0) {
|
|
2920
|
+
const contextTagIdentifier = contextTagCall.expression;
|
|
2921
|
+
const selfTypeNode = wholeCall.typeArguments[0];
|
|
2922
|
+
if (ts.isPropertyAccessExpression(contextTagIdentifier) && ts.isIdentifier(contextTagIdentifier.name) && contextTagIdentifier.name.text === "Tag") {
|
|
2923
|
+
const parsedContextModule = yield* pipe(
|
|
2924
|
+
importedContextModule(contextTagIdentifier.expression),
|
|
2925
|
+
option
|
|
2926
|
+
);
|
|
2927
|
+
if (isSome2(parsedContextModule)) {
|
|
2928
|
+
const tagType = yield* contextTag(type, atLocation);
|
|
2929
|
+
return {
|
|
2930
|
+
className: atLocation.name,
|
|
2931
|
+
selfTypeNode,
|
|
2932
|
+
args: contextTagCall.arguments,
|
|
2933
|
+
Identifier: tagType.Identifier,
|
|
2934
|
+
Tag: parsedContextModule.value
|
|
2935
|
+
};
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
return yield* typeParserIssue("Class does not extend Context.Tag", void 0, atLocation);
|
|
2944
|
+
}),
|
|
2945
|
+
"TypeParser.extendsContextTag",
|
|
2946
|
+
(atLocation) => atLocation
|
|
2947
|
+
);
|
|
2698
2948
|
const extendsEffectService = cachedBy(
|
|
2699
2949
|
fn("TypeParser.extendsEffectService")(function* (atLocation) {
|
|
2700
2950
|
if (!atLocation.name) {
|
|
@@ -2724,6 +2974,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2724
2974
|
);
|
|
2725
2975
|
if (isSome2(parsedContextTag)) {
|
|
2726
2976
|
let accessors2 = void 0;
|
|
2977
|
+
let dependencies = void 0;
|
|
2727
2978
|
if (wholeCall.arguments.length >= 2) {
|
|
2728
2979
|
const args2 = wholeCall.arguments[1];
|
|
2729
2980
|
if (ts.isObjectLiteralExpression(args2)) {
|
|
@@ -2731,6 +2982,9 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2731
2982
|
if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && property.name.text === "accessors" && property.initializer && property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
2732
2983
|
accessors2 = true;
|
|
2733
2984
|
}
|
|
2985
|
+
if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && property.name.text === "dependencies" && property.initializer && ts.isArrayLiteralExpression(property.initializer)) {
|
|
2986
|
+
dependencies = property.initializer.elements;
|
|
2987
|
+
}
|
|
2734
2988
|
}
|
|
2735
2989
|
}
|
|
2736
2990
|
}
|
|
@@ -2739,7 +2993,8 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2739
2993
|
className: atLocation.name,
|
|
2740
2994
|
selfTypeNode,
|
|
2741
2995
|
args: wholeCall.arguments,
|
|
2742
|
-
accessors: accessors2
|
|
2996
|
+
accessors: accessors2,
|
|
2997
|
+
dependencies
|
|
2743
2998
|
};
|
|
2744
2999
|
}
|
|
2745
3000
|
}
|
|
@@ -2770,7 +3025,12 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2770
3025
|
pipeCall,
|
|
2771
3026
|
scopeType,
|
|
2772
3027
|
promiseLike,
|
|
2773
|
-
extendsEffectService
|
|
3028
|
+
extendsEffectService,
|
|
3029
|
+
extendsContextTag,
|
|
3030
|
+
extendsSchemaClass,
|
|
3031
|
+
extendsSchemaTaggedClass,
|
|
3032
|
+
extendsSchemaTaggedError,
|
|
3033
|
+
extendsSchemaTaggedRequest
|
|
2774
3034
|
};
|
|
2775
3035
|
}
|
|
2776
3036
|
|
|
@@ -3109,6 +3369,104 @@ var effectDataClasses = createCompletion({
|
|
|
3109
3369
|
})
|
|
3110
3370
|
});
|
|
3111
3371
|
|
|
3372
|
+
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/encoding/common.js
|
|
3373
|
+
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
3374
|
+
|
|
3375
|
+
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/encoding/base64.js
|
|
3376
|
+
var encode = (bytes) => {
|
|
3377
|
+
const length = bytes.length;
|
|
3378
|
+
let result = "";
|
|
3379
|
+
let i;
|
|
3380
|
+
for (i = 2; i < length; i += 3) {
|
|
3381
|
+
result += base64abc[bytes[i - 2] >> 2];
|
|
3382
|
+
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
3383
|
+
result += base64abc[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
|
|
3384
|
+
result += base64abc[bytes[i] & 63];
|
|
3385
|
+
}
|
|
3386
|
+
if (i === length + 1) {
|
|
3387
|
+
result += base64abc[bytes[i - 2] >> 2];
|
|
3388
|
+
result += base64abc[(bytes[i - 2] & 3) << 4];
|
|
3389
|
+
result += "==";
|
|
3390
|
+
}
|
|
3391
|
+
if (i === length) {
|
|
3392
|
+
result += base64abc[bytes[i - 2] >> 2];
|
|
3393
|
+
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
3394
|
+
result += base64abc[(bytes[i - 1] & 15) << 2];
|
|
3395
|
+
result += "=";
|
|
3396
|
+
}
|
|
3397
|
+
return result;
|
|
3398
|
+
};
|
|
3399
|
+
var base64abc = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"];
|
|
3400
|
+
|
|
3401
|
+
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/encoding/base64Url.js
|
|
3402
|
+
var encode2 = (data) => encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
3403
|
+
|
|
3404
|
+
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Encoding.js
|
|
3405
|
+
var encodeBase64Url = (input) => typeof input === "string" ? encode2(encoder.encode(input)) : encode2(input);
|
|
3406
|
+
|
|
3407
|
+
// src/diagnostics/classSelfMismatch.ts
|
|
3408
|
+
var classSelfMismatch = createDiagnostic({
|
|
3409
|
+
name: "classSelfMismatch",
|
|
3410
|
+
code: 20,
|
|
3411
|
+
severity: "error",
|
|
3412
|
+
apply: fn("classSelfMismatch.apply")(function* (sourceFile, report) {
|
|
3413
|
+
const ts = yield* service(TypeScriptApi);
|
|
3414
|
+
const typeParser = yield* service(TypeParser);
|
|
3415
|
+
const nodeToVisit = [];
|
|
3416
|
+
const appendNodeToVisit = (node) => {
|
|
3417
|
+
nodeToVisit.push(node);
|
|
3418
|
+
return void 0;
|
|
3419
|
+
};
|
|
3420
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
3421
|
+
while (nodeToVisit.length > 0) {
|
|
3422
|
+
const node = nodeToVisit.shift();
|
|
3423
|
+
if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
3424
|
+
const result = yield* pipe(
|
|
3425
|
+
typeParser.extendsEffectService(node),
|
|
3426
|
+
orElse2(() => typeParser.extendsContextTag(node)),
|
|
3427
|
+
orElse2(() => typeParser.extendsSchemaClass(node)),
|
|
3428
|
+
orElse2(() => typeParser.extendsSchemaTaggedClass(node)),
|
|
3429
|
+
orElse2(() => typeParser.extendsSchemaTaggedError(node)),
|
|
3430
|
+
orElse2(() => typeParser.extendsSchemaTaggedRequest(node)),
|
|
3431
|
+
orElse2(() => void_)
|
|
3432
|
+
);
|
|
3433
|
+
if (result) {
|
|
3434
|
+
const { className, selfTypeNode } = result;
|
|
3435
|
+
let actualName = "";
|
|
3436
|
+
if (ts.isTypeReferenceNode(selfTypeNode)) {
|
|
3437
|
+
if (ts.isIdentifier(selfTypeNode.typeName)) {
|
|
3438
|
+
actualName = selfTypeNode.typeName.text;
|
|
3439
|
+
} else if (ts.isQualifiedName(selfTypeNode.typeName)) {
|
|
3440
|
+
actualName = selfTypeNode.typeName.right.text;
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
const expectedName = className.text;
|
|
3444
|
+
if (actualName !== expectedName) {
|
|
3445
|
+
report({
|
|
3446
|
+
location: selfTypeNode,
|
|
3447
|
+
messageText: `Self type parameter should be '${expectedName}'`,
|
|
3448
|
+
fixes: [{
|
|
3449
|
+
fixName: "classSelfMismatch_fix",
|
|
3450
|
+
description: `Replace '${actualName}' with '${expectedName}'`,
|
|
3451
|
+
apply: gen(function* () {
|
|
3452
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
3453
|
+
const typeArgs = ts.isTypeReferenceNode(selfTypeNode) ? selfTypeNode.typeArguments : void 0;
|
|
3454
|
+
const newTypeReference = ts.factory.createTypeReferenceNode(
|
|
3455
|
+
ts.factory.createIdentifier(expectedName),
|
|
3456
|
+
typeArgs
|
|
3457
|
+
);
|
|
3458
|
+
changeTracker.replaceNode(sourceFile, selfTypeNode, newTypeReference);
|
|
3459
|
+
})
|
|
3460
|
+
}]
|
|
3461
|
+
});
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
3466
|
+
}
|
|
3467
|
+
})
|
|
3468
|
+
});
|
|
3469
|
+
|
|
3112
3470
|
// src/diagnostics/duplicatePackage.ts
|
|
3113
3471
|
var checkedPackagesCache = /* @__PURE__ */ new Map();
|
|
3114
3472
|
var programResolvedCacheSize = /* @__PURE__ */ new Map();
|
|
@@ -3728,6 +4086,89 @@ var missingEffectError = createDiagnostic({
|
|
|
3728
4086
|
})
|
|
3729
4087
|
});
|
|
3730
4088
|
|
|
4089
|
+
// src/diagnostics/missingEffectServiceDependency.ts
|
|
4090
|
+
var missingEffectServiceDependency = createDiagnostic({
|
|
4091
|
+
name: "missingEffectServiceDependency",
|
|
4092
|
+
code: 21,
|
|
4093
|
+
severity: "off",
|
|
4094
|
+
apply: fn("missingEffectServiceDependency.apply")(function* (sourceFile, report) {
|
|
4095
|
+
const ts = yield* service(TypeScriptApi);
|
|
4096
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
4097
|
+
const typeParser = yield* service(TypeParser);
|
|
4098
|
+
const nodeToVisit = [];
|
|
4099
|
+
const appendNodeToVisit = (node) => {
|
|
4100
|
+
nodeToVisit.push(node);
|
|
4101
|
+
return void 0;
|
|
4102
|
+
};
|
|
4103
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
4104
|
+
while (nodeToVisit.length > 0) {
|
|
4105
|
+
const node = nodeToVisit.shift();
|
|
4106
|
+
if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
4107
|
+
const serviceResult = yield* pipe(
|
|
4108
|
+
typeParser.extendsEffectService(node),
|
|
4109
|
+
orElse2(() => void_)
|
|
4110
|
+
);
|
|
4111
|
+
if (serviceResult) {
|
|
4112
|
+
const { className, dependencies } = serviceResult;
|
|
4113
|
+
const classSymbol = typeChecker.getSymbolAtLocation(className);
|
|
4114
|
+
if (classSymbol) {
|
|
4115
|
+
const classType = typeChecker.getTypeOfSymbol(classSymbol);
|
|
4116
|
+
const defaultWithoutDepsProperty = typeChecker.getPropertyOfType(classType, "DefaultWithoutDependencies");
|
|
4117
|
+
const defaultProperty = defaultWithoutDepsProperty || typeChecker.getPropertyOfType(classType, "Default");
|
|
4118
|
+
if (defaultProperty) {
|
|
4119
|
+
const defaultType = typeChecker.getTypeOfSymbolAtLocation(defaultProperty, node);
|
|
4120
|
+
const layerResult = yield* pipe(
|
|
4121
|
+
typeParser.layerType(defaultType, node),
|
|
4122
|
+
orElse2(() => void_)
|
|
4123
|
+
);
|
|
4124
|
+
if (layerResult) {
|
|
4125
|
+
const servicesMemory = /* @__PURE__ */ new Map();
|
|
4126
|
+
const excludeNever = (type) => succeed((type.flags & ts.TypeFlags.Never) !== 0);
|
|
4127
|
+
const { allIndexes: requiredIndexes } = yield* appendToUniqueTypesMap(
|
|
4128
|
+
servicesMemory,
|
|
4129
|
+
layerResult.RIn,
|
|
4130
|
+
excludeNever
|
|
4131
|
+
);
|
|
4132
|
+
const providedIndexes = /* @__PURE__ */ new Set();
|
|
4133
|
+
const dependenciesToProcess = dependencies || [];
|
|
4134
|
+
for (const depExpression of dependenciesToProcess) {
|
|
4135
|
+
const depType = typeChecker.getTypeAtLocation(depExpression);
|
|
4136
|
+
const depLayerResult = yield* pipe(
|
|
4137
|
+
typeParser.layerType(depType, depExpression),
|
|
4138
|
+
orElse2(() => void_)
|
|
4139
|
+
);
|
|
4140
|
+
if (depLayerResult) {
|
|
4141
|
+
const { allIndexes } = yield* appendToUniqueTypesMap(
|
|
4142
|
+
servicesMemory,
|
|
4143
|
+
depLayerResult.ROut,
|
|
4144
|
+
excludeNever
|
|
4145
|
+
);
|
|
4146
|
+
for (const index of allIndexes) {
|
|
4147
|
+
providedIndexes.add(index);
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4151
|
+
const missingIndexes = requiredIndexes.filter((index) => !providedIndexes.has(index));
|
|
4152
|
+
if (missingIndexes.length > 0) {
|
|
4153
|
+
const missingTypes = missingIndexes.map((index) => servicesMemory.get(index));
|
|
4154
|
+
const missingTypeNames = missingTypes.map((t) => typeChecker.typeToString(t));
|
|
4155
|
+
const message = missingTypeNames.length === 1 ? `Service '${missingTypeNames[0]}' is required but not provided by dependencies` : `Services ${missingTypeNames.map((s) => `'${s}'`).join(", ")} are required but not provided by dependencies`;
|
|
4156
|
+
report({
|
|
4157
|
+
location: className,
|
|
4158
|
+
messageText: message,
|
|
4159
|
+
fixes: []
|
|
4160
|
+
});
|
|
4161
|
+
}
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
4168
|
+
}
|
|
4169
|
+
})
|
|
4170
|
+
});
|
|
4171
|
+
|
|
3731
4172
|
// src/diagnostics/missingReturnYieldStar.ts
|
|
3732
4173
|
var missingReturnYieldStar = createDiagnostic({
|
|
3733
4174
|
name: "missingReturnYieldStar",
|
|
@@ -4447,11 +4888,68 @@ var unnecessaryPipeChain = createDiagnostic({
|
|
|
4447
4888
|
})
|
|
4448
4889
|
});
|
|
4449
4890
|
|
|
4891
|
+
// src/diagnostics/unsupportedServiceAccessors.ts
|
|
4892
|
+
var unsupportedServiceAccessors = createDiagnostic({
|
|
4893
|
+
name: "unsupportedServiceAccessors",
|
|
4894
|
+
code: 21,
|
|
4895
|
+
severity: "warning",
|
|
4896
|
+
apply: fn("unsupportedServiceAccessors.apply")(function* (sourceFile, report) {
|
|
4897
|
+
const ts = yield* service(TypeScriptApi);
|
|
4898
|
+
const nodeToVisit = [];
|
|
4899
|
+
const appendNodeToVisit = (node) => {
|
|
4900
|
+
nodeToVisit.push(node);
|
|
4901
|
+
return void 0;
|
|
4902
|
+
};
|
|
4903
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
4904
|
+
while (nodeToVisit.length > 0) {
|
|
4905
|
+
const node = nodeToVisit.shift();
|
|
4906
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
4907
|
+
if (ts.isClassDeclaration(node)) {
|
|
4908
|
+
const parseResult = yield* pipe(
|
|
4909
|
+
parse2(node),
|
|
4910
|
+
orElse2(() => succeed(null))
|
|
4911
|
+
);
|
|
4912
|
+
if (parseResult && parseResult.involvedMembers.length > 0) {
|
|
4913
|
+
const existingStaticMembers = /* @__PURE__ */ new Set();
|
|
4914
|
+
node.members?.forEach((member) => {
|
|
4915
|
+
if (ts.isPropertyDeclaration(member) && member.modifiers?.some((mod) => mod.kind === ts.SyntaxKind.StaticKeyword)) {
|
|
4916
|
+
if (member.name && ts.isIdentifier(member.name)) {
|
|
4917
|
+
existingStaticMembers.add(member.name.text);
|
|
4918
|
+
}
|
|
4919
|
+
}
|
|
4920
|
+
});
|
|
4921
|
+
const missingMembers = parseResult.involvedMembers.filter(
|
|
4922
|
+
({ property }) => !existingStaticMembers.has(property.getName())
|
|
4923
|
+
);
|
|
4924
|
+
if (missingMembers.length > 0) {
|
|
4925
|
+
const memberNames = missingMembers.map(({ property }) => `'${property.getName()}'`).join(", ");
|
|
4926
|
+
report({
|
|
4927
|
+
location: parseResult.className,
|
|
4928
|
+
messageText: `Even if accessors are enabled, accessors for ${memberNames} won't be available because the signature have generic type parameters or multiple call signatures.`,
|
|
4929
|
+
fixes: [{
|
|
4930
|
+
fixName: "unsupportedServiceAccessors_enableCodegen",
|
|
4931
|
+
description: "Enable accessors codegen",
|
|
4932
|
+
apply: gen(function* () {
|
|
4933
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
4934
|
+
const comment = "// @effect-codegens accessors\n";
|
|
4935
|
+
changeTracker.insertText(sourceFile, node.getStart(sourceFile), comment);
|
|
4936
|
+
})
|
|
4937
|
+
}]
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
}
|
|
4943
|
+
})
|
|
4944
|
+
});
|
|
4945
|
+
|
|
4450
4946
|
// src/diagnostics.ts
|
|
4451
4947
|
var diagnostics = [
|
|
4948
|
+
classSelfMismatch,
|
|
4452
4949
|
duplicatePackage,
|
|
4453
4950
|
missingEffectContext,
|
|
4454
4951
|
missingEffectError,
|
|
4952
|
+
missingEffectServiceDependency,
|
|
4455
4953
|
floatingEffect,
|
|
4456
4954
|
missingStarInYieldEffectGen,
|
|
4457
4955
|
unnecessaryEffectGen,
|
|
@@ -4467,7 +4965,8 @@ var diagnostics = [
|
|
|
4467
4965
|
unnecessaryPipeChain,
|
|
4468
4966
|
strictBooleanExpressions,
|
|
4469
4967
|
multipleEffectProvide,
|
|
4470
|
-
outdatedEffectCodegen
|
|
4968
|
+
outdatedEffectCodegen,
|
|
4969
|
+
unsupportedServiceAccessors
|
|
4471
4970
|
];
|
|
4472
4971
|
|
|
4473
4972
|
// src/completions/effectDiagnosticsComment.ts
|
|
@@ -5504,41 +6003,6 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
5504
6003
|
);
|
|
5505
6004
|
}
|
|
5506
6005
|
|
|
5507
|
-
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/encoding/common.js
|
|
5508
|
-
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
5509
|
-
|
|
5510
|
-
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/encoding/base64.js
|
|
5511
|
-
var encode = (bytes) => {
|
|
5512
|
-
const length = bytes.length;
|
|
5513
|
-
let result = "";
|
|
5514
|
-
let i;
|
|
5515
|
-
for (i = 2; i < length; i += 3) {
|
|
5516
|
-
result += base64abc[bytes[i - 2] >> 2];
|
|
5517
|
-
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
5518
|
-
result += base64abc[(bytes[i - 1] & 15) << 2 | bytes[i] >> 6];
|
|
5519
|
-
result += base64abc[bytes[i] & 63];
|
|
5520
|
-
}
|
|
5521
|
-
if (i === length + 1) {
|
|
5522
|
-
result += base64abc[bytes[i - 2] >> 2];
|
|
5523
|
-
result += base64abc[(bytes[i - 2] & 3) << 4];
|
|
5524
|
-
result += "==";
|
|
5525
|
-
}
|
|
5526
|
-
if (i === length) {
|
|
5527
|
-
result += base64abc[bytes[i - 2] >> 2];
|
|
5528
|
-
result += base64abc[(bytes[i - 2] & 3) << 4 | bytes[i - 1] >> 4];
|
|
5529
|
-
result += base64abc[(bytes[i - 1] & 15) << 2];
|
|
5530
|
-
result += "=";
|
|
5531
|
-
}
|
|
5532
|
-
return result;
|
|
5533
|
-
};
|
|
5534
|
-
var base64abc = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"];
|
|
5535
|
-
|
|
5536
|
-
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/encoding/base64Url.js
|
|
5537
|
-
var encode2 = (data) => encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
5538
|
-
|
|
5539
|
-
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Encoding.js
|
|
5540
|
-
var encodeBase64Url = (input) => typeof input === "string" ? encode2(encoder.encode(input)) : encode2(input);
|
|
5541
|
-
|
|
5542
6006
|
// node_modules/.pnpm/pako@2.1.0/node_modules/pako/dist/pako.esm.mjs
|
|
5543
6007
|
var Z_FIXED$1 = 4;
|
|
5544
6008
|
var Z_BINARY = 0;
|