@effect/language-service 0.32.0 → 0.33.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 +4 -1
- package/cli.js +26 -9
- package/cli.js.map +1 -1
- package/index.js +104 -10
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +26 -9
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1519,17 +1519,34 @@ function parseDiagnosticSeverity(config) {
|
|
|
1519
1519
|
)
|
|
1520
1520
|
);
|
|
1521
1521
|
}
|
|
1522
|
+
var defaults = {
|
|
1523
|
+
refactors: true,
|
|
1524
|
+
diagnostics: true,
|
|
1525
|
+
diagnosticSeverity: {},
|
|
1526
|
+
quickinfo: true,
|
|
1527
|
+
quickinfoEffectParameters: "whentruncated",
|
|
1528
|
+
completions: true,
|
|
1529
|
+
goto: true,
|
|
1530
|
+
inlays: true,
|
|
1531
|
+
allowedDuplicatedPackages: [],
|
|
1532
|
+
namespaceImportPackages: [],
|
|
1533
|
+
barrelImportPackages: [],
|
|
1534
|
+
topLevelNamedReexports: "ignore"
|
|
1535
|
+
};
|
|
1522
1536
|
function parse(config) {
|
|
1523
1537
|
return {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1538
|
+
refactors: isObject(config) && hasProperty(config, "refactors") && isBoolean(config.refactors) ? config.refactors : defaults.refactors,
|
|
1539
|
+
diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : defaults.diagnostics,
|
|
1540
|
+
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : defaults.diagnosticSeverity,
|
|
1541
|
+
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : defaults.quickinfo,
|
|
1542
|
+
quickinfoEffectParameters: isObject(config) && hasProperty(config, "quickinfoEffectParameters") && isString(config.quickinfoEffectParameters) && ["always", "never", "whentruncated"].includes(config.quickinfoEffectParameters.toLowerCase()) ? config.quickinfoEffectParameters.toLowerCase() : defaults.quickinfoEffectParameters,
|
|
1543
|
+
completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : defaults.completions,
|
|
1544
|
+
goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : defaults.goto,
|
|
1545
|
+
inlays: isObject(config) && hasProperty(config, "inlays") && isBoolean(config.inlays) ? config.inlays : defaults.inlays,
|
|
1546
|
+
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
|
|
1547
|
+
namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
|
|
1548
|
+
barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : defaults.barrelImportPackages,
|
|
1549
|
+
topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports
|
|
1533
1550
|
};
|
|
1534
1551
|
}
|
|
1535
1552
|
|
|
@@ -5929,6 +5946,64 @@ function goto(applicableGotoDefinition, sourceFile, position) {
|
|
|
5929
5946
|
return effectRpcDefinition(applicableGotoDefinition, sourceFile, position);
|
|
5930
5947
|
}
|
|
5931
5948
|
|
|
5949
|
+
// src/inlays/middlewareGenLike.ts
|
|
5950
|
+
var middlewareGenLike = fn("middlewareGenLike")(function* (sourceFile, _span, preferences, inlayHints) {
|
|
5951
|
+
if (!preferences) return inlayHints;
|
|
5952
|
+
if (preferences.includeInlayFunctionLikeReturnTypeHints !== true) return inlayHints;
|
|
5953
|
+
if (!inlayHints) return inlayHints;
|
|
5954
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
5955
|
+
const ts = yield* service(TypeScriptApi);
|
|
5956
|
+
const typeParser = yield* service(TypeParser);
|
|
5957
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
5958
|
+
const result = [];
|
|
5959
|
+
const parseType = (node) => {
|
|
5960
|
+
return pipe(
|
|
5961
|
+
map3(typeParser.effectGen(node), (_) => {
|
|
5962
|
+
const type = typeChecker.getTypeAtLocation(_.node);
|
|
5963
|
+
const typeString = typeChecker.typeToString(type, _.generatorFunction, ts.TypeFormatFlags.NoTruncation);
|
|
5964
|
+
return { ..._, typeString };
|
|
5965
|
+
}),
|
|
5966
|
+
orElse2(
|
|
5967
|
+
() => map3(pipe(typeParser.effectFnGen(node), orElse2(() => typeParser.effectFnUntracedGen(node))), (_) => {
|
|
5968
|
+
const fnType = typeChecker.getTypeAtLocation(_.node);
|
|
5969
|
+
const types = [];
|
|
5970
|
+
for (const callSig of fnType.getCallSignatures()) {
|
|
5971
|
+
types.push(
|
|
5972
|
+
typeChecker.typeToString(callSig.getReturnType(), _.generatorFunction, ts.TypeFormatFlags.NoTruncation)
|
|
5973
|
+
);
|
|
5974
|
+
}
|
|
5975
|
+
return { ..._, typeString: types.join(" | ") };
|
|
5976
|
+
})
|
|
5977
|
+
)
|
|
5978
|
+
);
|
|
5979
|
+
};
|
|
5980
|
+
for (const inlayHint of inlayHints) {
|
|
5981
|
+
let modifiedInlayHint = inlayHint;
|
|
5982
|
+
if (inlayHint.kind === ts.InlayHintKind.Type) {
|
|
5983
|
+
const node = tsUtils.findNodeAtPositionIncludingTrivia(sourceFile, inlayHint.position - 1);
|
|
5984
|
+
if (node && node.parent) {
|
|
5985
|
+
const possiblyGen = node.parent;
|
|
5986
|
+
yield* pipe(
|
|
5987
|
+
parseType(possiblyGen),
|
|
5988
|
+
map3((_) => {
|
|
5989
|
+
const argsCloseParen = ts.findChildOfKind(_.generatorFunction, ts.SyntaxKind.CloseParenToken, sourceFile);
|
|
5990
|
+
if (argsCloseParen && _.body && inlayHint.position >= argsCloseParen.getEnd() && inlayHint.position <= _.body.getStart(sourceFile)) {
|
|
5991
|
+
const { displayParts: _displayParts, text: _text, ...toKeep } = inlayHint;
|
|
5992
|
+
modifiedInlayHint = {
|
|
5993
|
+
...toKeep,
|
|
5994
|
+
text: ": " + _.typeString
|
|
5995
|
+
};
|
|
5996
|
+
}
|
|
5997
|
+
}),
|
|
5998
|
+
ignore
|
|
5999
|
+
);
|
|
6000
|
+
}
|
|
6001
|
+
}
|
|
6002
|
+
result.push(modifiedInlayHint);
|
|
6003
|
+
}
|
|
6004
|
+
return result;
|
|
6005
|
+
});
|
|
6006
|
+
|
|
5932
6007
|
// src/quickinfo/dedupeJsDocs.ts
|
|
5933
6008
|
var SymbolDisplayPartEq = make((fa, fb) => fa.kind === fb.kind && fa.text === fb.text);
|
|
5934
6009
|
var JSDocTagInfoEq = make(
|
|
@@ -5952,6 +6027,8 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
5952
6027
|
const ts = yield* service(TypeScriptApi);
|
|
5953
6028
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
5954
6029
|
const typeParser = yield* service(TypeParser);
|
|
6030
|
+
const options = yield* service(LanguageServicePluginOptions);
|
|
6031
|
+
if (options.quickinfoEffectParameters === "never") return quickInfo2;
|
|
5955
6032
|
function formatTypeForQuickInfo(channelType, channelName) {
|
|
5956
6033
|
const stringRepresentation = typeChecker.typeToString(
|
|
5957
6034
|
channelType,
|
|
@@ -5997,7 +6074,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
5997
6074
|
type: typeChecker.getTypeAtLocation(adjustedNode),
|
|
5998
6075
|
atLocation: adjustedNode,
|
|
5999
6076
|
node: adjustedNode,
|
|
6000
|
-
shouldTry: quickInfo2 && ts.displayPartsToString(quickInfo2.displayParts).indexOf("...") > -1
|
|
6077
|
+
shouldTry: options.quickinfoEffectParameters === "always" && quickInfo2 ? true : quickInfo2 && ts.displayPartsToString(quickInfo2.displayParts).indexOf("...") > -1
|
|
6001
6078
|
};
|
|
6002
6079
|
}
|
|
6003
6080
|
const data = getDataForQuickInfo();
|
|
@@ -12435,6 +12512,23 @@ var init = (modules) => {
|
|
|
12435
12512
|
}
|
|
12436
12513
|
return applicableDefinition;
|
|
12437
12514
|
};
|
|
12515
|
+
proxy.provideInlayHints = (fileName, span, preferences, ...args2) => {
|
|
12516
|
+
const applicableInlayHints = languageService.provideInlayHints(fileName, span, preferences, ...args2);
|
|
12517
|
+
if (languageServicePluginOptions.inlays) {
|
|
12518
|
+
const program = languageService.getProgram();
|
|
12519
|
+
if (program) {
|
|
12520
|
+
const sourceFile = program.getSourceFile(fileName);
|
|
12521
|
+
if (sourceFile) {
|
|
12522
|
+
return pipe(
|
|
12523
|
+
middlewareGenLike(sourceFile, span, preferences, applicableInlayHints),
|
|
12524
|
+
runNano(program),
|
|
12525
|
+
getOrElse(() => applicableInlayHints)
|
|
12526
|
+
);
|
|
12527
|
+
}
|
|
12528
|
+
}
|
|
12529
|
+
}
|
|
12530
|
+
return applicableInlayHints;
|
|
12531
|
+
};
|
|
12438
12532
|
return proxy;
|
|
12439
12533
|
}
|
|
12440
12534
|
return { create, onConfigurationChanged };
|