luaut-language-server 3.1.0 → 4.0.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/dist/{chunk-SCZTSX3Y.js → chunk-XK3KS3T4.js} +24 -13
- package/dist/chunk-XK3KS3T4.js.map +1 -0
- package/dist/cli.cjs +22 -11
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +22 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-SCZTSX3Y.js.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -61,6 +61,20 @@ function membersOf(type, aliases, seen = /* @__PURE__ */ new Set()) {
|
|
|
61
61
|
}
|
|
62
62
|
case "typeParam":
|
|
63
63
|
return membersOf(type.constraint, aliases, seen);
|
|
64
|
+
// An array and a string answer to the methods the language gives them
|
|
65
|
+
// — `names:filter(f)`, `text:trim()`. They are written in the parser's
|
|
66
|
+
// prelude as `ArrayMethods<T>` and `StringMethods`, so the element
|
|
67
|
+
// type goes in where `T` stands.
|
|
68
|
+
case "array":
|
|
69
|
+
case "tuple": {
|
|
70
|
+
const element = type.kind === "array" ? type.element : (0, import_luaut_parser.union)(type.elements);
|
|
71
|
+
const methods = aliases.get("ArrayMethods");
|
|
72
|
+
return methods ? membersOf((0, import_luaut_parser.substitute)(methods, /* @__PURE__ */ new Map([["T", element]])), aliases, seen) : [];
|
|
73
|
+
}
|
|
74
|
+
case "primitive":
|
|
75
|
+
return type.name === "string" ? membersOf(aliases.get("StringMethods"), aliases, seen) : [];
|
|
76
|
+
case "literal":
|
|
77
|
+
return type.base === "string" ? membersOf(aliases.get("StringMethods"), aliases, seen) : [];
|
|
64
78
|
default:
|
|
65
79
|
return [];
|
|
66
80
|
}
|
|
@@ -1472,12 +1486,7 @@ function memberItems(analysis, access) {
|
|
|
1472
1486
|
const object = access.object;
|
|
1473
1487
|
const type = withoutNil(analysis.types.typeOf.get(object));
|
|
1474
1488
|
const colon = access.type === "MethodCallExpression";
|
|
1475
|
-
if (
|
|
1476
|
-
if (!colon) return [];
|
|
1477
|
-
const id = analysis.scopes.globalsByName.get("string");
|
|
1478
|
-
const library = id === void 0 ? void 0 : analysis.types.bindingType.get(id);
|
|
1479
|
-
return membersOf(library, analysis.types.aliases).filter((member) => signaturesOf(member.property.type).length > 0).map((member) => memberItem(member.name, member.property.type, member.property.readonly));
|
|
1480
|
-
}
|
|
1489
|
+
if (isMethodOnly(type) && !colon) return [];
|
|
1481
1490
|
return membersOf(type, analysis.types.aliases).filter((member) => colon ? member.isMethod : true).map((member) => memberItem(member.name, member.property.type, member.property.readonly));
|
|
1482
1491
|
}
|
|
1483
1492
|
function withoutNil(type) {
|
|
@@ -1485,17 +1494,19 @@ function withoutNil(type) {
|
|
|
1485
1494
|
const kept = type.types.filter((t) => !(t.kind === "primitive" && t.name === "nil"));
|
|
1486
1495
|
return kept.length === 1 ? kept[0] : { ...type, types: kept };
|
|
1487
1496
|
}
|
|
1488
|
-
function
|
|
1497
|
+
function isMethodOnly(type) {
|
|
1489
1498
|
if (!type) return false;
|
|
1490
1499
|
switch (type.kind) {
|
|
1500
|
+
case "array":
|
|
1501
|
+
case "tuple":
|
|
1502
|
+
case "templateLiteral":
|
|
1503
|
+
return true;
|
|
1491
1504
|
case "primitive":
|
|
1492
1505
|
return type.name === "string";
|
|
1493
1506
|
case "literal":
|
|
1494
1507
|
return typeof type.value === "string";
|
|
1495
|
-
case "templateLiteral":
|
|
1496
|
-
return true;
|
|
1497
1508
|
case "union":
|
|
1498
|
-
return type.types.length > 0 && type.types.every(
|
|
1509
|
+
return type.types.length > 0 && type.types.every(isMethodOnly);
|
|
1499
1510
|
default:
|
|
1500
1511
|
return false;
|
|
1501
1512
|
}
|
|
@@ -2063,7 +2074,7 @@ function createServer(connection, options = {}) {
|
|
|
2063
2074
|
severity: import_node.DiagnosticSeverity.Information,
|
|
2064
2075
|
source: "luaut",
|
|
2065
2076
|
code: "no-config",
|
|
2066
|
-
message: 'No luaut.config.json applies to this file, so no types are loaded \u2014 not even `print`. Add one to this folder or a folder above
|
|
2077
|
+
message: 'No luaut.config.json applies to this file, so no types are loaded \u2014 not even `print`. Add one to this folder or a folder above: { "types": [], "paths": {}, "sourceMap": null }, listing in `types` the type libraries the project has installed.'
|
|
2067
2078
|
}];
|
|
2068
2079
|
};
|
|
2069
2080
|
documents.onDidOpen(publishAll);
|