@effect/language-service 0.30.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 +1 -0
- package/cli.js +90 -1
- package/cli.js.map +1 -1
- package/index.js +90 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +90 -1
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -2974,6 +2974,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2974
2974
|
);
|
|
2975
2975
|
if (isSome2(parsedContextTag)) {
|
|
2976
2976
|
let accessors2 = void 0;
|
|
2977
|
+
let dependencies = void 0;
|
|
2977
2978
|
if (wholeCall.arguments.length >= 2) {
|
|
2978
2979
|
const args2 = wholeCall.arguments[1];
|
|
2979
2980
|
if (ts.isObjectLiteralExpression(args2)) {
|
|
@@ -2981,6 +2982,9 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2981
2982
|
if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && property.name.text === "accessors" && property.initializer && property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
2982
2983
|
accessors2 = true;
|
|
2983
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
|
+
}
|
|
2984
2988
|
}
|
|
2985
2989
|
}
|
|
2986
2990
|
}
|
|
@@ -2989,7 +2993,8 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2989
2993
|
className: atLocation.name,
|
|
2990
2994
|
selfTypeNode,
|
|
2991
2995
|
args: wholeCall.arguments,
|
|
2992
|
-
accessors: accessors2
|
|
2996
|
+
accessors: accessors2,
|
|
2997
|
+
dependencies
|
|
2993
2998
|
};
|
|
2994
2999
|
}
|
|
2995
3000
|
}
|
|
@@ -4081,6 +4086,89 @@ var missingEffectError = createDiagnostic({
|
|
|
4081
4086
|
})
|
|
4082
4087
|
});
|
|
4083
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
|
+
|
|
4084
4172
|
// src/diagnostics/missingReturnYieldStar.ts
|
|
4085
4173
|
var missingReturnYieldStar = createDiagnostic({
|
|
4086
4174
|
name: "missingReturnYieldStar",
|
|
@@ -4861,6 +4949,7 @@ var diagnostics = [
|
|
|
4861
4949
|
duplicatePackage,
|
|
4862
4950
|
missingEffectContext,
|
|
4863
4951
|
missingEffectError,
|
|
4952
|
+
missingEffectServiceDependency,
|
|
4864
4953
|
floatingEffect,
|
|
4865
4954
|
missingStarInYieldEffectGen,
|
|
4866
4955
|
unnecessaryEffectGen,
|