@effect/language-service 0.75.0 → 0.75.1
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/cli.js +250 -168
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +249 -168
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +347 -206
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +249 -167
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -3102,6 +3102,7 @@ var externals = (graph, config = {}) => {
|
|
|
3102
3102
|
};
|
|
3103
3103
|
|
|
3104
3104
|
// src/core/Nano.ts
|
|
3105
|
+
var debugPerformance = false;
|
|
3105
3106
|
var NanoTag = class {
|
|
3106
3107
|
constructor(key) {
|
|
3107
3108
|
this.key = key;
|
|
@@ -3199,7 +3200,6 @@ var NanoFiber = class {
|
|
|
3199
3200
|
_yielded = void 0;
|
|
3200
3201
|
_services = {};
|
|
3201
3202
|
_cache = {};
|
|
3202
|
-
_perf = false;
|
|
3203
3203
|
_lastSpan = "";
|
|
3204
3204
|
runLoop(nano) {
|
|
3205
3205
|
let current = nano;
|
|
@@ -3230,7 +3230,7 @@ var WithSpanProto = {
|
|
|
3230
3230
|
...PrimitiveProto,
|
|
3231
3231
|
[evaluate](fiber) {
|
|
3232
3232
|
const [fa, name] = this[args];
|
|
3233
|
-
if (!
|
|
3233
|
+
if (!debugPerformance) return fa;
|
|
3234
3234
|
const previousSpan = fiber._lastSpan;
|
|
3235
3235
|
fiber._lastSpan = name;
|
|
3236
3236
|
const start = performance.now();
|
|
@@ -3438,6 +3438,21 @@ var all = fn("all")(
|
|
|
3438
3438
|
return results;
|
|
3439
3439
|
}
|
|
3440
3440
|
);
|
|
3441
|
+
var getTimings = () => {
|
|
3442
|
+
if (!debugPerformance) return [];
|
|
3443
|
+
const result = [];
|
|
3444
|
+
for (const key in timings) {
|
|
3445
|
+
result.push([key, timings[key] / (timingsCount[key] || 1), timingsCount[key], timings[key]]);
|
|
3446
|
+
}
|
|
3447
|
+
result.sort((a, b) => b[3] - a[3]);
|
|
3448
|
+
const lines = [];
|
|
3449
|
+
for (const [name, avg, hits, total] of result) {
|
|
3450
|
+
lines.push(
|
|
3451
|
+
`${name.padEnd(75)} tot ${total.toFixed(2).padStart(10)}ms avg ${avg.toFixed(2).padStart(10)}ms ${hits.toString().padStart(10)} hits`
|
|
3452
|
+
);
|
|
3453
|
+
}
|
|
3454
|
+
return lines;
|
|
3455
|
+
};
|
|
3441
3456
|
|
|
3442
3457
|
// src/core/LanguageServicePluginOptions.ts
|
|
3443
3458
|
var LanguageServicePluginOptions = Tag("PluginOptions");
|
|
@@ -4200,6 +4215,26 @@ var getApplicableRefactors = fn("LSP.getApplicableRefactors")(function* (refacto
|
|
|
4200
4215
|
}
|
|
4201
4216
|
return effectRefactors;
|
|
4202
4217
|
});
|
|
4218
|
+
function codeFixNameToFullyQualifiedName(name) {
|
|
4219
|
+
return `@effect/language-service/codefixes/${name}`;
|
|
4220
|
+
}
|
|
4221
|
+
var codeFixesToApplicableRefactor = fn("LSP.codeFixesToApplicableRefactor")(function* (codeFixes, sourceFile, positionOrRange) {
|
|
4222
|
+
const effectRefactors = [];
|
|
4223
|
+
const range = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
|
|
4224
|
+
const inRangeCodeFixes = codeFixes.filter((_) => _.start <= range.pos && _.end >= range.end);
|
|
4225
|
+
for (const codeFix of inRangeCodeFixes) {
|
|
4226
|
+
effectRefactors.push({
|
|
4227
|
+
name: codeFixNameToFullyQualifiedName(codeFix.fixName),
|
|
4228
|
+
description: "Quick Fix: " + codeFix.description,
|
|
4229
|
+
actions: [{
|
|
4230
|
+
name: codeFixNameToFullyQualifiedName(codeFix.fixName),
|
|
4231
|
+
description: "Quick Fix: " + codeFix.description,
|
|
4232
|
+
kind: "refactor.rewrite.codeFixEffect." + codeFix.fixName
|
|
4233
|
+
}]
|
|
4234
|
+
});
|
|
4235
|
+
}
|
|
4236
|
+
return effectRefactors;
|
|
4237
|
+
});
|
|
4203
4238
|
var getEditsForRefactor = fn("LSP.getEditsForRefactor")(function* (refactors2, sourceFile, positionOrRange, refactorName) {
|
|
4204
4239
|
const refactor = refactors2.find((refactor2) => refactorNameToFullyQualifiedName(refactor2.name) === refactorName);
|
|
4205
4240
|
if (!refactor) {
|
|
@@ -4208,6 +4243,16 @@ var getEditsForRefactor = fn("LSP.getEditsForRefactor")(function* (refactors2, s
|
|
|
4208
4243
|
const textRange = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
|
|
4209
4244
|
return yield* refactor.apply(sourceFile, textRange);
|
|
4210
4245
|
});
|
|
4246
|
+
var getEditsForCodeFixes = fn("LSP.getEditsForCodeFixes")(function* (codeFixes, positionOrRange, refactorName) {
|
|
4247
|
+
const textRange = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
|
|
4248
|
+
const fixToRun = codeFixes.find(
|
|
4249
|
+
(_) => codeFixNameToFullyQualifiedName(_.fixName) === refactorName && _.start <= textRange.pos && _.end >= textRange.end
|
|
4250
|
+
);
|
|
4251
|
+
if (!fixToRun) {
|
|
4252
|
+
return yield* fail3(new RefactorNotApplicableError());
|
|
4253
|
+
}
|
|
4254
|
+
return fixToRun;
|
|
4255
|
+
});
|
|
4211
4256
|
var getCompletionsAtPosition = fn("LSP.getCompletionsAtPosition")(function* (completions2, sourceFile, position, options, formatCodeSettings) {
|
|
4212
4257
|
let effectCompletions = [];
|
|
4213
4258
|
for (const completion of completions2) {
|
|
@@ -4291,7 +4336,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
4291
4336
|
message: ts.DiagnosticCategory.Message,
|
|
4292
4337
|
suggestion: ts.DiagnosticCategory.Suggestion
|
|
4293
4338
|
};
|
|
4294
|
-
const execute = (
|
|
4339
|
+
const execute = fn("LSP.execute")(function* (rule) {
|
|
4295
4340
|
const diagnostics2 = [];
|
|
4296
4341
|
const codeFixes = [];
|
|
4297
4342
|
const ruleNameLowered = rule.name.toLowerCase();
|
|
@@ -5138,6 +5183,9 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
5138
5183
|
if (signatures.length !== 1) {
|
|
5139
5184
|
return typeParserIssue("Covariant type has no call signature", type);
|
|
5140
5185
|
}
|
|
5186
|
+
if (signatures[0].typeParameters && signatures[0].typeParameters.length > 0) {
|
|
5187
|
+
return typeParserIssue("Invariant type should not have type parameters", type);
|
|
5188
|
+
}
|
|
5141
5189
|
return succeed(typeChecker.getReturnTypeOfSignature(signatures[0]));
|
|
5142
5190
|
}
|
|
5143
5191
|
function contravariantTypeArgument(type) {
|
|
@@ -5145,6 +5193,9 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
5145
5193
|
if (signatures.length !== 1) {
|
|
5146
5194
|
return typeParserIssue("Contravariant type has no call signature", type);
|
|
5147
5195
|
}
|
|
5196
|
+
if (signatures[0].typeParameters && signatures[0].typeParameters.length > 0) {
|
|
5197
|
+
return typeParserIssue("Invariant type should not have type parameters", type);
|
|
5198
|
+
}
|
|
5148
5199
|
return succeed(typeCheckerUtils.getTypeParameterAtPosition(signatures[0], 0));
|
|
5149
5200
|
}
|
|
5150
5201
|
function invariantTypeArgument(type) {
|
|
@@ -5152,6 +5203,9 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
5152
5203
|
if (signatures.length !== 1) {
|
|
5153
5204
|
return typeParserIssue("Invariant type has no call signature", type);
|
|
5154
5205
|
}
|
|
5206
|
+
if (signatures[0].typeParameters && signatures[0].typeParameters.length > 0) {
|
|
5207
|
+
return typeParserIssue("Invariant type should not have type parameters", type);
|
|
5208
|
+
}
|
|
5155
5209
|
return succeed(typeChecker.getReturnTypeOfSignature(signatures[0]));
|
|
5156
5210
|
}
|
|
5157
5211
|
const pipeableType = cachedBy(
|
|
@@ -7145,25 +7199,27 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
7145
7199
|
return succeed(typeNode);
|
|
7146
7200
|
})
|
|
7147
7201
|
);
|
|
7148
|
-
const proxySignature = (
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7202
|
+
const proxySignature = fn("writeTagClassAccessors.proxySignature")(
|
|
7203
|
+
function* (signature, atLocation2, className2) {
|
|
7204
|
+
const signatureDeclaration = typeChecker.signatureToSignatureDeclaration(
|
|
7205
|
+
signature,
|
|
7206
|
+
ts.SyntaxKind.FunctionType,
|
|
7207
|
+
atLocation2,
|
|
7208
|
+
ts.NodeBuilderFlags.NoTruncation
|
|
7209
|
+
);
|
|
7210
|
+
if (!signatureDeclaration) return yield* fail3("error generating signature");
|
|
7211
|
+
const returnType = yield* generateReturnType(
|
|
7212
|
+
typeChecker.getReturnTypeOfSignature(signature),
|
|
7213
|
+
atLocation2,
|
|
7214
|
+
className2
|
|
7215
|
+
);
|
|
7216
|
+
return ts.factory.createFunctionTypeNode(
|
|
7217
|
+
signatureDeclaration.typeParameters,
|
|
7218
|
+
signatureDeclaration.parameters,
|
|
7219
|
+
returnType
|
|
7220
|
+
);
|
|
7221
|
+
}
|
|
7222
|
+
);
|
|
7167
7223
|
for (const { property, propertyType } of involvedMembers) {
|
|
7168
7224
|
const callSignatures = [];
|
|
7169
7225
|
let propertyDeclaration = void 0;
|
|
@@ -7300,7 +7356,7 @@ var annotate = createCodegen({
|
|
|
7300
7356
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
7301
7357
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
7302
7358
|
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
7303
|
-
const parse3 = (
|
|
7359
|
+
const parse3 = fn("annotate.parse")(function* (node) {
|
|
7304
7360
|
let variableDeclarations = [];
|
|
7305
7361
|
const result = [];
|
|
7306
7362
|
if (ts.isVariableStatement(node)) {
|
|
@@ -7980,7 +8036,7 @@ var typeToSchema = createCodegen({
|
|
|
7980
8036
|
new CodegenNotApplicableError("the typeToSchema codegen can be used only once per file")
|
|
7981
8037
|
);
|
|
7982
8038
|
}
|
|
7983
|
-
const parse3 = (
|
|
8039
|
+
const parse3 = fn("typeToSchema.parse")(function* (node) {
|
|
7984
8040
|
if (!ts.isTypeAliasDeclaration(node)) {
|
|
7985
8041
|
return yield* fail3(
|
|
7986
8042
|
new CodegenNotApplicableError(
|
|
@@ -8268,32 +8324,38 @@ var catchAllToMapError = createDiagnostic({
|
|
|
8268
8324
|
return void 0;
|
|
8269
8325
|
};
|
|
8270
8326
|
const getEffectFailCallInfo = (body) => {
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
return { failCall: body, failArg: body.arguments[0] };
|
|
8279
|
-
}
|
|
8280
|
-
}
|
|
8281
|
-
if (ts.isBlock(body)) {
|
|
8282
|
-
const statements = body.statements;
|
|
8283
|
-
if (statements.length === 1) {
|
|
8284
|
-
const stmt = statements[0];
|
|
8285
|
-
if (ts.isReturnStatement(stmt) && stmt.expression && ts.isCallExpression(stmt.expression)) {
|
|
8286
|
-
const isFailCall = yield* pipe(
|
|
8287
|
-
typeParser.isNodeReferenceToEffectModuleApi("fail")(stmt.expression.expression),
|
|
8288
|
-
orUndefined
|
|
8289
|
-
);
|
|
8290
|
-
if (isFailCall && stmt.expression.arguments.length >= 1) {
|
|
8291
|
-
return { failCall: stmt.expression, failArg: stmt.expression.arguments[0] };
|
|
8292
|
-
}
|
|
8327
|
+
if (ts.isCallExpression(body)) {
|
|
8328
|
+
return pipe(
|
|
8329
|
+
typeParser.isNodeReferenceToEffectModuleApi("fail")(body.expression),
|
|
8330
|
+
orUndefined,
|
|
8331
|
+
map8((isFailCall) => {
|
|
8332
|
+
if (isFailCall && body.arguments.length >= 1) {
|
|
8333
|
+
return { failCall: body, failArg: body.arguments[0] };
|
|
8293
8334
|
}
|
|
8335
|
+
return void 0;
|
|
8336
|
+
})
|
|
8337
|
+
);
|
|
8338
|
+
}
|
|
8339
|
+
if (ts.isBlock(body)) {
|
|
8340
|
+
const statements = body.statements;
|
|
8341
|
+
if (statements.length === 1) {
|
|
8342
|
+
const stmt = statements[0];
|
|
8343
|
+
if (ts.isReturnStatement(stmt) && stmt.expression && ts.isCallExpression(stmt.expression)) {
|
|
8344
|
+
const callExpr = stmt.expression;
|
|
8345
|
+
return pipe(
|
|
8346
|
+
typeParser.isNodeReferenceToEffectModuleApi("fail")(callExpr.expression),
|
|
8347
|
+
orUndefined,
|
|
8348
|
+
map8((isFailCall) => {
|
|
8349
|
+
if (isFailCall && callExpr.arguments.length >= 1) {
|
|
8350
|
+
return { failCall: callExpr, failArg: callExpr.arguments[0] };
|
|
8351
|
+
}
|
|
8352
|
+
return void 0;
|
|
8353
|
+
})
|
|
8354
|
+
);
|
|
8294
8355
|
}
|
|
8295
8356
|
}
|
|
8296
|
-
}
|
|
8357
|
+
}
|
|
8358
|
+
return void_;
|
|
8297
8359
|
};
|
|
8298
8360
|
const flows = yield* typeParser.pipingFlows(true)(sourceFile);
|
|
8299
8361
|
for (const flow2 of flows) {
|
|
@@ -8472,20 +8534,21 @@ var deterministicKeys = createDiagnostic({
|
|
|
8472
8534
|
const typeScriptUtils = yield* service(TypeScriptUtils);
|
|
8473
8535
|
const options = yield* service(LanguageServicePluginOptions);
|
|
8474
8536
|
const parseExtendsCustom = cachedBy(
|
|
8475
|
-
|
|
8537
|
+
(classDeclaration) => {
|
|
8476
8538
|
if (!options.extendedKeyDetection) {
|
|
8477
|
-
return
|
|
8539
|
+
return TypeParserIssue.issue;
|
|
8478
8540
|
}
|
|
8479
8541
|
if (!classDeclaration.name) {
|
|
8480
|
-
return
|
|
8542
|
+
return TypeParserIssue.issue;
|
|
8481
8543
|
}
|
|
8482
8544
|
if (!ts.isIdentifier(classDeclaration.name)) {
|
|
8483
|
-
return
|
|
8545
|
+
return TypeParserIssue.issue;
|
|
8484
8546
|
}
|
|
8485
8547
|
const heritageClauses = classDeclaration.heritageClauses;
|
|
8486
8548
|
if (!heritageClauses) {
|
|
8487
|
-
return
|
|
8549
|
+
return TypeParserIssue.issue;
|
|
8488
8550
|
}
|
|
8551
|
+
const className = classDeclaration.name;
|
|
8489
8552
|
const nodeToVisit2 = [...classDeclaration.heritageClauses];
|
|
8490
8553
|
const appendNodeToVisit2 = (node) => {
|
|
8491
8554
|
nodeToVisit2.push(node);
|
|
@@ -8506,7 +8569,7 @@ var deterministicKeys = createDiagnostic({
|
|
|
8506
8569
|
const parameterSourceFile = typeScriptUtils.getSourceFileOfNode(declaration);
|
|
8507
8570
|
const paramText = parameterSourceFile.text.substring(declaration.pos, declaration.end);
|
|
8508
8571
|
if (paramText.toLowerCase().includes("@effect-identifier")) {
|
|
8509
|
-
return { className
|
|
8572
|
+
return succeed({ className, keyStringLiteral: arg, target: "custom" });
|
|
8510
8573
|
}
|
|
8511
8574
|
}
|
|
8512
8575
|
}
|
|
@@ -8515,12 +8578,8 @@ var deterministicKeys = createDiagnostic({
|
|
|
8515
8578
|
}
|
|
8516
8579
|
ts.forEachChild(node, appendNodeToVisit2);
|
|
8517
8580
|
}
|
|
8518
|
-
return
|
|
8519
|
-
|
|
8520
|
-
void 0,
|
|
8521
|
-
classDeclaration
|
|
8522
|
-
);
|
|
8523
|
-
}),
|
|
8581
|
+
return TypeParserIssue.issue;
|
|
8582
|
+
},
|
|
8524
8583
|
"deterministicKeys.parseExtendsCustom",
|
|
8525
8584
|
(classDeclaration) => classDeclaration
|
|
8526
8585
|
);
|
|
@@ -8799,7 +8858,7 @@ var effectFnOpportunity = createDiagnostic({
|
|
|
8799
8858
|
}
|
|
8800
8859
|
return false;
|
|
8801
8860
|
};
|
|
8802
|
-
const tryExtractWithSpanExpression = (
|
|
8861
|
+
const tryExtractWithSpanExpression = fn("effectFnOpportunity.tryExtractWithSpanExpression")(function* (expr) {
|
|
8803
8862
|
if (!ts.isCallExpression(expr)) return void 0;
|
|
8804
8863
|
const callee = expr.expression;
|
|
8805
8864
|
const isWithSpan = yield* pipe(
|
|
@@ -8811,7 +8870,9 @@ var effectFnOpportunity = createDiagnostic({
|
|
|
8811
8870
|
if (expr.arguments.length === 0) return void 0;
|
|
8812
8871
|
return expr.arguments[0];
|
|
8813
8872
|
});
|
|
8814
|
-
const tryParseGenOpportunity = (
|
|
8873
|
+
const tryParseGenOpportunity = fn(
|
|
8874
|
+
"effectFnOpportunity.tryParseGenOpportunity"
|
|
8875
|
+
)(function* (fnNode) {
|
|
8815
8876
|
const bodyExpression = getBodyExpression(fnNode);
|
|
8816
8877
|
if (!bodyExpression) return yield* TypeParserIssue.issue;
|
|
8817
8878
|
const { pipeArguments: pipeArguments2, subject } = yield* pipe(
|
|
@@ -8847,62 +8908,67 @@ var effectFnOpportunity = createDiagnostic({
|
|
|
8847
8908
|
orElse2(() => succeed(false))
|
|
8848
8909
|
);
|
|
8849
8910
|
};
|
|
8850
|
-
const
|
|
8911
|
+
const parseEffectFnOpportunityTargetGen = fn("effectFnOpportunity.parseEffectFnOpportunityTarget")(
|
|
8912
|
+
function* (node, returnType, traceName, nameIdentifier) {
|
|
8913
|
+
if (yield* isInsideEffectFn(node)) {
|
|
8914
|
+
return yield* TypeParserIssue.issue;
|
|
8915
|
+
}
|
|
8916
|
+
const unionMembers = typeCheckerUtils.unrollUnionMembers(returnType);
|
|
8917
|
+
yield* all(...unionMembers.map((member) => typeParser.strictEffectType(member, node)));
|
|
8918
|
+
const opportunity = yield* pipe(
|
|
8919
|
+
tryParseGenOpportunity(node),
|
|
8920
|
+
orElse2(() => {
|
|
8921
|
+
if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {
|
|
8922
|
+
return TypeParserIssue.issue;
|
|
8923
|
+
}
|
|
8924
|
+
const body = ts.isArrowFunction(node) ? node.body : node.body;
|
|
8925
|
+
if (!body || !ts.isBlock(body) || body.statements.length <= 5) {
|
|
8926
|
+
return TypeParserIssue.issue;
|
|
8927
|
+
}
|
|
8928
|
+
return succeed({
|
|
8929
|
+
effectModuleName: sourceEffectModuleName,
|
|
8930
|
+
pipeArguments: [],
|
|
8931
|
+
generatorFunction: void 0,
|
|
8932
|
+
explicitTraceExpression: void 0
|
|
8933
|
+
});
|
|
8934
|
+
})
|
|
8935
|
+
);
|
|
8936
|
+
return {
|
|
8937
|
+
node,
|
|
8938
|
+
nameIdentifier,
|
|
8939
|
+
effectModuleName: opportunity.effectModuleName,
|
|
8940
|
+
inferredTraceName: traceName,
|
|
8941
|
+
explicitTraceExpression: opportunity.explicitTraceExpression,
|
|
8942
|
+
pipeArguments: opportunity.pipeArguments,
|
|
8943
|
+
generatorFunction: opportunity.generatorFunction,
|
|
8944
|
+
hasParamsInPipeArgs: areParametersReferencedIn(node, opportunity.pipeArguments)
|
|
8945
|
+
};
|
|
8946
|
+
}
|
|
8947
|
+
);
|
|
8948
|
+
const parseEffectFnOpportunityTarget = (node) => {
|
|
8851
8949
|
if (!ts.isFunctionExpression(node) && !ts.isArrowFunction(node) && !ts.isFunctionDeclaration(node)) {
|
|
8852
|
-
return
|
|
8950
|
+
return TypeParserIssue.issue;
|
|
8853
8951
|
}
|
|
8854
8952
|
if ((ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) && node.asteriskToken) {
|
|
8855
|
-
return
|
|
8953
|
+
return TypeParserIssue.issue;
|
|
8856
8954
|
}
|
|
8857
8955
|
if (ts.isFunctionExpression(node) && node.name) {
|
|
8858
|
-
return
|
|
8956
|
+
return TypeParserIssue.issue;
|
|
8859
8957
|
}
|
|
8860
8958
|
if (node.type) {
|
|
8861
|
-
return
|
|
8862
|
-
}
|
|
8863
|
-
if (yield* isInsideEffectFn(node)) {
|
|
8864
|
-
return yield* TypeParserIssue.issue;
|
|
8959
|
+
return TypeParserIssue.issue;
|
|
8865
8960
|
}
|
|
8866
8961
|
const functionType = typeChecker.getTypeAtLocation(node);
|
|
8867
|
-
if (!functionType) return
|
|
8962
|
+
if (!functionType) return TypeParserIssue.issue;
|
|
8868
8963
|
const callSignatures = typeChecker.getSignaturesOfType(functionType, ts.SignatureKind.Call);
|
|
8869
|
-
if (callSignatures.length !== 1) return
|
|
8964
|
+
if (callSignatures.length !== 1) return TypeParserIssue.issue;
|
|
8870
8965
|
const signature = callSignatures[0];
|
|
8871
8966
|
const returnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
8872
|
-
const unionMembers = typeCheckerUtils.unrollUnionMembers(returnType);
|
|
8873
|
-
yield* all(...unionMembers.map((member) => typeParser.strictEffectType(member, node)));
|
|
8874
8967
|
const nameIdentifier = getNameIdentifier(node);
|
|
8875
8968
|
const traceName = nameIdentifier ? ts.isIdentifier(nameIdentifier) ? ts.idText(nameIdentifier) : nameIdentifier.text : void 0;
|
|
8876
|
-
if (!traceName) return
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
orElse2(() => {
|
|
8880
|
-
if (ts.isArrowFunction(node) && !ts.isBlock(node.body)) {
|
|
8881
|
-
return TypeParserIssue.issue;
|
|
8882
|
-
}
|
|
8883
|
-
const body = ts.isArrowFunction(node) ? node.body : node.body;
|
|
8884
|
-
if (!body || !ts.isBlock(body) || body.statements.length <= 5) {
|
|
8885
|
-
return TypeParserIssue.issue;
|
|
8886
|
-
}
|
|
8887
|
-
return succeed({
|
|
8888
|
-
effectModuleName: sourceEffectModuleName,
|
|
8889
|
-
pipeArguments: [],
|
|
8890
|
-
generatorFunction: void 0,
|
|
8891
|
-
explicitTraceExpression: void 0
|
|
8892
|
-
});
|
|
8893
|
-
})
|
|
8894
|
-
);
|
|
8895
|
-
return {
|
|
8896
|
-
node,
|
|
8897
|
-
nameIdentifier,
|
|
8898
|
-
effectModuleName: opportunity.effectModuleName,
|
|
8899
|
-
inferredTraceName: traceName,
|
|
8900
|
-
explicitTraceExpression: opportunity.explicitTraceExpression,
|
|
8901
|
-
pipeArguments: opportunity.pipeArguments,
|
|
8902
|
-
generatorFunction: opportunity.generatorFunction,
|
|
8903
|
-
hasParamsInPipeArgs: areParametersReferencedIn(node, opportunity.pipeArguments)
|
|
8904
|
-
};
|
|
8905
|
-
});
|
|
8969
|
+
if (!traceName) return TypeParserIssue.issue;
|
|
8970
|
+
return parseEffectFnOpportunityTargetGen(node, returnType, traceName, nameIdentifier);
|
|
8971
|
+
};
|
|
8906
8972
|
const getFunctionBodyBlock = (node) => {
|
|
8907
8973
|
if (ts.isArrowFunction(node)) {
|
|
8908
8974
|
if (ts.isBlock(node.body)) {
|
|
@@ -9143,7 +9209,7 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
9143
9209
|
);
|
|
9144
9210
|
return { voidedEffect };
|
|
9145
9211
|
}
|
|
9146
|
-
return yield*
|
|
9212
|
+
return yield* TypeParserIssue.issue;
|
|
9147
9213
|
});
|
|
9148
9214
|
const entries2 = typeCheckerUtils.expectedAndRealType(sourceFile);
|
|
9149
9215
|
for (const [node, expectedType, valueNode, realType] of entries2) {
|
|
@@ -11000,73 +11066,99 @@ var preferSchemaOverJson = createDiagnostic({
|
|
|
11000
11066
|
apply: fn("preferSchemaOverJson.apply")(function* (sourceFile, report) {
|
|
11001
11067
|
const ts = yield* service(TypeScriptApi);
|
|
11002
11068
|
const typeParser = yield* service(TypeParser);
|
|
11003
|
-
const
|
|
11004
|
-
|
|
11005
|
-
const
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11069
|
+
const isJsonCall = (node) => ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression) && ts.idText(node.expression.expression) === "JSON" && (ts.idText(node.expression.name) === "parse" || ts.idText(node.expression.name) === "stringify");
|
|
11070
|
+
const findEnclosingEffectTry = (jsonCall) => {
|
|
11071
|
+
const parent = jsonCall.parent;
|
|
11072
|
+
let lazy;
|
|
11073
|
+
if (ts.isArrowFunction(parent) && parent.body === jsonCall && parent.parameters.length === 0 && (!parent.typeParameters || parent.typeParameters.length === 0)) {
|
|
11074
|
+
lazy = parent;
|
|
11075
|
+
}
|
|
11076
|
+
if (!lazy && ts.isReturnStatement(parent) && parent.expression === jsonCall) {
|
|
11077
|
+
const block = parent.parent;
|
|
11078
|
+
if (ts.isBlock(block) && block.statements.length === 1) {
|
|
11079
|
+
const fn2 = block.parent;
|
|
11080
|
+
if ((ts.isArrowFunction(fn2) || ts.isFunctionExpression(fn2)) && fn2.parameters.length === 0 && (!fn2.typeParameters || fn2.typeParameters.length === 0)) {
|
|
11081
|
+
lazy = fn2;
|
|
11082
|
+
}
|
|
11083
|
+
}
|
|
11011
11084
|
}
|
|
11012
|
-
if (
|
|
11013
|
-
|
|
11085
|
+
if (!lazy) return void 0;
|
|
11086
|
+
const lazyParent = lazy.parent;
|
|
11087
|
+
if (ts.isCallExpression(lazyParent) && lazyParent.arguments.length > 0 && lazyParent.arguments[0] === lazy) {
|
|
11088
|
+
return lazyParent;
|
|
11089
|
+
}
|
|
11090
|
+
if (ts.isPropertyAssignment(lazyParent) && ts.isIdentifier(lazyParent.name) && ts.idText(lazyParent.name) === "try") {
|
|
11091
|
+
const objLiteral = lazyParent.parent;
|
|
11092
|
+
if (ts.isObjectLiteralExpression(objLiteral)) {
|
|
11093
|
+
const callExpr = objLiteral.parent;
|
|
11094
|
+
if (ts.isCallExpression(callExpr) && callExpr.arguments.length > 0 && callExpr.arguments[0] === objLiteral) {
|
|
11095
|
+
return callExpr;
|
|
11096
|
+
}
|
|
11097
|
+
}
|
|
11014
11098
|
}
|
|
11015
|
-
return
|
|
11016
|
-
}
|
|
11017
|
-
const
|
|
11018
|
-
|
|
11099
|
+
return void 0;
|
|
11100
|
+
};
|
|
11101
|
+
const jsonCalls = [];
|
|
11102
|
+
const collectJsonCalls = (node) => {
|
|
11103
|
+
if (isJsonCall(node)) {
|
|
11104
|
+
jsonCalls.push(node);
|
|
11105
|
+
}
|
|
11106
|
+
ts.forEachChild(node, collectJsonCalls);
|
|
11107
|
+
};
|
|
11108
|
+
ts.forEachChild(sourceFile, collectJsonCalls);
|
|
11109
|
+
if (jsonCalls.length === 0) return;
|
|
11110
|
+
const effectTrySimple = fn("preferSchemaOverJson.effectTrySimple")(function* (node) {
|
|
11019
11111
|
yield* typeParser.isNodeReferenceToEffectModuleApi("try")(node.expression);
|
|
11020
|
-
if (node.arguments.length === 0) return yield*
|
|
11112
|
+
if (node.arguments.length === 0) return yield* TypeParserIssue.issue;
|
|
11021
11113
|
const lazyFn = yield* typeParser.lazyExpression(node.arguments[0]);
|
|
11022
|
-
|
|
11023
|
-
return
|
|
11114
|
+
if (!isJsonCall(lazyFn.expression)) return yield* TypeParserIssue.issue;
|
|
11115
|
+
return lazyFn.expression;
|
|
11024
11116
|
});
|
|
11025
|
-
const effectTryObject = (
|
|
11026
|
-
if (!ts.isCallExpression(node)) return yield* fail3("node is not a call expression");
|
|
11117
|
+
const effectTryObject = fn("preferSchemaOverJson.effectTryObject")(function* (node) {
|
|
11027
11118
|
yield* typeParser.isNodeReferenceToEffectModuleApi("try")(node.expression);
|
|
11028
|
-
if (node.arguments.length === 0) return yield*
|
|
11119
|
+
if (node.arguments.length === 0) return yield* TypeParserIssue.issue;
|
|
11029
11120
|
const arg = node.arguments[0];
|
|
11030
|
-
if (!ts.isObjectLiteralExpression(arg)) return yield*
|
|
11121
|
+
if (!ts.isObjectLiteralExpression(arg)) return yield* TypeParserIssue.issue;
|
|
11031
11122
|
const tryProp = arg.properties.find(
|
|
11032
11123
|
(p) => ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && ts.idText(p.name) === "try"
|
|
11033
11124
|
);
|
|
11034
|
-
if (!tryProp) return yield*
|
|
11125
|
+
if (!tryProp) return yield* TypeParserIssue.issue;
|
|
11035
11126
|
const lazyFn = yield* typeParser.lazyExpression(tryProp.initializer);
|
|
11036
|
-
|
|
11037
|
-
return
|
|
11127
|
+
if (!isJsonCall(lazyFn.expression)) return yield* TypeParserIssue.issue;
|
|
11128
|
+
return lazyFn.expression;
|
|
11038
11129
|
});
|
|
11039
|
-
const jsonMethodInEffectGen = (
|
|
11040
|
-
|
|
11041
|
-
|
|
11042
|
-
|
|
11043
|
-
|
|
11130
|
+
const jsonMethodInEffectGen = fn("preferSchemaOverJson.jsonMethodInEffectGen")(
|
|
11131
|
+
function* (jsonCall) {
|
|
11132
|
+
const { effectGen, scopeNode } = yield* typeParser.findEnclosingScopes(jsonCall);
|
|
11133
|
+
if (!effectGen || effectGen.body.statements.length === 0) {
|
|
11134
|
+
return yield* TypeParserIssue.issue;
|
|
11135
|
+
}
|
|
11136
|
+
if (scopeNode && scopeNode !== effectGen.generatorFunction) {
|
|
11137
|
+
return yield* TypeParserIssue.issue;
|
|
11138
|
+
}
|
|
11139
|
+
return jsonCall;
|
|
11044
11140
|
}
|
|
11045
|
-
|
|
11046
|
-
|
|
11141
|
+
);
|
|
11142
|
+
for (const jsonCall of jsonCalls) {
|
|
11143
|
+
const effectTryCall = findEnclosingEffectTry(jsonCall);
|
|
11144
|
+
let match3;
|
|
11145
|
+
if (effectTryCall) {
|
|
11146
|
+
match3 = yield* pipe(
|
|
11147
|
+
firstSuccessOf([
|
|
11148
|
+
effectTrySimple(effectTryCall),
|
|
11149
|
+
effectTryObject(effectTryCall)
|
|
11150
|
+
]),
|
|
11151
|
+
option
|
|
11152
|
+
);
|
|
11153
|
+
} else {
|
|
11154
|
+
match3 = yield* pipe(
|
|
11155
|
+
jsonMethodInEffectGen(jsonCall),
|
|
11156
|
+
option
|
|
11157
|
+
);
|
|
11047
11158
|
}
|
|
11048
|
-
return { node: jsonMethod.node, methodName: jsonMethod.methodName };
|
|
11049
|
-
});
|
|
11050
|
-
const nodeToVisit = [];
|
|
11051
|
-
const appendNodeToVisit = (node) => {
|
|
11052
|
-
nodeToVisit.push(node);
|
|
11053
|
-
return void 0;
|
|
11054
|
-
};
|
|
11055
|
-
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
11056
|
-
while (nodeToVisit.length > 0) {
|
|
11057
|
-
const node = nodeToVisit.shift();
|
|
11058
|
-
ts.forEachChild(node, appendNodeToVisit);
|
|
11059
|
-
const match3 = yield* pipe(
|
|
11060
|
-
firstSuccessOf([
|
|
11061
|
-
effectTrySimple(node),
|
|
11062
|
-
effectTryObject(node),
|
|
11063
|
-
jsonMethodInEffectGen(node)
|
|
11064
|
-
]),
|
|
11065
|
-
option
|
|
11066
|
-
);
|
|
11067
11159
|
if (isSome2(match3)) {
|
|
11068
11160
|
report({
|
|
11069
|
-
location: match3.value
|
|
11161
|
+
location: match3.value,
|
|
11070
11162
|
messageText: "Consider using Effect Schema for JSON operations instead of JSON.parse/JSON.stringify",
|
|
11071
11163
|
fixes: []
|
|
11072
11164
|
});
|
|
@@ -11710,19 +11802,24 @@ var strictEffectProvide = createDiagnostic({
|
|
|
11710
11802
|
const ts = yield* service(TypeScriptApi);
|
|
11711
11803
|
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
11712
11804
|
const typeParser = yield* service(TypeParser);
|
|
11713
|
-
const
|
|
11805
|
+
const parseEffectProvideWithLayerGen = fn("strictEffectProvide.parseEffectProvideWithLayer")(
|
|
11806
|
+
function* (node) {
|
|
11807
|
+
yield* typeParser.isNodeReferenceToEffectModuleApi("provide")(node.expression);
|
|
11808
|
+
return yield* firstSuccessOf(
|
|
11809
|
+
node.arguments.map((arg) => {
|
|
11810
|
+
const argType = typeCheckerUtils.getTypeAtLocation(arg);
|
|
11811
|
+
if (!argType) return typeParserIssue("Could not get argument type");
|
|
11812
|
+
return typeParser.layerType(argType, arg);
|
|
11813
|
+
})
|
|
11814
|
+
);
|
|
11815
|
+
}
|
|
11816
|
+
);
|
|
11817
|
+
const parseEffectProvideWithLayer = (node) => {
|
|
11714
11818
|
if (!ts.isCallExpression(node) || node.arguments.length === 0) {
|
|
11715
|
-
return
|
|
11716
|
-
}
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
node.arguments.map((arg) => {
|
|
11720
|
-
const argType = typeCheckerUtils.getTypeAtLocation(arg);
|
|
11721
|
-
if (!argType) return typeParserIssue("Could not get argument type");
|
|
11722
|
-
return typeParser.layerType(argType, arg);
|
|
11723
|
-
})
|
|
11724
|
-
);
|
|
11725
|
-
});
|
|
11819
|
+
return TypeParserIssue.issue;
|
|
11820
|
+
}
|
|
11821
|
+
return parseEffectProvideWithLayerGen(node);
|
|
11822
|
+
};
|
|
11726
11823
|
const nodeToVisit = [];
|
|
11727
11824
|
const appendNodeToVisit = (node) => {
|
|
11728
11825
|
nodeToVisit.push(node);
|
|
@@ -13237,36 +13334,38 @@ var middlewareAutoImportQuickfixes = fn("middlewareAutoImportQuickfixes")(functi
|
|
|
13237
13334
|
const program = yield* service(TypeScriptProgram);
|
|
13238
13335
|
const autoImportProvider = yield* getOrMakeAutoImportProvider(sourceFile);
|
|
13239
13336
|
const changedCodeFixes = [];
|
|
13240
|
-
const createImportAllChanges = (
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13337
|
+
const createImportAllChanges = fn("middlewareAutoImportQuickfixes.createImportAllChanges")(
|
|
13338
|
+
function* (imports) {
|
|
13339
|
+
const newImports = [];
|
|
13340
|
+
for (const importToAdd of imports) {
|
|
13341
|
+
if (!importToAdd.exportName) return;
|
|
13342
|
+
const fileName = ts.resolveModuleName(
|
|
13343
|
+
importToAdd.moduleName,
|
|
13344
|
+
sourceFile.fileName,
|
|
13345
|
+
program.getCompilerOptions(),
|
|
13346
|
+
program
|
|
13347
|
+
);
|
|
13348
|
+
if (!fileName.resolvedModule) return;
|
|
13349
|
+
const importKind = autoImportProvider.resolve(fileName.resolvedModule.resolvedFileName, importToAdd.exportName);
|
|
13350
|
+
if (!importKind) return;
|
|
13351
|
+
if (importKind.introducedPrefix) return;
|
|
13352
|
+
newImports.push(importKind);
|
|
13353
|
+
}
|
|
13354
|
+
const formatContext = ts.formatting.getFormatContext(
|
|
13355
|
+
formatOptions,
|
|
13356
|
+
languageServiceHost
|
|
13249
13357
|
);
|
|
13250
|
-
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
|
|
13254
|
-
|
|
13358
|
+
const edits = ts.textChanges.ChangeTracker.with(
|
|
13359
|
+
{
|
|
13360
|
+
formatContext,
|
|
13361
|
+
host: languageServiceHost,
|
|
13362
|
+
preferences: preferences || {}
|
|
13363
|
+
},
|
|
13364
|
+
(changeTracker) => newImports.forEach((_) => addImport(ts, sourceFile, changeTracker, preferences, _))
|
|
13365
|
+
);
|
|
13366
|
+
return edits;
|
|
13255
13367
|
}
|
|
13256
|
-
|
|
13257
|
-
formatOptions,
|
|
13258
|
-
languageServiceHost
|
|
13259
|
-
);
|
|
13260
|
-
const edits = ts.textChanges.ChangeTracker.with(
|
|
13261
|
-
{
|
|
13262
|
-
formatContext,
|
|
13263
|
-
host: languageServiceHost,
|
|
13264
|
-
preferences: preferences || {}
|
|
13265
|
-
},
|
|
13266
|
-
(changeTracker) => newImports.forEach((_) => addImport(ts, sourceFile, changeTracker, preferences, _))
|
|
13267
|
-
);
|
|
13268
|
-
return edits;
|
|
13269
|
-
});
|
|
13368
|
+
);
|
|
13270
13369
|
for (const codeFix of codeFixes) {
|
|
13271
13370
|
const textFileChanges = codeFix.changes;
|
|
13272
13371
|
if (textFileChanges.length !== 1) {
|
|
@@ -18893,6 +18992,30 @@ var asyncAwaitToGenTryPromise = createRefactor({
|
|
|
18893
18992
|
})
|
|
18894
18993
|
});
|
|
18895
18994
|
|
|
18995
|
+
// src/refactors/debugPerformance.ts
|
|
18996
|
+
var debugPerformance2 = createRefactor({
|
|
18997
|
+
name: "debugPerformance",
|
|
18998
|
+
description: "Debug: LSP Performance",
|
|
18999
|
+
apply: fn("debugPerformance.apply")(function* (sourceFile) {
|
|
19000
|
+
const ts = yield* service(TypeScriptApi);
|
|
19001
|
+
return {
|
|
19002
|
+
kind: "refactor.rewrite.effect.debugPerformance",
|
|
19003
|
+
description: "Debug: LSP Performance",
|
|
19004
|
+
apply: pipe(
|
|
19005
|
+
gen(function* () {
|
|
19006
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
19007
|
+
changeTracker.insertText(
|
|
19008
|
+
sourceFile,
|
|
19009
|
+
0,
|
|
19010
|
+
"/** \n" + getTimings().join("\n") + "\n */"
|
|
19011
|
+
);
|
|
19012
|
+
}),
|
|
19013
|
+
provideService(TypeScriptApi, ts)
|
|
19014
|
+
)
|
|
19015
|
+
};
|
|
19016
|
+
})
|
|
19017
|
+
});
|
|
19018
|
+
|
|
18896
19019
|
// src/refactors/effectGenToFn.ts
|
|
18897
19020
|
var effectGenToFn = createRefactor({
|
|
18898
19021
|
name: "effectGenToFn",
|
|
@@ -19765,7 +19888,7 @@ var togglePipeStyle = createRefactor({
|
|
|
19765
19888
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
19766
19889
|
const typeParser = yield* service(TypeParser);
|
|
19767
19890
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
19768
|
-
const
|
|
19891
|
+
const togglePipeStyleForNode = fn("togglePipeStyle.togglePipeStyleForNode")(function* (node) {
|
|
19769
19892
|
const pipeCall = yield* typeParser.pipeCall(node);
|
|
19770
19893
|
switch (pipeCall.kind) {
|
|
19771
19894
|
case "pipe": {
|
|
@@ -19811,7 +19934,7 @@ var togglePipeStyle = createRefactor({
|
|
|
19811
19934
|
});
|
|
19812
19935
|
const ancestorNodes = tsUtils.getAncestorNodesInRange(sourceFile, textRange);
|
|
19813
19936
|
return yield* pipe(
|
|
19814
|
-
firstSuccessOf(ancestorNodes.map(
|
|
19937
|
+
firstSuccessOf(ancestorNodes.map(togglePipeStyleForNode)),
|
|
19815
19938
|
orElse2(() => fail3(new RefactorNotApplicableError()))
|
|
19816
19939
|
);
|
|
19817
19940
|
})
|
|
@@ -20083,7 +20206,7 @@ var createUnsupportedNodeComment = (ts, sourceFile, node) => ts.addSyntheticTrai
|
|
|
20083
20206
|
ts.SyntaxKind.MultiLineCommentTrivia,
|
|
20084
20207
|
" Not supported conversion: " + node.getText(sourceFile) + " "
|
|
20085
20208
|
);
|
|
20086
|
-
var processNode = (
|
|
20209
|
+
var processNode = fn("SchemaGen.processNode")(function* (node, isVirtualTypeNode) {
|
|
20087
20210
|
const { createApiCall, createApiPropertyAccess, entityNameToDataTypeName, sourceFile, supportedEffect, ts } = yield* service(
|
|
20088
20211
|
SchemaGenContext
|
|
20089
20212
|
);
|
|
@@ -20576,10 +20699,10 @@ var refactors = [
|
|
|
20576
20699
|
effectGenToFn,
|
|
20577
20700
|
togglePipeStyle,
|
|
20578
20701
|
writeTagClassAccessors
|
|
20579
|
-
];
|
|
20702
|
+
].concat(debugPerformance ? [debugPerformance2] : []);
|
|
20580
20703
|
|
|
20581
20704
|
// src/renames/keyStrings.ts
|
|
20582
|
-
var renameKeyStrings = (sourceFile, position, _findInStrings, _findInComments, _preferences, renameLocations)
|
|
20705
|
+
var renameKeyStrings = fn("renameKeyStrings")(function* (sourceFile, position, _findInStrings, _findInComments, _preferences, renameLocations) {
|
|
20583
20706
|
const ts = yield* service(TypeScriptApi);
|
|
20584
20707
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
20585
20708
|
const typeParser = yield* service(TypeParser);
|
|
@@ -20777,10 +20900,23 @@ var init = (modules) => {
|
|
|
20777
20900
|
if (program) {
|
|
20778
20901
|
const sourceFile = program.getSourceFile(fileName);
|
|
20779
20902
|
if (sourceFile) {
|
|
20903
|
+
if (!effectCodeFixesForFile.has(fileName)) {
|
|
20904
|
+
runDiagnosticsAndCacheCodeFixes(fileName);
|
|
20905
|
+
}
|
|
20780
20906
|
return pipe(
|
|
20781
20907
|
getApplicableRefactors(refactors, sourceFile, positionOrRange),
|
|
20908
|
+
flatMap4(
|
|
20909
|
+
(effectRefactors) => map8(
|
|
20910
|
+
codeFixesToApplicableRefactor(
|
|
20911
|
+
effectCodeFixesForFile.get(fileName) || [],
|
|
20912
|
+
sourceFile,
|
|
20913
|
+
positionOrRange
|
|
20914
|
+
),
|
|
20915
|
+
(effectCodefixes) => effectCodefixes.concat(effectRefactors)
|
|
20916
|
+
)
|
|
20917
|
+
),
|
|
20782
20918
|
runNano(program),
|
|
20783
|
-
map((
|
|
20919
|
+
map((effectCodeActions) => applicableRefactors.concat(effectCodeActions)),
|
|
20784
20920
|
getOrElse(() => applicableRefactors)
|
|
20785
20921
|
);
|
|
20786
20922
|
}
|
|
@@ -20794,11 +20930,16 @@ var init = (modules) => {
|
|
|
20794
20930
|
if (sourceFile) {
|
|
20795
20931
|
const result = pipe(
|
|
20796
20932
|
gen(function* () {
|
|
20797
|
-
const applicableRefactor = yield*
|
|
20798
|
-
|
|
20799
|
-
|
|
20800
|
-
|
|
20801
|
-
|
|
20933
|
+
const applicableRefactor = yield* pipe(
|
|
20934
|
+
getEditsForRefactor(
|
|
20935
|
+
refactors,
|
|
20936
|
+
sourceFile,
|
|
20937
|
+
positionOrRange,
|
|
20938
|
+
refactorName
|
|
20939
|
+
),
|
|
20940
|
+
orElse2(
|
|
20941
|
+
() => getEditsForCodeFixes(effectCodeFixesForFile.get(fileName) || [], positionOrRange, refactorName)
|
|
20942
|
+
)
|
|
20802
20943
|
);
|
|
20803
20944
|
const formatContext = modules.typescript.formatting.getFormatContext(
|
|
20804
20945
|
formatOptions,
|