@effect/language-service 0.21.0 → 0.21.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/README.md +4 -1
- package/index.js +194 -113
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +172 -96
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -41,9 +41,9 @@ And you're done! You'll now be able to use a set of refactor and diagnostics tha
|
|
|
41
41
|
- Better error readability when you're missing errors or service types in your Effect definitions
|
|
42
42
|
- Floating Effects that are not yielded or run
|
|
43
43
|
- Wrong usage of yield inside Effect.gen
|
|
44
|
-
- Unnecessary usages of Effect.gen
|
|
45
44
|
- Multiple versions of Effect in your project
|
|
46
45
|
- Warn on leaking requirements in Effect services
|
|
46
|
+
- Unnecessary usages of Effect.gen or pipe()
|
|
47
47
|
|
|
48
48
|
### Completions
|
|
49
49
|
|
|
@@ -75,6 +75,9 @@ Few options can be provided alongside the initialization of the Language Service
|
|
|
75
75
|
{
|
|
76
76
|
"name": "@effect/language-service",
|
|
77
77
|
"diagnostics": true, // controls Effect diagnostics (default: true)
|
|
78
|
+
"diagnosticSeverity": { // allows to change per-rule default severity of the diagnostic in the whole project
|
|
79
|
+
"floatingEffect": "warning" // example for a rule, allowed values are off,error,warning,message,suggestion
|
|
80
|
+
},
|
|
78
81
|
"quickinfo": true, // controls quickinfo over Effect (default: true)
|
|
79
82
|
"completions": true, // controls Effect completions (default: true)
|
|
80
83
|
"allowedDuplicatedPackages": [] // list of package names that has effect in peer dependencies and are allowed to be duplicated (default: [])
|
package/index.js
CHANGED
|
@@ -198,6 +198,7 @@ var isFunction2 = isFunction;
|
|
|
198
198
|
var isRecordOrArray = (input) => typeof input === "object" && input !== null;
|
|
199
199
|
var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
|
|
200
200
|
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
|
|
201
|
+
var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
|
|
201
202
|
|
|
202
203
|
// node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/errors.js
|
|
203
204
|
var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
|
|
@@ -1549,19 +1550,32 @@ var createReturnYieldStarStatement = fn("AST.createReturnYieldStarStatement")(
|
|
|
1549
1550
|
);
|
|
1550
1551
|
}
|
|
1551
1552
|
);
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
)
|
|
1553
|
+
|
|
1554
|
+
// src/core/LanguageServicePluginOptions.ts
|
|
1555
|
+
var LanguageServicePluginOptions = Tag("PluginOptions");
|
|
1556
|
+
function parseDiagnosticSeverity(config) {
|
|
1557
|
+
if (!isRecord(config)) return {};
|
|
1558
|
+
return Object.fromEntries(
|
|
1559
|
+
pipe(
|
|
1560
|
+
Object.entries(config),
|
|
1561
|
+
filter(([key, value]) => isString(key) && isString(value)),
|
|
1562
|
+
map3(([key, value]) => [String(key).toLowerCase(), String(value).toLowerCase()]),
|
|
1563
|
+
filter(
|
|
1564
|
+
([_, value]) => value === "off" || value === "error" || value === "warning" || value === "message" || value === "suggestion"
|
|
1565
|
+
)
|
|
1566
|
+
)
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1569
|
+
function parse(config) {
|
|
1570
|
+
return {
|
|
1571
|
+
diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : true,
|
|
1572
|
+
diagnosticSeverity: isObject(config) && hasProperty(config, "diagnosticSeverity") && isRecord(config.diagnosticSeverity) ? parseDiagnosticSeverity(config.diagnosticSeverity) : {},
|
|
1573
|
+
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : true,
|
|
1574
|
+
completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : true,
|
|
1575
|
+
goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : true,
|
|
1576
|
+
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : []
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1565
1579
|
|
|
1566
1580
|
// src/core/LSP.ts
|
|
1567
1581
|
var RefactorNotApplicableError = class {
|
|
@@ -1666,6 +1680,7 @@ var getCompletionsAtPosition = fn("LSP.getCompletionsAtPosition")(function* (com
|
|
|
1666
1680
|
var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
1667
1681
|
function* (sourceFile) {
|
|
1668
1682
|
const ts = yield* service(TypeScriptApi);
|
|
1683
|
+
const pluginOptions = yield* service(LanguageServicePluginOptions);
|
|
1669
1684
|
function findNodeWithLeadingCommentAtPosition(position) {
|
|
1670
1685
|
const sourceText = sourceFile.text;
|
|
1671
1686
|
let result;
|
|
@@ -1749,24 +1764,30 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1749
1764
|
const ruleNameLowered = rule.name.toLowerCase();
|
|
1750
1765
|
if (skippedRules.indexOf(ruleNameLowered) > -1) return [];
|
|
1751
1766
|
let modifiedDiagnostics = yield* rule.apply(sourceFile);
|
|
1767
|
+
const newLevel = pluginOptions.diagnosticSeverity[ruleNameLowered];
|
|
1768
|
+
if (newLevel) {
|
|
1769
|
+
for (const emitted of modifiedDiagnostics) {
|
|
1770
|
+
emitted.category = newLevel && newLevel in levelToDiagnosticCategory ? levelToDiagnosticCategory[newLevel] : emitted.category;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1752
1773
|
for (const emitted of modifiedDiagnostics.slice(0)) {
|
|
1753
|
-
let
|
|
1774
|
+
let newLevel2 = void 0;
|
|
1754
1775
|
if (!(ruleNameLowered in sectionOverrides || ruleNameLowered in lineOverrides)) continue;
|
|
1755
1776
|
const lineOverride = (lineOverrides[ruleNameLowered] || []).find(
|
|
1756
1777
|
(_) => _.pos < emitted.node.getStart(sourceFile) && _.end >= emitted.node.getEnd()
|
|
1757
1778
|
);
|
|
1758
1779
|
if (lineOverride) {
|
|
1759
|
-
|
|
1780
|
+
newLevel2 = lineOverride.level;
|
|
1760
1781
|
} else {
|
|
1761
1782
|
const sectionOverride = (sectionOverrides[ruleNameLowered] || []).find(
|
|
1762
1783
|
(_) => _.pos < emitted.node.getStart(sourceFile)
|
|
1763
1784
|
);
|
|
1764
|
-
if (sectionOverride)
|
|
1785
|
+
if (sectionOverride) newLevel2 = sectionOverride.level;
|
|
1765
1786
|
}
|
|
1766
|
-
if (
|
|
1787
|
+
if (newLevel2 === "off") {
|
|
1767
1788
|
modifiedDiagnostics = modifiedDiagnostics.filter((_) => _ !== emitted);
|
|
1768
1789
|
} else {
|
|
1769
|
-
emitted.category =
|
|
1790
|
+
emitted.category = newLevel2 && newLevel2 in levelToDiagnosticCategory ? levelToDiagnosticCategory[newLevel2] : emitted.category;
|
|
1770
1791
|
}
|
|
1771
1792
|
}
|
|
1772
1793
|
const fixByDisableNextLine = (_) => ({
|
|
@@ -1999,18 +2020,18 @@ function make4(ts, typeChecker) {
|
|
|
1999
2020
|
return succeed(signatures[0].getReturnType());
|
|
2000
2021
|
}
|
|
2001
2022
|
const pipeableType = cachedBy(
|
|
2002
|
-
|
|
2023
|
+
function(type, atLocation) {
|
|
2003
2024
|
const pipeSymbol = typeChecker.getPropertyOfType(type, "pipe");
|
|
2004
2025
|
if (!pipeSymbol) {
|
|
2005
|
-
return
|
|
2026
|
+
return typeParserIssue("Type has no 'pipe' property", type, atLocation);
|
|
2006
2027
|
}
|
|
2007
2028
|
const pipeType = typeChecker.getTypeOfSymbolAtLocation(pipeSymbol, atLocation);
|
|
2008
2029
|
const signatures = pipeType.getCallSignatures();
|
|
2009
2030
|
if (signatures.length === 0) {
|
|
2010
|
-
return
|
|
2031
|
+
return typeParserIssue("'pipe' property is not callable", type, atLocation);
|
|
2011
2032
|
}
|
|
2012
|
-
return type;
|
|
2013
|
-
}
|
|
2033
|
+
return succeed(type);
|
|
2034
|
+
},
|
|
2014
2035
|
"TypeParser.pipeableType",
|
|
2015
2036
|
(type) => type
|
|
2016
2037
|
);
|
|
@@ -2148,105 +2169,107 @@ function make4(ts, typeChecker) {
|
|
|
2148
2169
|
(node) => node
|
|
2149
2170
|
);
|
|
2150
2171
|
const effectGen = cachedBy(
|
|
2151
|
-
|
|
2172
|
+
function(node) {
|
|
2152
2173
|
if (!ts.isCallExpression(node)) {
|
|
2153
|
-
return
|
|
2174
|
+
return typeParserIssue("Node is not a call expression", void 0, node);
|
|
2154
2175
|
}
|
|
2155
2176
|
if (node.arguments.length === 0) {
|
|
2156
|
-
return
|
|
2177
|
+
return typeParserIssue("Node has no arguments", void 0, node);
|
|
2157
2178
|
}
|
|
2158
2179
|
const generatorFunction = node.arguments[0];
|
|
2159
2180
|
if (!ts.isFunctionExpression(generatorFunction)) {
|
|
2160
|
-
return
|
|
2181
|
+
return typeParserIssue("Node is not a function expression", void 0, node);
|
|
2161
2182
|
}
|
|
2162
2183
|
if (generatorFunction.asteriskToken === void 0) {
|
|
2163
|
-
return
|
|
2184
|
+
return typeParserIssue("Node is not a generator function", void 0, node);
|
|
2164
2185
|
}
|
|
2165
2186
|
if (!ts.isPropertyAccessExpression(node.expression)) {
|
|
2166
|
-
return
|
|
2187
|
+
return typeParserIssue("Node is not a property access expression", void 0, node);
|
|
2167
2188
|
}
|
|
2168
2189
|
const propertyAccess = node.expression;
|
|
2169
2190
|
if (propertyAccess.name.text !== "gen") {
|
|
2170
|
-
return
|
|
2191
|
+
return typeParserIssue("Call expression name is not 'gen'", void 0, node);
|
|
2171
2192
|
}
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2193
|
+
return pipe(
|
|
2194
|
+
importedEffectModule(propertyAccess.expression),
|
|
2195
|
+
map4((effectModule) => ({
|
|
2196
|
+
node,
|
|
2197
|
+
effectModule,
|
|
2198
|
+
generatorFunction,
|
|
2199
|
+
body: generatorFunction.body,
|
|
2200
|
+
functionStar: generatorFunction.getFirstToken()
|
|
2201
|
+
}))
|
|
2202
|
+
);
|
|
2203
|
+
},
|
|
2181
2204
|
"TypeParser.effectGen",
|
|
2182
2205
|
(node) => node
|
|
2183
2206
|
);
|
|
2184
2207
|
const effectFnUntracedGen = cachedBy(
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2208
|
+
function(node) {
|
|
2209
|
+
if (!ts.isCallExpression(node)) {
|
|
2210
|
+
return typeParserIssue("Node is not a call expression", void 0, node);
|
|
2211
|
+
}
|
|
2212
|
+
if (node.arguments.length === 0) {
|
|
2213
|
+
return typeParserIssue("Node has no arguments", void 0, node);
|
|
2214
|
+
}
|
|
2215
|
+
const generatorFunction = node.arguments[0];
|
|
2216
|
+
if (!ts.isFunctionExpression(generatorFunction)) {
|
|
2217
|
+
return typeParserIssue("Node is not a function expression", void 0, node);
|
|
2218
|
+
}
|
|
2219
|
+
if (generatorFunction.asteriskToken === void 0) {
|
|
2220
|
+
return typeParserIssue(
|
|
2221
|
+
"Node is not a generator function",
|
|
2222
|
+
void 0,
|
|
2223
|
+
node
|
|
2224
|
+
);
|
|
2225
|
+
}
|
|
2226
|
+
if (!ts.isPropertyAccessExpression(node.expression)) {
|
|
2227
|
+
return typeParserIssue(
|
|
2228
|
+
"Node is not a property access expression",
|
|
2229
|
+
void 0,
|
|
2230
|
+
node
|
|
2231
|
+
);
|
|
2232
|
+
}
|
|
2233
|
+
const propertyAccess = node.expression;
|
|
2234
|
+
if (propertyAccess.name.text !== "fnUntraced") {
|
|
2235
|
+
return typeParserIssue(
|
|
2236
|
+
"Call expression name is not 'fnUntraced'",
|
|
2237
|
+
void 0,
|
|
2238
|
+
node
|
|
2239
|
+
);
|
|
2240
|
+
}
|
|
2241
|
+
return pipe(
|
|
2242
|
+
importedEffectModule(propertyAccess.expression),
|
|
2243
|
+
map4((effectModule) => ({
|
|
2221
2244
|
node,
|
|
2222
2245
|
effectModule,
|
|
2223
2246
|
generatorFunction,
|
|
2224
2247
|
body: generatorFunction.body,
|
|
2225
2248
|
functionStar: generatorFunction.getFirstToken()
|
|
2226
|
-
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2249
|
+
}))
|
|
2250
|
+
);
|
|
2251
|
+
},
|
|
2229
2252
|
"TypeParser.effectFnUntracedGen",
|
|
2230
2253
|
(node) => node
|
|
2231
2254
|
);
|
|
2232
2255
|
const effectFnGen = cachedBy(
|
|
2233
|
-
|
|
2256
|
+
function(node) {
|
|
2234
2257
|
if (!ts.isCallExpression(node)) {
|
|
2235
|
-
return
|
|
2258
|
+
return typeParserIssue("Node is not a call expression", void 0, node);
|
|
2236
2259
|
}
|
|
2237
2260
|
if (node.arguments.length === 0) {
|
|
2238
|
-
return
|
|
2261
|
+
return typeParserIssue("Node has no arguments", void 0, node);
|
|
2239
2262
|
}
|
|
2240
2263
|
const generatorFunction = node.arguments[0];
|
|
2241
2264
|
if (!ts.isFunctionExpression(generatorFunction)) {
|
|
2242
|
-
return
|
|
2265
|
+
return typeParserIssue(
|
|
2243
2266
|
"Node is not a function expression",
|
|
2244
2267
|
void 0,
|
|
2245
2268
|
node
|
|
2246
2269
|
);
|
|
2247
2270
|
}
|
|
2248
2271
|
if (generatorFunction.asteriskToken === void 0) {
|
|
2249
|
-
return
|
|
2272
|
+
return typeParserIssue(
|
|
2250
2273
|
"Node is not a generator function",
|
|
2251
2274
|
void 0,
|
|
2252
2275
|
node
|
|
@@ -2254,7 +2277,7 @@ function make4(ts, typeChecker) {
|
|
|
2254
2277
|
}
|
|
2255
2278
|
const expressionToTest = ts.isCallExpression(node.expression) ? node.expression.expression : node.expression;
|
|
2256
2279
|
if (!ts.isPropertyAccessExpression(expressionToTest)) {
|
|
2257
|
-
return
|
|
2280
|
+
return typeParserIssue(
|
|
2258
2281
|
"Node is not a property access expression",
|
|
2259
2282
|
void 0,
|
|
2260
2283
|
node
|
|
@@ -2262,21 +2285,23 @@ function make4(ts, typeChecker) {
|
|
|
2262
2285
|
}
|
|
2263
2286
|
const propertyAccess = expressionToTest;
|
|
2264
2287
|
if (propertyAccess.name.text !== "fn") {
|
|
2265
|
-
return
|
|
2288
|
+
return typeParserIssue(
|
|
2266
2289
|
"Call expression name is not 'fn'",
|
|
2267
2290
|
void 0,
|
|
2268
2291
|
node
|
|
2269
2292
|
);
|
|
2270
2293
|
}
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2294
|
+
return pipe(
|
|
2295
|
+
importedEffectModule(propertyAccess.expression),
|
|
2296
|
+
map4((effectModule) => ({
|
|
2297
|
+
node,
|
|
2298
|
+
generatorFunction,
|
|
2299
|
+
effectModule,
|
|
2300
|
+
body: generatorFunction.body,
|
|
2301
|
+
functionStar: generatorFunction.getFirstToken()
|
|
2302
|
+
}))
|
|
2303
|
+
);
|
|
2304
|
+
},
|
|
2280
2305
|
"TypeParser.effectFnGen",
|
|
2281
2306
|
(node) => node
|
|
2282
2307
|
);
|
|
@@ -2407,6 +2432,20 @@ function make4(ts, typeChecker) {
|
|
|
2407
2432
|
"TypeParser.contextTag",
|
|
2408
2433
|
(type) => type
|
|
2409
2434
|
);
|
|
2435
|
+
const pipeCall = cachedBy(
|
|
2436
|
+
function(node) {
|
|
2437
|
+
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && node.expression.name.text === "pipe") {
|
|
2438
|
+
return succeed({ node, subject: node.expression.expression, args: Array.from(node.arguments) });
|
|
2439
|
+
}
|
|
2440
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "pipe" && node.arguments.length > 0) {
|
|
2441
|
+
const [subject, ...args] = node.arguments;
|
|
2442
|
+
return succeed({ node, subject, args });
|
|
2443
|
+
}
|
|
2444
|
+
return typeParserIssue("Node is not a pipe call", void 0, node);
|
|
2445
|
+
},
|
|
2446
|
+
"TypeParser.pipeCall",
|
|
2447
|
+
(node) => node
|
|
2448
|
+
);
|
|
2410
2449
|
return {
|
|
2411
2450
|
effectType,
|
|
2412
2451
|
layerType,
|
|
@@ -2418,7 +2457,8 @@ function make4(ts, typeChecker) {
|
|
|
2418
2457
|
effectFnGen,
|
|
2419
2458
|
unnecessaryEffectGen: unnecessaryEffectGen2,
|
|
2420
2459
|
effectSchemaType,
|
|
2421
|
-
contextTag
|
|
2460
|
+
contextTag,
|
|
2461
|
+
pipeCall
|
|
2422
2462
|
};
|
|
2423
2463
|
}
|
|
2424
2464
|
|
|
@@ -2797,18 +2837,6 @@ var completions = [
|
|
|
2797
2837
|
effectDataClasses
|
|
2798
2838
|
];
|
|
2799
2839
|
|
|
2800
|
-
// src/core/LanguageServicePluginOptions.ts
|
|
2801
|
-
var LanguageServicePluginOptions = Tag("PluginOptions");
|
|
2802
|
-
function parse(config) {
|
|
2803
|
-
return {
|
|
2804
|
-
diagnostics: isObject(config) && hasProperty(config, "diagnostics") && isBoolean(config.diagnostics) ? config.diagnostics : true,
|
|
2805
|
-
quickinfo: isObject(config) && hasProperty(config, "quickinfo") && isBoolean(config.quickinfo) ? config.quickinfo : true,
|
|
2806
|
-
completions: isObject(config) && hasProperty(config, "completions") && isBoolean(config.completions) ? config.completions : true,
|
|
2807
|
-
goto: isObject(config) && hasProperty(config, "goto") && isBoolean(config.goto) ? config.goto : true,
|
|
2808
|
-
allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : []
|
|
2809
|
-
};
|
|
2810
|
-
}
|
|
2811
|
-
|
|
2812
2840
|
// src/diagnostics/duplicatePackage.ts
|
|
2813
2841
|
var checkedPackagesCache = /* @__PURE__ */ new Map();
|
|
2814
2842
|
var programResolvedCacheSize = /* @__PURE__ */ new Map();
|
|
@@ -3311,6 +3339,53 @@ var unnecessaryEffectGen = createDiagnostic({
|
|
|
3311
3339
|
})
|
|
3312
3340
|
});
|
|
3313
3341
|
|
|
3342
|
+
// src/diagnostics/unnecessaryPipe.ts
|
|
3343
|
+
var unnecessaryPipe = createDiagnostic({
|
|
3344
|
+
name: "unnecessaryPipe",
|
|
3345
|
+
code: 9,
|
|
3346
|
+
apply: fn("unnecessaryPipe.apply")(function* (sourceFile) {
|
|
3347
|
+
const ts = yield* service(TypeScriptApi);
|
|
3348
|
+
const typeParser = yield* service(TypeParser);
|
|
3349
|
+
const pipeDiagnostics = [];
|
|
3350
|
+
const unnecessaryPipes = /* @__PURE__ */ new Map();
|
|
3351
|
+
const nodeToVisit = [];
|
|
3352
|
+
const appendNodeToVisit = (node) => {
|
|
3353
|
+
nodeToVisit.push(node);
|
|
3354
|
+
return void 0;
|
|
3355
|
+
};
|
|
3356
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
3357
|
+
while (nodeToVisit.length > 0) {
|
|
3358
|
+
const node = nodeToVisit.shift();
|
|
3359
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
3360
|
+
if (ts.isCallExpression(node)) {
|
|
3361
|
+
yield* pipe(
|
|
3362
|
+
typeParser.pipeCall(node),
|
|
3363
|
+
map4(({ args, subject }) => args.length === 0 ? unnecessaryPipes.set(node, subject) : void 0),
|
|
3364
|
+
ignore
|
|
3365
|
+
);
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
unnecessaryPipes.forEach(
|
|
3369
|
+
(pipeCall, pipeSubject) => pipeDiagnostics.push({
|
|
3370
|
+
node: pipeCall,
|
|
3371
|
+
category: ts.DiagnosticCategory.Suggestion,
|
|
3372
|
+
messageText: `This pipe call contains no arguments.`,
|
|
3373
|
+
fixes: [{
|
|
3374
|
+
fixName: "unnecessaryPipe_fix",
|
|
3375
|
+
description: "Remove the pipe call",
|
|
3376
|
+
apply: gen2(function* () {
|
|
3377
|
+
const textChanges = yield* service(
|
|
3378
|
+
ChangeTracker
|
|
3379
|
+
);
|
|
3380
|
+
textChanges.replaceNode(sourceFile, pipeSubject, pipeCall);
|
|
3381
|
+
})
|
|
3382
|
+
}]
|
|
3383
|
+
})
|
|
3384
|
+
);
|
|
3385
|
+
return pipeDiagnostics;
|
|
3386
|
+
})
|
|
3387
|
+
});
|
|
3388
|
+
|
|
3314
3389
|
// src/diagnostics.ts
|
|
3315
3390
|
var diagnostics = [
|
|
3316
3391
|
duplicatePackage,
|
|
@@ -3320,7 +3395,8 @@ var diagnostics = [
|
|
|
3320
3395
|
missingStarInYieldEffectGen,
|
|
3321
3396
|
unnecessaryEffectGen,
|
|
3322
3397
|
missingReturnYieldStar,
|
|
3323
|
-
leakingRequirements
|
|
3398
|
+
leakingRequirements,
|
|
3399
|
+
unnecessaryPipe
|
|
3324
3400
|
];
|
|
3325
3401
|
|
|
3326
3402
|
// src/goto/effectRpcDefinition.ts
|
|
@@ -3537,7 +3613,7 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
3537
3613
|
const ts = yield* service(TypeScriptApi);
|
|
3538
3614
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3539
3615
|
const typeParser = yield* service(TypeParser);
|
|
3540
|
-
const maybePipe = yield* option(
|
|
3616
|
+
const maybePipe = yield* option(typeParser.pipeCall(node));
|
|
3541
3617
|
if (isSome2(maybePipe)) {
|
|
3542
3618
|
let graphNode = yield* processLayerGraphNode(ctx, maybePipe.value.subject, void 0);
|
|
3543
3619
|
for (const entry of maybePipe.value.args) {
|
|
@@ -4078,8 +4154,8 @@ var effectGenToFn = createRefactor({
|
|
|
4078
4154
|
continue;
|
|
4079
4155
|
}
|
|
4080
4156
|
const maybePipe = yield* pipe(
|
|
4081
|
-
|
|
4082
|
-
orElse3((e) => parent.parent ?
|
|
4157
|
+
typeParser.pipeCall(parent),
|
|
4158
|
+
orElse3((e) => parent.parent ? typeParser.pipeCall(parent.parent) : fail(e)),
|
|
4083
4159
|
option
|
|
4084
4160
|
);
|
|
4085
4161
|
if (isSome2(maybePipe) && maybePipe.value.subject === nodeToReplace2) {
|
|
@@ -5352,10 +5428,15 @@ var refactors = [
|
|
|
5352
5428
|
// src/index.ts
|
|
5353
5429
|
var LSP_INJECTED_URI = "@effect/language-service/injected";
|
|
5354
5430
|
var init = (modules) => {
|
|
5431
|
+
let languageServicePluginOptions = parse({});
|
|
5432
|
+
function onConfigurationChanged(config) {
|
|
5433
|
+
languageServicePluginOptions = parse(config);
|
|
5434
|
+
}
|
|
5355
5435
|
function create(info) {
|
|
5356
5436
|
const languageService = info.languageService;
|
|
5437
|
+
languageServicePluginOptions = parse(info.config);
|
|
5357
5438
|
if (languageService[LSP_INJECTED_URI]) return languageService;
|
|
5358
|
-
|
|
5439
|
+
info.project.log("[@effect/language-service] Started!");
|
|
5359
5440
|
const diagnosticsErrorCodes = diagnostics.map((diagnostic) => diagnostic.code);
|
|
5360
5441
|
try {
|
|
5361
5442
|
;
|
|
@@ -5601,7 +5682,7 @@ var init = (modules) => {
|
|
|
5601
5682
|
};
|
|
5602
5683
|
return proxy;
|
|
5603
5684
|
}
|
|
5604
|
-
return { create };
|
|
5685
|
+
return { create, onConfigurationChanged };
|
|
5605
5686
|
};
|
|
5606
5687
|
module.exports = init;
|
|
5607
5688
|
//# sourceMappingURL=index.js.map
|