layermap 0.1.30 → 0.1.32
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 +2 -1
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/analyzers/project-map-worker.mjs +4 -0
- package/dist/cli.mjs +466 -297
- package/package.json +1 -1
- package/pi/layermap.mjs +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -7,6 +7,8 @@ var __export = (target, all) => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// src/cli.ts
|
|
10
|
+
import { realpath as realpath4 } from "node:fs/promises";
|
|
11
|
+
import path15 from "node:path";
|
|
10
12
|
import { parseArgs } from "node:util";
|
|
11
13
|
|
|
12
14
|
// src/agent/environment.ts
|
|
@@ -1305,10 +1307,10 @@ function mergeDefs(...defs) {
|
|
|
1305
1307
|
function cloneDef(schema) {
|
|
1306
1308
|
return mergeDefs(schema._zod.def);
|
|
1307
1309
|
}
|
|
1308
|
-
function getElementAtPath(obj,
|
|
1309
|
-
if (!
|
|
1310
|
+
function getElementAtPath(obj, path16) {
|
|
1311
|
+
if (!path16)
|
|
1310
1312
|
return obj;
|
|
1311
|
-
return
|
|
1313
|
+
return path16.reduce((acc, key) => acc?.[key], obj);
|
|
1312
1314
|
}
|
|
1313
1315
|
function promiseAllObject(promisesObj) {
|
|
1314
1316
|
const keys = Object.keys(promisesObj);
|
|
@@ -1717,11 +1719,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1717
1719
|
}
|
|
1718
1720
|
return false;
|
|
1719
1721
|
}
|
|
1720
|
-
function prefixIssues(
|
|
1722
|
+
function prefixIssues(path16, issues) {
|
|
1721
1723
|
return issues.map((iss) => {
|
|
1722
1724
|
var _a3;
|
|
1723
1725
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1724
|
-
iss.path.unshift(
|
|
1726
|
+
iss.path.unshift(path16);
|
|
1725
1727
|
return iss;
|
|
1726
1728
|
});
|
|
1727
1729
|
}
|
|
@@ -1868,16 +1870,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1868
1870
|
}
|
|
1869
1871
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1870
1872
|
const fieldErrors = { _errors: [] };
|
|
1871
|
-
const processError = (error52,
|
|
1873
|
+
const processError = (error52, path16 = []) => {
|
|
1872
1874
|
for (const issue2 of error52.issues) {
|
|
1873
1875
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1874
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1876
|
+
issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
|
|
1875
1877
|
} else if (issue2.code === "invalid_key") {
|
|
1876
|
-
processError({ issues: issue2.issues }, [...
|
|
1878
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
1877
1879
|
} else if (issue2.code === "invalid_element") {
|
|
1878
|
-
processError({ issues: issue2.issues }, [...
|
|
1880
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
1879
1881
|
} else {
|
|
1880
|
-
const fullpath = [...
|
|
1882
|
+
const fullpath = [...path16, ...issue2.path];
|
|
1881
1883
|
if (fullpath.length === 0) {
|
|
1882
1884
|
fieldErrors._errors.push(mapper(issue2));
|
|
1883
1885
|
} else {
|
|
@@ -1904,17 +1906,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1904
1906
|
}
|
|
1905
1907
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1906
1908
|
const result = { errors: [] };
|
|
1907
|
-
const processError = (error52,
|
|
1909
|
+
const processError = (error52, path16 = []) => {
|
|
1908
1910
|
var _a3, _b;
|
|
1909
1911
|
for (const issue2 of error52.issues) {
|
|
1910
1912
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1911
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1913
|
+
issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
|
|
1912
1914
|
} else if (issue2.code === "invalid_key") {
|
|
1913
|
-
processError({ issues: issue2.issues }, [...
|
|
1915
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
1914
1916
|
} else if (issue2.code === "invalid_element") {
|
|
1915
|
-
processError({ issues: issue2.issues }, [...
|
|
1917
|
+
processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
|
|
1916
1918
|
} else {
|
|
1917
|
-
const fullpath = [...
|
|
1919
|
+
const fullpath = [...path16, ...issue2.path];
|
|
1918
1920
|
if (fullpath.length === 0) {
|
|
1919
1921
|
result.errors.push(mapper(issue2));
|
|
1920
1922
|
continue;
|
|
@@ -1946,8 +1948,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1946
1948
|
}
|
|
1947
1949
|
function toDotPath(_path) {
|
|
1948
1950
|
const segs = [];
|
|
1949
|
-
const
|
|
1950
|
-
for (const seg of
|
|
1951
|
+
const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1952
|
+
for (const seg of path16) {
|
|
1951
1953
|
if (typeof seg === "number")
|
|
1952
1954
|
segs.push(`[${seg}]`);
|
|
1953
1955
|
else if (typeof seg === "symbol")
|
|
@@ -14639,13 +14641,13 @@ function resolveRef(ref, ctx) {
|
|
|
14639
14641
|
if (!ref.startsWith("#")) {
|
|
14640
14642
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14641
14643
|
}
|
|
14642
|
-
const
|
|
14643
|
-
if (
|
|
14644
|
+
const path16 = ref.slice(1).split("/").filter(Boolean);
|
|
14645
|
+
if (path16.length === 0) {
|
|
14644
14646
|
return ctx.rootSchema;
|
|
14645
14647
|
}
|
|
14646
14648
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14647
|
-
if (
|
|
14648
|
-
const key =
|
|
14649
|
+
if (path16[0] === defsKey) {
|
|
14650
|
+
const key = path16[1];
|
|
14649
14651
|
if (!key || !ctx.defs[key]) {
|
|
14650
14652
|
throw new Error(`Reference not found: ${ref}`);
|
|
14651
14653
|
}
|
|
@@ -15959,8 +15961,8 @@ var MapAnalysisSchema = external_exports.object({
|
|
|
15959
15961
|
var mapPathAllowed = (relative, prefixes) => prefixes.some(
|
|
15960
15962
|
(prefix) => prefix === "." || relative === prefix || relative.startsWith(`${prefix}/`)
|
|
15961
15963
|
);
|
|
15962
|
-
var mapTestPath = (
|
|
15963
|
-
|
|
15964
|
+
var mapTestPath = (path16) => /(?:^|\/)(?:__tests__|tests?|fixtures?|e2e|testdata)(?:\/|$)|\.(?:spec|test)\.|_test\.(?:go|py)$|(?:^|\/)(?:test_[^/]*\.py|conftest\.py)$/iu.test(
|
|
15965
|
+
path16
|
|
15964
15966
|
);
|
|
15965
15967
|
|
|
15966
15968
|
// src/project-map-reference-types.ts
|
|
@@ -16044,11 +16046,11 @@ var string4 = (value) => {
|
|
|
16044
16046
|
var identity = (id2, reconstructed) => id2 === reconstructed ? [] : [JSON.stringify(id2)];
|
|
16045
16047
|
function encodeMapText(graph) {
|
|
16046
16048
|
const files = /* @__PURE__ */ new Map();
|
|
16047
|
-
const file2 = (
|
|
16048
|
-
let ref = files.get(
|
|
16049
|
+
const file2 = (path16) => {
|
|
16050
|
+
let ref = files.get(path16);
|
|
16049
16051
|
if (!ref) {
|
|
16050
16052
|
ref = `F${files.size + 1}`;
|
|
16051
|
-
files.set(
|
|
16053
|
+
files.set(path16, ref);
|
|
16052
16054
|
}
|
|
16053
16055
|
return ref;
|
|
16054
16056
|
};
|
|
@@ -16096,7 +16098,7 @@ function encodeMapText(graph) {
|
|
|
16096
16098
|
rows2.push(`B ${node(frontier.entityRef)} ${frontier.direction}`);
|
|
16097
16099
|
return [
|
|
16098
16100
|
...header,
|
|
16099
|
-
...[...files].map(([
|
|
16101
|
+
...[...files].map(([path16, ref]) => `${ref} ${JSON.stringify(path16)}`),
|
|
16100
16102
|
...rows2
|
|
16101
16103
|
].join("\n");
|
|
16102
16104
|
}
|
|
@@ -16116,10 +16118,10 @@ function decodeMapText(text) {
|
|
|
16116
16118
|
const at = (value) => {
|
|
16117
16119
|
const match = /^(F[1-9]\d*):(\d+)-(\d+)@(\d+)-(\d+)$/u.exec(value ?? "");
|
|
16118
16120
|
if (!match) return failed();
|
|
16119
|
-
const
|
|
16120
|
-
if (
|
|
16121
|
+
const path16 = files.get(match[1] ?? "");
|
|
16122
|
+
if (path16 === void 0) return failed();
|
|
16121
16123
|
return MapAnchorSchema.parse({
|
|
16122
|
-
path:
|
|
16124
|
+
path: path16,
|
|
16123
16125
|
startLine: Number(match[2]),
|
|
16124
16126
|
endLine: Number(match[3]),
|
|
16125
16127
|
start: Number(match[4]),
|
|
@@ -16196,8 +16198,8 @@ function decodeMapText(text) {
|
|
|
16196
16198
|
var locationSchema = MapAnchorSchema.describe(
|
|
16197
16199
|
"Source location: start/end are zero-based UTF-16 offsets with an exclusive end; line numbers are one-based."
|
|
16198
16200
|
);
|
|
16199
|
-
var location = ({ path:
|
|
16200
|
-
path:
|
|
16201
|
+
var location = ({ path: path16, startLine, endLine, start, end }) => ({
|
|
16202
|
+
path: path16,
|
|
16201
16203
|
startLine,
|
|
16202
16204
|
endLine,
|
|
16203
16205
|
start,
|
|
@@ -16300,11 +16302,11 @@ var MapNavigationObjectsSchema = external_exports.union([
|
|
|
16300
16302
|
),
|
|
16301
16303
|
external_exports.object({ files: external_exports.array(searchFileSchema) }).passthrough().refine((value) => !("format" in value), "Text navigation must decode through its format.").transform(
|
|
16302
16304
|
(value) => value.files.flatMap(
|
|
16303
|
-
({ path:
|
|
16305
|
+
({ path: path16, symbols }) => symbols.map(({ id: id2, name, kind, startLine, endLine, start, end, execution }) => ({
|
|
16304
16306
|
id: id2,
|
|
16305
16307
|
name,
|
|
16306
16308
|
kind,
|
|
16307
|
-
anchor: { path:
|
|
16309
|
+
anchor: { path: path16, startLine, endLine, start, end },
|
|
16308
16310
|
...execution ? { execution } : {}
|
|
16309
16311
|
}))
|
|
16310
16312
|
)
|
|
@@ -16317,10 +16319,10 @@ var mapSearchNavigation = (result) => {
|
|
|
16317
16319
|
for (const [index, object2] of found.entries()) {
|
|
16318
16320
|
const ranking = rankings[index];
|
|
16319
16321
|
if (!ranking) throw new Error("PROJECT_MAP_SEARCH_RANKING_MISSING");
|
|
16320
|
-
const
|
|
16322
|
+
const path16 = object2.anchor.path;
|
|
16321
16323
|
let file2 = files.at(-1);
|
|
16322
|
-
if (file2?.path !==
|
|
16323
|
-
file2 = { path:
|
|
16324
|
+
if (file2?.path !== path16) {
|
|
16325
|
+
file2 = { path: path16, symbols: [] };
|
|
16324
16326
|
files.push(file2);
|
|
16325
16327
|
}
|
|
16326
16328
|
file2.symbols.push({
|
|
@@ -16446,8 +16448,8 @@ var MapViewGraph = class {
|
|
|
16446
16448
|
}
|
|
16447
16449
|
return object2;
|
|
16448
16450
|
}
|
|
16449
|
-
objectsAt(
|
|
16450
|
-
return this.statements.path.all(this.version,
|
|
16451
|
+
objectsAt(path16) {
|
|
16452
|
+
return this.statements.path.all(this.version, path16).map((row) => {
|
|
16451
16453
|
const object2 = MapObjectSchema.parse(JSON.parse(String(row.object_json)));
|
|
16452
16454
|
this.objects.set(object2.id, object2);
|
|
16453
16455
|
return object2;
|
|
@@ -16566,8 +16568,8 @@ var MapViewGraph = class {
|
|
|
16566
16568
|
);
|
|
16567
16569
|
}
|
|
16568
16570
|
};
|
|
16569
|
-
function mapSelectDeclarations(graph,
|
|
16570
|
-
const objects2 = graph.objectsAt(
|
|
16571
|
+
function mapSelectDeclarations(graph, path16, name, line) {
|
|
16572
|
+
const objects2 = graph.objectsAt(path16).filter((object2) => !mapIsModule(object2));
|
|
16571
16573
|
const matching = name === void 0 ? objects2 : objects2.filter(
|
|
16572
16574
|
(object2) => object2.name === name || name.includes(".") && graph.qualifiedName(object2.id) === name
|
|
16573
16575
|
);
|
|
@@ -16589,12 +16591,12 @@ function requireMapObject(store, version2, selector, prefixes) {
|
|
|
16589
16591
|
if ([entityRef, locator, symbol2].filter((value) => value !== void 0).length !== 1 || entityRef !== void 0 && !entityRef.length)
|
|
16590
16592
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16591
16593
|
if (symbol2) {
|
|
16592
|
-
const
|
|
16593
|
-
if (!mapPathAllowed(
|
|
16594
|
+
const path16 = normalizeProjectEvidencePath(symbol2.path);
|
|
16595
|
+
if (!mapPathAllowed(path16, prefixes))
|
|
16594
16596
|
throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
|
|
16595
16597
|
const selected = mapSelectDeclarations(
|
|
16596
16598
|
new MapViewGraph(store, version2),
|
|
16597
|
-
|
|
16599
|
+
path16,
|
|
16598
16600
|
symbol2.name,
|
|
16599
16601
|
symbol2.line
|
|
16600
16602
|
);
|
|
@@ -16605,14 +16607,14 @@ function requireMapObject(store, version2, selector, prefixes) {
|
|
|
16605
16607
|
}
|
|
16606
16608
|
let rows2;
|
|
16607
16609
|
if (locator) {
|
|
16608
|
-
const
|
|
16610
|
+
const path16 = normalizeProjectEvidencePath(locator.path);
|
|
16609
16611
|
if (!Number.isSafeInteger(locator.start) || locator.start < 0 || locator.kind !== void 0 && !MapObjectKindSchema.safeParse(locator.kind).success)
|
|
16610
16612
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16611
|
-
if (!mapPathAllowed(
|
|
16613
|
+
if (!mapPathAllowed(path16, prefixes))
|
|
16612
16614
|
throw new ProjectEvidenceError("PROJECT_MAP_OBJECT_NOT_FOUND", false);
|
|
16613
16615
|
rows2 = store.database.prepare(`SELECT object_json FROM project_map_objects
|
|
16614
16616
|
WHERE version_ref = ? AND path = ? AND json_extract(object_json, '$.anchor.start') = ?
|
|
16615
|
-
AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2,
|
|
16617
|
+
AND (? IS NULL OR kind = ?) LIMIT 2`).all(version2, path16, locator.start, locator.kind ?? null, locator.kind ?? null);
|
|
16616
16618
|
} else {
|
|
16617
16619
|
rows2 = store.database.prepare(
|
|
16618
16620
|
"SELECT object_json FROM project_map_objects WHERE version_ref = ? AND entity_ref = ?"
|
|
@@ -16653,13 +16655,13 @@ function mapQueryPage(count, materialize, navigation, budget) {
|
|
|
16653
16655
|
|
|
16654
16656
|
// src/project-map-query-selection.ts
|
|
16655
16657
|
var mapQuerySelection = (input, knownKinds) => {
|
|
16656
|
-
const
|
|
16658
|
+
const path16 = normalizeProjectEvidencePath(input.path ?? ".", true) || ".";
|
|
16657
16659
|
const kinds = input.kinds ?? knownKinds;
|
|
16658
16660
|
if (!Array.isArray(kinds) || !kinds.length || kinds.length > knownKinds.length || kinds.some((kind) => !knownKinds.includes(kind)))
|
|
16659
16661
|
throw new ProjectEvidenceError("PROJECT_READ_INPUT_INVALID", false);
|
|
16660
|
-
return { path:
|
|
16662
|
+
return { path: path16, kinds: [...new Set(kinds)].sort() };
|
|
16661
16663
|
};
|
|
16662
|
-
var mapQueryPathMatches = (
|
|
16664
|
+
var mapQueryPathMatches = (path16, prefix) => prefix === "." || path16 === prefix || path16.startsWith(`${prefix}/`);
|
|
16663
16665
|
var mapQueryPathSql = (column) => `(? = '.' OR ${column} = ? OR substr(${column}, 1, length(?) + 1) = ? || '/')`;
|
|
16664
16666
|
|
|
16665
16667
|
// src/project-map-search-focus.ts
|
|
@@ -16757,7 +16759,7 @@ var declarationKinds = /* @__PURE__ */ new Set([
|
|
|
16757
16759
|
"METHOD",
|
|
16758
16760
|
"TYPE"
|
|
16759
16761
|
]);
|
|
16760
|
-
var fileStem = (
|
|
16762
|
+
var fileStem = (path16) => path16.slice(path16.lastIndexOf("/") + 1).replace(/\.(?:[cm]?[jt]sx?|vue|svelte|go|pyi?)$/iu, "");
|
|
16761
16763
|
var compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
16762
16764
|
var compareRows = (left, right) => right.ranking.score - left.ranking.score || compareText(left.object.anchor.path, right.object.anchor.path) || compareText(left.object.id, right.object.id);
|
|
16763
16765
|
function mapSearchQuery(input) {
|
|
@@ -16784,10 +16786,10 @@ function mapSearchQuery(input) {
|
|
|
16784
16786
|
}
|
|
16785
16787
|
function rank(object2, documentation, relationCount, query, focus) {
|
|
16786
16788
|
const name = object2.name.toLowerCase();
|
|
16787
|
-
const
|
|
16789
|
+
const path16 = object2.anchor.path.toLowerCase();
|
|
16788
16790
|
const values = {
|
|
16789
16791
|
NAME: [name],
|
|
16790
|
-
PATH: [
|
|
16792
|
+
PATH: [path16],
|
|
16791
16793
|
DOCUMENTATION: documentation.map((text) => text.toLowerCase())
|
|
16792
16794
|
};
|
|
16793
16795
|
const matched = query.terms.map((term) => ({
|
|
@@ -16812,12 +16814,12 @@ function rank(object2, documentation, relationCount, query, focus) {
|
|
|
16812
16814
|
score += 7e3;
|
|
16813
16815
|
signals.push("SYMBOL_CONTAINS");
|
|
16814
16816
|
} else if (matchedFields.includes("NAME")) signals.push("SYMBOL_CONTAINS");
|
|
16815
|
-
if (object2.kind === "FILE" && fileStem(
|
|
16817
|
+
if (object2.kind === "FILE" && fileStem(path16) === normalizedQuery) {
|
|
16816
16818
|
score += 11e3;
|
|
16817
16819
|
signals.push("EXACT_FILE_STEM");
|
|
16818
16820
|
}
|
|
16819
16821
|
if (matchedFields.includes("PATH")) {
|
|
16820
|
-
score +=
|
|
16822
|
+
score += path16.includes(normalizedQuery) ? 2500 : 0;
|
|
16821
16823
|
signals.push("PATH_CONTAINS");
|
|
16822
16824
|
}
|
|
16823
16825
|
if (matchedFields.includes("DOCUMENTATION")) {
|
|
@@ -16832,8 +16834,8 @@ function rank(object2, documentation, relationCount, query, focus) {
|
|
|
16832
16834
|
score += kindWeight[object2.kind] + Math.min(1200, relationCount * 20) + (focus?.score ?? 0);
|
|
16833
16835
|
if (declarationKinds.has(object2.kind)) signals.push("DECLARATION");
|
|
16834
16836
|
if (relationCount > 0) signals.push("GRAPH_CONNECTED");
|
|
16835
|
-
const isTest = mapTestPath(
|
|
16836
|
-
const isGenerated = generatedPath.test(
|
|
16837
|
+
const isTest = mapTestPath(path16);
|
|
16838
|
+
const isGenerated = generatedPath.test(path16);
|
|
16837
16839
|
const hasTestIntent = query.terms.some((term) => testQuery.test(term));
|
|
16838
16840
|
score += isTest ? hasTestIntent ? 1e3 : -5e3 : 300;
|
|
16839
16841
|
score += isGenerated ? -3e3 : 300;
|
|
@@ -17317,13 +17319,13 @@ function utf16Offsets(text) {
|
|
|
17317
17319
|
}
|
|
17318
17320
|
function offsetConverter(files, offsets) {
|
|
17319
17321
|
const converters = /* @__PURE__ */ new Map();
|
|
17320
|
-
return (
|
|
17321
|
-
let convert = converters.get(
|
|
17322
|
+
return (path16, offset) => {
|
|
17323
|
+
let convert = converters.get(path16);
|
|
17322
17324
|
if (!convert) {
|
|
17323
|
-
const text = files[
|
|
17325
|
+
const text = files[path16];
|
|
17324
17326
|
if (text === void 0) return invalid();
|
|
17325
17327
|
convert = offsets === "UTF16" ? (value) => value <= text.length ? value : invalid() : utf16Offsets(text);
|
|
17326
|
-
converters.set(
|
|
17328
|
+
converters.set(path16, convert);
|
|
17327
17329
|
}
|
|
17328
17330
|
return convert(offset);
|
|
17329
17331
|
};
|
|
@@ -17354,7 +17356,7 @@ function mapFactsAnalysis(facts, input, context) {
|
|
|
17354
17356
|
const collect = new MapOutputCollector(output);
|
|
17355
17357
|
const positions = new MapSourcePositions(input.files);
|
|
17356
17358
|
const offset = offsetConverter(input.files, context.offsets);
|
|
17357
|
-
const anchor = (
|
|
17359
|
+
const anchor = (path16, start, end) => positions.span(path16, offset(path16, start), offset(path16, end));
|
|
17358
17360
|
const located = /* @__PURE__ */ new Map();
|
|
17359
17361
|
const canonical = /* @__PURE__ */ new Map();
|
|
17360
17362
|
const bySpan = /* @__PURE__ */ new Map();
|
|
@@ -17921,8 +17923,8 @@ var goModule = /(?:^|\/)go\.mod$/u;
|
|
|
17921
17923
|
var codeHosts = /* @__PURE__ */ new Set(["github.com", "gitlab.com", "bitbucket.org"]);
|
|
17922
17924
|
var GO_MAP_LANGUAGE = Object.freeze({
|
|
17923
17925
|
id: "go-1.24-map-v9",
|
|
17924
|
-
claims: (
|
|
17925
|
-
reads: (
|
|
17926
|
+
claims: (path16) => path16.endsWith(".go"),
|
|
17927
|
+
reads: (path16) => goModule.test(path16),
|
|
17926
17928
|
// A module path, or the standard library, whose first path element has no dot.
|
|
17927
17929
|
importName: (specifier) => {
|
|
17928
17930
|
const parts = specifier.split("/");
|
|
@@ -17931,7 +17933,7 @@ var GO_MAP_LANGUAGE = Object.freeze({
|
|
|
17931
17933
|
return parts.slice(0, size).join("/");
|
|
17932
17934
|
},
|
|
17933
17935
|
// Go imports a package: the directory of the file.
|
|
17934
|
-
importTarget: (
|
|
17936
|
+
importTarget: (path16) => `${path16.slice(0, path16.lastIndexOf("/") + 1) || "./"}`,
|
|
17935
17937
|
create: () => new GoMapAnalyzer()
|
|
17936
17938
|
});
|
|
17937
17939
|
var GO_GAPS = [
|
|
@@ -17977,12 +17979,12 @@ var GoMapAnalyzer = class {
|
|
|
17977
17979
|
}
|
|
17978
17980
|
}
|
|
17979
17981
|
async analyze(session, signal) {
|
|
17980
|
-
const modules = session.readable.map((entry) => entry.path).filter((
|
|
17981
|
-
const moduleOf = (
|
|
17982
|
+
const modules = session.readable.map((entry) => entry.path).filter((path16) => goModule.test(path16)).sort();
|
|
17983
|
+
const moduleOf = (path16) => {
|
|
17982
17984
|
let best;
|
|
17983
17985
|
for (const modFile of modules) {
|
|
17984
17986
|
const directory = modFile.slice(0, modFile.lastIndexOf("/") + 1);
|
|
17985
|
-
if (
|
|
17987
|
+
if (path16.startsWith(directory) && (!best || directory.length > best.lastIndexOf("/") + 1))
|
|
17986
17988
|
best = modFile;
|
|
17987
17989
|
}
|
|
17988
17990
|
return best;
|
|
@@ -17998,11 +18000,11 @@ var GoMapAnalyzer = class {
|
|
|
17998
18000
|
for (const modFile of [...groups.keys()].sort()) {
|
|
17999
18001
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
18000
18002
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18001
|
-
for (const
|
|
18002
|
-
const text = session.texts[
|
|
18003
|
+
for (const path16 of [...groups.get(modFile) ?? [], ...modFile ? [modFile] : []]) {
|
|
18004
|
+
const text = session.texts[path16];
|
|
18003
18005
|
if (text === void 0)
|
|
18004
18006
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18005
|
-
files[
|
|
18007
|
+
files[path16] = text;
|
|
18006
18008
|
}
|
|
18007
18009
|
const input = {
|
|
18008
18010
|
contextRef: digestValue({
|
|
@@ -18037,8 +18039,8 @@ var GoMapAnalyzer = class {
|
|
|
18037
18039
|
if (text === void 0 || !existsSync3(this.resources.compilerPath))
|
|
18038
18040
|
throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
|
|
18039
18041
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18040
|
-
for (const [
|
|
18041
|
-
if (this.claims(
|
|
18042
|
+
for (const [path16, value] of Object.entries(input.files))
|
|
18043
|
+
if (this.claims(path16) || goModule.test(path16)) files[path16] = value;
|
|
18042
18044
|
const facts = await this.operation(
|
|
18043
18045
|
{
|
|
18044
18046
|
...input,
|
|
@@ -18068,14 +18070,14 @@ var BUILD_FILES = [
|
|
|
18068
18070
|
"pom.xml"
|
|
18069
18071
|
];
|
|
18070
18072
|
var buildFile = /(?:^|\/)(?:pom\.xml|(?:build|settings)\.gradle(?:\.kts)?)$/u;
|
|
18071
|
-
var directoryOf = (
|
|
18072
|
-
var nameOf = (
|
|
18073
|
+
var directoryOf = (path16) => path16.slice(0, path16.lastIndexOf("/") + 1);
|
|
18074
|
+
var nameOf = (path16) => path16.slice(path16.lastIndexOf("/") + 1);
|
|
18073
18075
|
var DEFAULT_RELEASE = 21;
|
|
18074
18076
|
var platformPackage = /^(?:java|jdk|sun|com\.sun|javax\.(?:annotation\.processing|crypto|imageio|lang\.model|management|naming|net|print|script|security|sound|sql|swing|tools|transaction\.xa|xml))(?:\.|$)/u;
|
|
18075
18077
|
var JAVA_MAP_LANGUAGE = Object.freeze({
|
|
18076
18078
|
id: "javac-lombok-1.18.48-map-v8",
|
|
18077
|
-
claims: (
|
|
18078
|
-
reads: (
|
|
18079
|
+
claims: (path16) => path16.endsWith(".java"),
|
|
18080
|
+
reads: (path16) => buildFile.test(path16),
|
|
18079
18081
|
// A package of the Java platform, or a library named by its first two package segments.
|
|
18080
18082
|
importName: (specifier) => platformPackage.test(specifier) ? "Java standard library" : specifier.split(".").slice(0, 2).join("."),
|
|
18081
18083
|
create: () => new JavaMapAnalyzer()
|
|
@@ -18165,12 +18167,12 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18165
18167
|
// The worker's request for a context: the Java sources, the release and which are tests.
|
|
18166
18168
|
request(input, buildTexts) {
|
|
18167
18169
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18168
|
-
for (const [
|
|
18169
|
-
if (this.claims(
|
|
18170
|
+
for (const [path16, text] of Object.entries(input.files))
|
|
18171
|
+
if (this.claims(path16)) files[path16] = text;
|
|
18170
18172
|
return {
|
|
18171
18173
|
files,
|
|
18172
18174
|
release: javaRelease(buildTexts, this.resources.runtimeVersion),
|
|
18173
|
-
tests: Object.keys(files).filter((
|
|
18175
|
+
tests: Object.keys(files).filter((path16) => mapTestPath(path16))
|
|
18174
18176
|
};
|
|
18175
18177
|
}
|
|
18176
18178
|
// The build files of a context's root directory, which declare its Java version.
|
|
@@ -18182,35 +18184,35 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18182
18184
|
}
|
|
18183
18185
|
async analyze(session, signal) {
|
|
18184
18186
|
this.refreshRuntime();
|
|
18185
|
-
const builds = session.readable.map((entry) => entry.path).filter((
|
|
18186
|
-
for (const
|
|
18187
|
-
const rank2 = (
|
|
18187
|
+
const builds = session.readable.map((entry) => entry.path).filter((path16) => buildFile.test(path16));
|
|
18188
|
+
for (const path16 of builds) session.configuration(path16);
|
|
18189
|
+
const rank2 = (path16) => BUILD_FILES.indexOf(nameOf(path16));
|
|
18188
18190
|
const roots = /* @__PURE__ */ new Map();
|
|
18189
18191
|
const modules = /* @__PURE__ */ new Map();
|
|
18190
|
-
for (const
|
|
18191
|
-
const directory = directoryOf(
|
|
18192
|
+
for (const path16 of builds) {
|
|
18193
|
+
const directory = directoryOf(path16);
|
|
18192
18194
|
const current = modules.get(directory);
|
|
18193
|
-
if (current === void 0 || rank2(
|
|
18194
|
-
const text = session.texts[
|
|
18195
|
-
if (/settings\.gradle(?:\.kts)?$/u.test(
|
|
18195
|
+
if (current === void 0 || rank2(path16) < rank2(current)) modules.set(directory, path16);
|
|
18196
|
+
const text = session.texts[path16] ?? "";
|
|
18197
|
+
if (/settings\.gradle(?:\.kts)?$/u.test(path16) || path16.endsWith("pom.xml") && /<modules>/u.test(text)) {
|
|
18196
18198
|
const root = roots.get(directory);
|
|
18197
|
-
if (root === void 0 || rank2(
|
|
18199
|
+
if (root === void 0 || rank2(path16) < rank2(root)) roots.set(directory, path16);
|
|
18198
18200
|
}
|
|
18199
18201
|
}
|
|
18200
|
-
const configOf = (
|
|
18202
|
+
const configOf = (path16) => {
|
|
18201
18203
|
let outer;
|
|
18202
18204
|
for (const directory of roots.keys())
|
|
18203
|
-
if (
|
|
18205
|
+
if (path16.startsWith(directory) && (outer === void 0 || directory.length < outer.length))
|
|
18204
18206
|
outer = directory;
|
|
18205
18207
|
if (outer !== void 0) return roots.get(outer);
|
|
18206
18208
|
let nearest;
|
|
18207
18209
|
for (const directory of modules.keys())
|
|
18208
|
-
if (
|
|
18210
|
+
if (path16.startsWith(directory) && (nearest === void 0 || directory.length > nearest.length))
|
|
18209
18211
|
nearest = directory;
|
|
18210
18212
|
return nearest === void 0 ? "" : modules.get(nearest);
|
|
18211
18213
|
};
|
|
18212
|
-
const output = (
|
|
18213
|
-
(directory) =>
|
|
18214
|
+
const output = (path16) => [...modules.keys()].some(
|
|
18215
|
+
(directory) => path16.startsWith(`${directory}build/`) || path16.startsWith(`${directory}target/`)
|
|
18214
18216
|
);
|
|
18215
18217
|
const groups = /* @__PURE__ */ new Map();
|
|
18216
18218
|
for (const entry of session.readable) {
|
|
@@ -18225,13 +18227,13 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18225
18227
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
18226
18228
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18227
18229
|
const rootBuilds = configPath ? BUILD_FILES.map((name) => `${directoryOf(configPath)}${name}`).filter(
|
|
18228
|
-
(
|
|
18230
|
+
(path16) => builds.includes(path16)
|
|
18229
18231
|
) : [];
|
|
18230
|
-
for (const
|
|
18231
|
-
const text = session.texts[
|
|
18232
|
+
for (const path16 of [...groups.get(configPath) ?? [], ...rootBuilds]) {
|
|
18233
|
+
const text = session.texts[path16];
|
|
18232
18234
|
if (text === void 0)
|
|
18233
18235
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18234
|
-
files[
|
|
18236
|
+
files[path16] = text;
|
|
18235
18237
|
}
|
|
18236
18238
|
const input = {
|
|
18237
18239
|
contextRef: digestValue({
|
|
@@ -18274,7 +18276,7 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18274
18276
|
const prior = JavaStateSchema.safeParse(previous?.state).data;
|
|
18275
18277
|
const incremental = previous && prior?.basis === basis ? {
|
|
18276
18278
|
changed: Object.keys(request.files).filter(
|
|
18277
|
-
(
|
|
18279
|
+
(path16) => digests.get(path16) !== previous.digests.get(path16)
|
|
18278
18280
|
),
|
|
18279
18281
|
state: prior.java
|
|
18280
18282
|
} : void 0;
|
|
@@ -18303,14 +18305,14 @@ var JavaMapAnalyzer = class _JavaMapAnalyzer {
|
|
|
18303
18305
|
continue;
|
|
18304
18306
|
}
|
|
18305
18307
|
const focus = new Set(facts.focus);
|
|
18306
|
-
if (!incremental || facts.focus.some((
|
|
18308
|
+
if (!incremental || facts.focus.some((path16) => !Object.hasOwn(request.files, path16)) || incremental.changed.some((path16) => !focus.has(path16)))
|
|
18307
18309
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18308
18310
|
analysis.objects = analysis.objects.filter((object2) => focus.has(object2.anchor.path));
|
|
18309
18311
|
analysis.relations = analysis.relations.filter((relation) => focus.has(relation.anchor.path));
|
|
18310
18312
|
analysis.notes = analysis.notes.filter((note) => focus.has(note.anchor.path));
|
|
18311
18313
|
session.accept(analysis, {
|
|
18312
18314
|
state,
|
|
18313
|
-
linked: analysis.parsedFiles.filter((
|
|
18315
|
+
linked: analysis.parsedFiles.filter((path16) => !focus.has(path16))
|
|
18314
18316
|
});
|
|
18315
18317
|
}
|
|
18316
18318
|
}
|
|
@@ -18622,12 +18624,12 @@ var PYTHON_STANDARD_LIBRARY = /* @__PURE__ */ new Set([
|
|
|
18622
18624
|
// src/project-map-language-python.ts
|
|
18623
18625
|
var CONFIGURATION = ["pyrightconfig.json", "pyproject.toml", "setup.cfg"];
|
|
18624
18626
|
var pythonConfig = /(?:^|\/)(?:pyrightconfig\.json|pyproject\.toml|setup\.cfg)$/u;
|
|
18625
|
-
var directoryOf2 = (
|
|
18627
|
+
var directoryOf2 = (path16) => path16.slice(0, path16.lastIndexOf("/") + 1);
|
|
18626
18628
|
var DEFAULT_PYTHON = { major: 3, minor: 13 };
|
|
18627
18629
|
var PYTHON_MAP_LANGUAGE = Object.freeze({
|
|
18628
18630
|
id: "pyright-1.1.414-map-v13",
|
|
18629
|
-
claims: (
|
|
18630
|
-
reads: (
|
|
18631
|
+
claims: (path16) => /\.pyi?$/u.test(path16),
|
|
18632
|
+
reads: (path16) => pythonConfig.test(path16),
|
|
18631
18633
|
// An absolute import names the standard library or a distribution's top-level package.
|
|
18632
18634
|
importName: (specifier) => {
|
|
18633
18635
|
const top = specifier.split(".", 1)[0] ?? specifier;
|
|
@@ -18679,21 +18681,21 @@ var PythonMapAnalyzer = class {
|
|
|
18679
18681
|
return {
|
|
18680
18682
|
root: input.configPath ? directoryOf2(input.configPath).replace(/\/$/u, "") : "",
|
|
18681
18683
|
pythonVersion: pythonVersion(input.files, input.configPath),
|
|
18682
|
-
tests: Object.keys(input.files).filter((
|
|
18684
|
+
tests: Object.keys(input.files).filter((path16) => this.claims(path16) && mapTestPath(path16))
|
|
18683
18685
|
};
|
|
18684
18686
|
}
|
|
18685
18687
|
async analyze(session, signal) {
|
|
18686
18688
|
const roots = /* @__PURE__ */ new Map();
|
|
18687
|
-
for (const
|
|
18688
|
-
const directory = directoryOf2(
|
|
18689
|
+
for (const path16 of session.readable.map((entry) => entry.path).filter((path17) => pythonConfig.test(path17))) {
|
|
18690
|
+
const directory = directoryOf2(path16);
|
|
18689
18691
|
const current = roots.get(directory);
|
|
18690
18692
|
const rank2 = (file2) => CONFIGURATION.indexOf(file2.slice(directory.length));
|
|
18691
|
-
if (current === void 0 || rank2(
|
|
18693
|
+
if (current === void 0 || rank2(path16) < rank2(current)) roots.set(directory, path16);
|
|
18692
18694
|
}
|
|
18693
|
-
const rootOf = (
|
|
18695
|
+
const rootOf = (path16) => {
|
|
18694
18696
|
let best;
|
|
18695
18697
|
for (const directory of roots.keys())
|
|
18696
|
-
if (
|
|
18698
|
+
if (path16.startsWith(directory) && (best === void 0 || directory.length > best.length))
|
|
18697
18699
|
best = directory;
|
|
18698
18700
|
return best === void 0 ? "" : roots.get(best);
|
|
18699
18701
|
};
|
|
@@ -18708,11 +18710,11 @@ var PythonMapAnalyzer = class {
|
|
|
18708
18710
|
for (const configPath of [...groups.keys()].sort()) {
|
|
18709
18711
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
18710
18712
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18711
|
-
for (const
|
|
18712
|
-
const text = session.texts[
|
|
18713
|
+
for (const path16 of [...groups.get(configPath) ?? [], ...configPath ? [configPath] : []]) {
|
|
18714
|
+
const text = session.texts[path16];
|
|
18713
18715
|
if (text === void 0)
|
|
18714
18716
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18715
|
-
files[
|
|
18717
|
+
files[path16] = text;
|
|
18716
18718
|
}
|
|
18717
18719
|
const input = {
|
|
18718
18720
|
contextRef: digestValue({
|
|
@@ -18760,8 +18762,8 @@ var PythonMapAnalyzer = class {
|
|
|
18760
18762
|
if (input.files[reference.targetPath] === void 0)
|
|
18761
18763
|
throw new ProjectEvidenceError("PROJECT_MAP_REFERENCE_TARGET_UNAVAILABLE", false);
|
|
18762
18764
|
const files = /* @__PURE__ */ Object.create(null);
|
|
18763
|
-
for (const [
|
|
18764
|
-
if (this.claims(
|
|
18765
|
+
for (const [path16, value] of Object.entries(input.files))
|
|
18766
|
+
if (this.claims(path16) || pythonConfig.test(path16)) files[path16] = value;
|
|
18765
18767
|
const facts = await this.operation(
|
|
18766
18768
|
{
|
|
18767
18769
|
...input,
|
|
@@ -18811,9 +18813,9 @@ var miniprogramEventOf = (target) => {
|
|
|
18811
18813
|
|
|
18812
18814
|
// src/project-map-language-typescript.ts
|
|
18813
18815
|
var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
18814
|
-
id: "typescript-7.0.2-map-
|
|
18815
|
-
claims: (
|
|
18816
|
-
reads: (
|
|
18816
|
+
id: "typescript-7.0.2-map-v21",
|
|
18817
|
+
claims: (path16) => /\.[cm]?[jt]sx?$/u.test(path16),
|
|
18818
|
+
reads: (path16) => path16.endsWith(".json") || path16.endsWith(".wxml") || path16 === "pnpm-workspace.yaml",
|
|
18817
18819
|
create: () => new TypeScriptMapAnalyzer()
|
|
18818
18820
|
});
|
|
18819
18821
|
var CONFIGURATIONS_KEPT = 4;
|
|
@@ -18935,9 +18937,9 @@ var TypeScriptMapAnalyzer = class {
|
|
|
18935
18937
|
accept(analysis);
|
|
18936
18938
|
return;
|
|
18937
18939
|
}
|
|
18938
|
-
const required2 = analysis.requiredFiles.map((
|
|
18939
|
-
const entry = byPath.get(
|
|
18940
|
-
if (!entry || Object.hasOwn(texts,
|
|
18940
|
+
const required2 = analysis.requiredFiles.map((path16) => {
|
|
18941
|
+
const entry = byPath.get(path16);
|
|
18942
|
+
if (!entry || Object.hasOwn(texts, path16))
|
|
18941
18943
|
throw new ProjectEvidenceError("PROJECT_MAP_PROTOCOL_INVALID", false);
|
|
18942
18944
|
return entry;
|
|
18943
18945
|
});
|
|
@@ -18995,16 +18997,16 @@ var MAP_LANGUAGES = Object.freeze([
|
|
|
18995
18997
|
]);
|
|
18996
18998
|
var mapAnalyzerSuite = (languages) => languages.map((language) => language.id).sort().join("+");
|
|
18997
18999
|
var PROJECT_MAP_ANALYZER = mapAnalyzerSuite(MAP_LANGUAGES);
|
|
18998
|
-
var mapCodePath = (
|
|
18999
|
-
var languageOf = (
|
|
19000
|
-
var mapLanguageOf = (
|
|
19000
|
+
var mapCodePath = (path16) => MAP_LANGUAGES.some((language) => language.claims(path16));
|
|
19001
|
+
var languageOf = (path16) => MAP_LANGUAGES.find((language) => language.claims(path16));
|
|
19002
|
+
var mapLanguageOf = (path16) => languageOf(path16)?.id;
|
|
19001
19003
|
var npmPackage = (specifier) => {
|
|
19002
19004
|
if (specifier.startsWith("node:")) return "node:*";
|
|
19003
19005
|
const parts = specifier.split("/");
|
|
19004
19006
|
return specifier.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0] ?? specifier;
|
|
19005
19007
|
};
|
|
19006
19008
|
var mapExternalImport = (sourcePath, specifier) => languageOf(sourcePath)?.importName?.(specifier) ?? npmPackage(specifier);
|
|
19007
|
-
var mapImportTarget = (
|
|
19009
|
+
var mapImportTarget = (path16) => languageOf(path16)?.importTarget?.(path16) ?? path16;
|
|
19008
19010
|
|
|
19009
19011
|
// src/project-map-view.ts
|
|
19010
19012
|
var MAP_VIEW_FORMAT = "PROJECT_MAP_VIEW_V1";
|
|
@@ -19043,10 +19045,10 @@ var notFound = () => {
|
|
|
19043
19045
|
};
|
|
19044
19046
|
var MAP_KINDS_LEGEND = "kinds f function, c class, m method, p property, v variable, t type, i interface, e enum; numbers are 1-based source lines";
|
|
19045
19047
|
var MAP_DECLARATION_LEGEND = `@n marks where a relationship occurs and +n counts further sites, which project_find_references lists; a quoted path after the sites is the route the call or value is registered under there: its HTTP methods when the registration names them, then its path joined with the prefixes of the routers it is registered on, as far as the same function or file sets them (a prefix added where a router is mounted or passed in is not included); route "\u2026" after a decorator is the full route the decorator maps, its class's path joined with its own. Static relationships are grouped by the declaration that owns them. Callers are direct calls, uses as a value (stored, passed, returned or selected, then usually invoked through that value) and calls through an interface, type or base member that a declaration implements (dispatched from); dispatches to lists the members that implement an interface, type or base member, which a call through it may reach; trace stops names calls whose target is a function value, a member without a mapped implementation or a computed key, which only source reading can follow; possible callers by name are calls elsewhere, in the same language, of a member with a method's name on a receiver of unknown type (an untyped value, or one an unloaded package produced); they may or may not reach that method.`;
|
|
19046
|
-
var within = (
|
|
19047
|
-
var parentDirectory = (
|
|
19048
|
-
const slash =
|
|
19049
|
-
return slash < 0 ? "." :
|
|
19048
|
+
var within = (path16, directory) => directory === "." || path16.startsWith(`${directory}/`);
|
|
19049
|
+
var parentDirectory = (path16) => {
|
|
19050
|
+
const slash = path16.lastIndexOf("/");
|
|
19051
|
+
return slash < 0 ? "." : path16.slice(0, slash);
|
|
19050
19052
|
};
|
|
19051
19053
|
var compareText2 = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
19052
19054
|
var byCount = ([leftName, left], [rightName, right]) => right - left || compareText2(leftName, rightName);
|
|
@@ -19120,7 +19122,7 @@ function pageBlocks(view, head, whole, offset, budget) {
|
|
|
19120
19122
|
if (offset === blocks.length) return materialize(0);
|
|
19121
19123
|
return mapQueryPage(blocks.length - offset, materialize, (page) => page, budget);
|
|
19122
19124
|
}
|
|
19123
|
-
var inModule = (
|
|
19125
|
+
var inModule = (path16, module) => module.direct ? parentDirectory(path16) === module.directory : within(path16, module.directory);
|
|
19124
19126
|
var moduleLabel = (module) => module.direct ? `${module.directory === "." ? "" : `${module.directory}/`}* (files directly here)` : `${module.directory}/`;
|
|
19125
19127
|
function childModules(module, files) {
|
|
19126
19128
|
if (module.direct) return [];
|
|
@@ -19175,9 +19177,9 @@ function mapProjectModules(entries) {
|
|
|
19175
19177
|
(entry) => entry.state === "TEXT" && mapCodePath(entry.path) && !mapTestPath(entry.path)
|
|
19176
19178
|
).map((entry) => entry.path)
|
|
19177
19179
|
);
|
|
19178
|
-
return (
|
|
19179
|
-
if (mapTestPath(
|
|
19180
|
-
const module = modules.find((candidate) => inModule(
|
|
19180
|
+
return (path16) => {
|
|
19181
|
+
if (mapTestPath(path16)) return void 0;
|
|
19182
|
+
const module = modules.find((candidate) => inModule(path16, candidate));
|
|
19181
19183
|
return module && moduleLabel(module);
|
|
19182
19184
|
};
|
|
19183
19185
|
}
|
|
@@ -19289,12 +19291,12 @@ function loadMemberCalls(store, version2) {
|
|
|
19289
19291
|
FROM project_map_relations
|
|
19290
19292
|
WHERE version_ref = ? AND to_ref IS NULL AND json_extract(relation_json, '$.kind') = 'CALLS'
|
|
19291
19293
|
AND json_extract(relation_json, '$.unresolvedReason') IN ('SYMBOL_NOT_RESOLVED', 'SYNTAX_ONLY')`).all(version2)) {
|
|
19292
|
-
const
|
|
19294
|
+
const path16 = String(row.path);
|
|
19293
19295
|
const target = String(row.target);
|
|
19294
19296
|
const name = MEMBER_NAME.exec(target)?.[1];
|
|
19295
|
-
const language = mapLanguageOf(
|
|
19297
|
+
const language = mapLanguageOf(path16);
|
|
19296
19298
|
if (!name || !language) continue;
|
|
19297
|
-
const call = { from: String(row.from_ref), path:
|
|
19299
|
+
const call = { from: String(row.from_ref), path: path16, line: Number(row.line), target };
|
|
19298
19300
|
const key = memberKey(language, name);
|
|
19299
19301
|
const known = calls.get(key);
|
|
19300
19302
|
if (known) known.push(call);
|
|
@@ -19349,10 +19351,10 @@ function loadCoverageNotes(store, version2) {
|
|
|
19349
19351
|
if (!codes.includes(gap.code)) codes.push(gap.code);
|
|
19350
19352
|
files.set(gap.path, codes);
|
|
19351
19353
|
}
|
|
19352
|
-
for (const [
|
|
19354
|
+
for (const [path16, codes] of files)
|
|
19353
19355
|
if (codes.length > 1 && codes.includes("NOT_IN_PARSED_CONTEXT"))
|
|
19354
19356
|
files.set(
|
|
19355
|
-
|
|
19357
|
+
path16,
|
|
19356
19358
|
codes.filter((code) => code !== "NOT_IN_PARSED_CONTEXT")
|
|
19357
19359
|
);
|
|
19358
19360
|
return { files, limits: [...limits] };
|
|
@@ -19392,9 +19394,9 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19392
19394
|
const visiblePaths = new Set(visible.map((entry) => entry.path));
|
|
19393
19395
|
const code = visible.filter((entry) => entry.state === "TEXT" && mapCodePath(entry.path)).map((entry) => entry.path);
|
|
19394
19396
|
const modules = mapModules(directory, code);
|
|
19395
|
-
const moduleOf = (
|
|
19396
|
-
const outside = (
|
|
19397
|
-
const parts =
|
|
19397
|
+
const moduleOf = (path16) => modules.find((module) => inModule(path16, module));
|
|
19398
|
+
const outside = (path16) => {
|
|
19399
|
+
const parts = path16.split("/");
|
|
19398
19400
|
return `${parts.slice(0, Math.min(2, parts.length - 1)).join("/") || "."}/ (outside)`;
|
|
19399
19401
|
};
|
|
19400
19402
|
const moduleImports = /* @__PURE__ */ new Map();
|
|
@@ -19419,8 +19421,8 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19419
19421
|
const blocks = [];
|
|
19420
19422
|
if (modules.length > 1) {
|
|
19421
19423
|
const sizes = /* @__PURE__ */ new Map();
|
|
19422
|
-
for (const
|
|
19423
|
-
const module = moduleOf(
|
|
19424
|
+
for (const path16 of code) {
|
|
19425
|
+
const module = moduleOf(path16);
|
|
19424
19426
|
if (module) increment(sizes, moduleLabel(module));
|
|
19425
19427
|
}
|
|
19426
19428
|
blocks.push(
|
|
@@ -19449,18 +19451,18 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19449
19451
|
)}${packages.length > shown.length ? `, +${packages.length - shown.length} more` : ""}`
|
|
19450
19452
|
);
|
|
19451
19453
|
}
|
|
19452
|
-
const lineCount = (
|
|
19453
|
-
const file2 = facts.files.get(
|
|
19454
|
-
const gaps = coverage.files.get(
|
|
19454
|
+
const lineCount = (path16) => {
|
|
19455
|
+
const file2 = facts.files.get(path16);
|
|
19456
|
+
const gaps = coverage.files.get(path16) ?? [];
|
|
19455
19457
|
if (file2?.parsed === false) return `[not parsed${gaps.length ? `: ${gaps.join("; ")}` : ""}]`;
|
|
19456
19458
|
return `${file2 ? `${file2.lines}L` : "?L"}${gaps.length ? ` [${gaps.join("; ")}]` : ""}`;
|
|
19457
19459
|
};
|
|
19458
19460
|
const codeDirectories = /* @__PURE__ */ new Set();
|
|
19459
|
-
for (const
|
|
19460
|
-
for (let parent = parentDirectory(
|
|
19461
|
+
for (const path16 of code)
|
|
19462
|
+
for (let parent = parentDirectory(path16); parent !== "." && !codeDirectories.has(parent); parent = parentDirectory(parent))
|
|
19461
19463
|
codeDirectories.add(parent);
|
|
19462
|
-
const groupOf = (
|
|
19463
|
-
let group = parentDirectory(
|
|
19464
|
+
const groupOf = (path16) => {
|
|
19465
|
+
let group = parentDirectory(path16);
|
|
19464
19466
|
for (let parent = group; parent !== "." && parent !== directory && !codeDirectories.has(parent); parent = parentDirectory(parent))
|
|
19465
19467
|
group = parent;
|
|
19466
19468
|
return group;
|
|
@@ -19492,11 +19494,11 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19492
19494
|
]);
|
|
19493
19495
|
}
|
|
19494
19496
|
const detailed = [
|
|
19495
|
-
...code.map((
|
|
19496
|
-
const declarations2 = (facts.exported.get(
|
|
19497
|
+
...code.map((path16) => {
|
|
19498
|
+
const declarations2 = (facts.exported.get(path16) ?? []).map(({ text: text2 }) => text2);
|
|
19497
19499
|
return [
|
|
19498
|
-
|
|
19499
|
-
`${
|
|
19500
|
+
path16,
|
|
19501
|
+
`${path16} ${lineCount(path16)}${declarations2.length ? `: ${declarations2.join(", ")}` : ""}`
|
|
19500
19502
|
];
|
|
19501
19503
|
}),
|
|
19502
19504
|
...listedOther.map((entry) => [
|
|
@@ -19507,7 +19509,7 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19507
19509
|
];
|
|
19508
19510
|
const directories = /* @__PURE__ */ new Map();
|
|
19509
19511
|
for (const entry of [
|
|
19510
|
-
...code.map((
|
|
19512
|
+
...code.map((path16) => ({ path: path16, item: lineCount(path16) })),
|
|
19511
19513
|
...listedOther.map((entry2) => ({
|
|
19512
19514
|
path: entry2.path,
|
|
19513
19515
|
item: entry2.state === "TEXT" ? "" : `(${entry2.state})`
|
|
@@ -19535,10 +19537,10 @@ function directoryView(facts, coverage, entries, input, directory, prefixes) {
|
|
|
19535
19537
|
);
|
|
19536
19538
|
const text = visible.filter((entry) => entry.state === "TEXT").length;
|
|
19537
19539
|
const resolution = /* @__PURE__ */ new Map();
|
|
19538
|
-
for (const
|
|
19539
|
-
const counts = facts.calls.get(
|
|
19540
|
+
for (const path16 of code) {
|
|
19541
|
+
const counts = facts.calls.get(path16);
|
|
19540
19542
|
if (!counts) continue;
|
|
19541
|
-
const language = facts.files.get(
|
|
19543
|
+
const language = facts.files.get(path16)?.language ?? "unknown";
|
|
19542
19544
|
const total = resolution.get(language) ?? { resolved: 0, unresolved: 0, external: 0 };
|
|
19543
19545
|
total.resolved += counts.resolved;
|
|
19544
19546
|
total.unresolved += counts.unresolved;
|
|
@@ -19597,8 +19599,8 @@ var DeclarationGroups = class {
|
|
|
19597
19599
|
prefixes;
|
|
19598
19600
|
showTests;
|
|
19599
19601
|
memberCalls;
|
|
19600
|
-
visible(
|
|
19601
|
-
return mapPathAllowed(
|
|
19602
|
+
visible(path16) {
|
|
19603
|
+
return mapPathAllowed(path16, this.prefixes) && (this.showTests || !mapTestPath(path16));
|
|
19602
19604
|
}
|
|
19603
19605
|
entry(object2, imported = false) {
|
|
19604
19606
|
if (mapMiniprogramTemplate(object2.anchor.path)) return "(template)";
|
|
@@ -19643,11 +19645,11 @@ var DeclarationGroups = class {
|
|
|
19643
19645
|
value.lines.push(line);
|
|
19644
19646
|
aggregates.set(key, value);
|
|
19645
19647
|
};
|
|
19646
|
-
const dispatch = (arrow, label, ref2,
|
|
19648
|
+
const dispatch = (arrow, label, ref2, path16, line) => {
|
|
19647
19649
|
const other = graph.object(graph.owner(ref2));
|
|
19648
19650
|
if (owned.has(other.id)) return;
|
|
19649
|
-
if (!this.visible(
|
|
19650
|
-
if (mapPathAllowed(
|
|
19651
|
+
if (!this.visible(path16)) {
|
|
19652
|
+
if (mapPathAllowed(path16, this.prefixes)) omittedTests++;
|
|
19651
19653
|
return;
|
|
19652
19654
|
}
|
|
19653
19655
|
add(arrow, label, other, line);
|
|
@@ -19804,7 +19806,7 @@ var DeclarationGroups = class {
|
|
|
19804
19806
|
else files2.set(call.path, [item]);
|
|
19805
19807
|
}
|
|
19806
19808
|
lines.push(
|
|
19807
|
-
` \u2190 possible callers by name: ${[...files2].map(([
|
|
19809
|
+
` \u2190 possible callers by name: ${[...files2].map(([path16, items]) => `${path16}: ${items.join(", ")}`).join("; ")}${inTests}`
|
|
19808
19810
|
);
|
|
19809
19811
|
} else if (possibleInTests)
|
|
19810
19812
|
lines.push(` \u2190 possible callers by name: ${possibleInTests} in test files (includeTests)`);
|
|
@@ -19840,14 +19842,14 @@ var DeclarationGroups = class {
|
|
|
19840
19842
|
return { lines, neighbors: [...new Set(neighbors)] };
|
|
19841
19843
|
}
|
|
19842
19844
|
};
|
|
19843
|
-
function fileView(store, coverage, graph, input,
|
|
19844
|
-
const entry = store.getEntry(input.version,
|
|
19845
|
-
if (!entry || !mapPathAllowed(
|
|
19846
|
-
const showTests = input.includeTests === true || mapTestPath(
|
|
19847
|
-
const module = mapCodePath(
|
|
19848
|
-
const gaps = coverage.files.get(
|
|
19845
|
+
function fileView(store, coverage, graph, input, path16, prefixes) {
|
|
19846
|
+
const entry = store.getEntry(input.version, path16);
|
|
19847
|
+
if (!entry || !mapPathAllowed(path16, prefixes)) return notFound();
|
|
19848
|
+
const showTests = input.includeTests === true || mapTestPath(path16);
|
|
19849
|
+
const module = mapCodePath(path16) ? graph.objectsAt(path16).find((object2) => mapIsModule(object2)) : mapMiniprogramTemplate(path16) ? graph.objectsAt(path16).find((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : void 0;
|
|
19850
|
+
const gaps = coverage.files.get(path16) ?? [];
|
|
19849
19851
|
const head = [
|
|
19850
|
-
`PROJECT MAP \xB7 FILE ${
|
|
19852
|
+
`PROJECT MAP \xB7 FILE ${path16} \xB7 ${entry.state !== "TEXT" ? entry.state : module ? module.parsing === "NOT_PARSED" ? `not parsed${gaps.length ? ` (${gaps.join("; ")})` : ""}; read it as text` : `${module.anchor.endLine} lines${gaps.length ? ` \xB7 ${gaps.join("; ")}` : ""}` : `${entry.byteLength} bytes, not analyzed; read it as text`}`
|
|
19851
19853
|
];
|
|
19852
19854
|
if (!module || entry.state !== "TEXT")
|
|
19853
19855
|
return pageBlocks("FILE", head, [], input.offset ?? 0, input.outputBudget);
|
|
@@ -19867,7 +19869,7 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
|
|
|
19867
19869
|
tags.set(relation.from, list);
|
|
19868
19870
|
}
|
|
19869
19871
|
const describe3 = (object2) => [
|
|
19870
|
-
`${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path ===
|
|
19872
|
+
`${object2.name} ${mapDeclarationLabel(object2)}${object2.anchor.path === path16 ? "" : ` (${object2.anchor.path})`}`,
|
|
19871
19873
|
...tags.get(object2.id) ?? []
|
|
19872
19874
|
].join(" ");
|
|
19873
19875
|
const declarations2 = [];
|
|
@@ -19882,11 +19884,11 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
|
|
|
19882
19884
|
);
|
|
19883
19885
|
}
|
|
19884
19886
|
const elsewhere = /* @__PURE__ */ new Map();
|
|
19885
|
-
for (const object2 of graph.objectsAt(
|
|
19887
|
+
for (const object2 of graph.objectsAt(path16)) {
|
|
19886
19888
|
const parent = mapIsModule(object2) ? void 0 : graph.parent(object2.id);
|
|
19887
19889
|
if (parent === void 0 || !graph.isAddressable(object2)) continue;
|
|
19888
19890
|
const container = graph.object(parent);
|
|
19889
|
-
if (mapIsModule(container) || container.anchor.path ===
|
|
19891
|
+
if (mapIsModule(container) || container.anchor.path === path16) continue;
|
|
19890
19892
|
const into = elsewhere.get(parent);
|
|
19891
19893
|
if (into) into.push(object2);
|
|
19892
19894
|
else elsewhere.set(parent, [object2]);
|
|
@@ -19900,7 +19902,7 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
|
|
|
19900
19902
|
if (declarations2.length) blocks.push(["DECLARATIONS (* exported)", ...declarations2].join("\n"));
|
|
19901
19903
|
const imports2 = /* @__PURE__ */ new Set();
|
|
19902
19904
|
const external = /* @__PURE__ */ new Set();
|
|
19903
|
-
const fileObjects = graph.objectsAt(
|
|
19905
|
+
const fileObjects = graph.objectsAt(path16).map((object2) => object2.id);
|
|
19904
19906
|
for (const relation of graph.relationsFrom(fileObjects)) {
|
|
19905
19907
|
if (!IMPORT_KINDS.has(relation.kind)) continue;
|
|
19906
19908
|
if (relation.to === void 0) external.add(relation.target);
|
|
@@ -19911,8 +19913,8 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
|
|
|
19911
19913
|
}
|
|
19912
19914
|
const importers = /* @__PURE__ */ new Set();
|
|
19913
19915
|
const testImporters = /* @__PURE__ */ new Set();
|
|
19914
|
-
const imported = mapImportTarget(
|
|
19915
|
-
const packageModules = imported ===
|
|
19916
|
+
const imported = mapImportTarget(path16);
|
|
19917
|
+
const packageModules = imported === path16 ? [module.id] : store.listEntries(input.version).filter((entry2) => mapImportTarget(entry2.path) === imported).flatMap((entry2) => graph.objectsAt(entry2.path).filter((object2) => mapIsModule(object2))).map((object2) => object2.id);
|
|
19916
19918
|
for (const relation of graph.relationsTo(packageModules)) {
|
|
19917
19919
|
if (!IMPORT_KINDS.has(relation.kind)) continue;
|
|
19918
19920
|
const source = relation.anchor.path;
|
|
@@ -19940,16 +19942,16 @@ function fileView(store, coverage, graph, input, path15, prefixes) {
|
|
|
19940
19942
|
if (scope.length) blocks.push(["MODULE SCOPE (top-level statements)", ...scope].join("\n"));
|
|
19941
19943
|
return pageBlocks("FILE", head, blocks, input.offset ?? 0, input.outputBudget);
|
|
19942
19944
|
}
|
|
19943
|
-
function declarationView(graph, input,
|
|
19945
|
+
function declarationView(graph, input, path16, prefixes, memberCalls) {
|
|
19944
19946
|
const requested = input.depth ?? 1;
|
|
19945
19947
|
if (!Number.isSafeInteger(requested) || requested < 1 || requested > MAP_VIEW_LIMITS.directedDepth)
|
|
19946
19948
|
return invalid2();
|
|
19947
19949
|
const both = (input.direction ?? "BOTH") === "BOTH";
|
|
19948
19950
|
const depth = both ? Math.min(requested, MAP_VIEW_LIMITS.bothDepth) : requested;
|
|
19949
19951
|
const { name, line } = input;
|
|
19950
|
-
const selected = mapSelectDeclarations(graph,
|
|
19952
|
+
const selected = mapSelectDeclarations(graph, path16, name, line);
|
|
19951
19953
|
if (!selected.length) return notFound();
|
|
19952
|
-
const showTests = input.includeTests === true || mapTestPath(
|
|
19954
|
+
const showTests = input.includeTests === true || mapTestPath(path16);
|
|
19953
19955
|
const groups = new DeclarationGroups(graph, input, prefixes, showTests, memberCalls);
|
|
19954
19956
|
const blocks = [];
|
|
19955
19957
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -19997,7 +19999,7 @@ function declarationView(graph, input, path15, prefixes, memberCalls) {
|
|
|
19997
19999
|
);
|
|
19998
20000
|
}
|
|
19999
20001
|
const head = [
|
|
20000
|
-
`PROJECT MAP \xB7 DECLARATION ${
|
|
20002
|
+
`PROJECT MAP \xB7 DECLARATION ${path16}${name === void 0 ? "" : ` ${name}`}${line === void 0 ? "" : ` line ${line}`} \xB7 direction ${input.direction ?? "BOTH"} \xB7 depth ${depth}${depth < requested ? ` (BOTH is limited to ${MAP_VIEW_LIMITS.bothDepth})` : ""}${prefixes.includes(".") ? "" : " \xB7 limited to authorized paths"}`,
|
|
20001
20003
|
...truncated ? [`Expansion stopped at ${MAP_VIEW_LIMITS.declarations} declarations.`] : [],
|
|
20002
20004
|
...(input.direction ?? "BOTH") === "OUTGOING" ? [] : [callerCoverage(input.textSearch ?? DEFAULT_TEXT_SEARCH)]
|
|
20003
20005
|
];
|
|
@@ -20124,10 +20126,10 @@ var ProjectMapQuery = class {
|
|
|
20124
20126
|
view(input, signal) {
|
|
20125
20127
|
this.requireReadableMap(input.version, signal);
|
|
20126
20128
|
const { offset, prefixes } = admission(input);
|
|
20127
|
-
const
|
|
20129
|
+
const path16 = normalizeProjectEvidencePath(input.path, true) || ".";
|
|
20128
20130
|
const view = mapView(
|
|
20129
20131
|
this.store,
|
|
20130
|
-
{ ...input, path:
|
|
20132
|
+
{ ...input, path: path16, offset, allowedPathPrefixes: prefixes },
|
|
20131
20133
|
this.views
|
|
20132
20134
|
);
|
|
20133
20135
|
if (signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
@@ -20327,13 +20329,13 @@ var ProjectMapSourceReader = class _ProjectMapSourceReader {
|
|
|
20327
20329
|
*/
|
|
20328
20330
|
async readAll(expected) {
|
|
20329
20331
|
if (this.signal.aborted) throw new ProjectEvidenceError("PROJECT_READ_CANCELLED", true);
|
|
20330
|
-
const paths = expected.map(({ path:
|
|
20331
|
-
assertProjectEvidencePathNotSensitive(
|
|
20332
|
-
if (isProjectEvidenceTraversalExcluded(
|
|
20332
|
+
const paths = expected.map(({ path: path16 }) => {
|
|
20333
|
+
assertProjectEvidencePathNotSensitive(path16);
|
|
20334
|
+
if (isProjectEvidenceTraversalExcluded(path16))
|
|
20333
20335
|
throw new ProjectEvidenceError("PROJECT_FILE_NOT_ALLOWED", false);
|
|
20334
|
-
return
|
|
20336
|
+
return path16;
|
|
20335
20337
|
});
|
|
20336
|
-
const results = this.commit ? await this.commit.readAll(paths) : await concurrently(paths, (
|
|
20338
|
+
const results = this.commit ? await this.commit.readAll(paths) : await concurrently(paths, (path16) => this.session.captureFile(path16));
|
|
20337
20339
|
for (const [index, { entry }] of results.entries()) {
|
|
20338
20340
|
const wanted = expected[index];
|
|
20339
20341
|
if (entry.state !== wanted?.state || entry.contentDigest !== wanted.contentDigest || entry.byteLength !== wanted.byteLength)
|
|
@@ -21044,7 +21046,7 @@ var CodeIndexStore = class {
|
|
|
21044
21046
|
const staged = this.stageUnits(buildRef, paths, linked);
|
|
21045
21047
|
const reused = linked ? this.database.prepare(`SELECT path, unit_ref FROM project_map_version_units
|
|
21046
21048
|
WHERE version_ref = ? AND path IN (SELECT value FROM json_each(?))`).all(linked.version, JSON.stringify([...linked.paths])).map((row) => ({ path: String(row.path), unit: String(row.unit_ref) })) : [];
|
|
21047
|
-
if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path:
|
|
21049
|
+
if (reused.length !== (linked?.paths.size ?? 0) || reused.some(({ path: path16 }) => !paths.has(path16)) || staged.some(({ path: path16 }) => linked?.paths.has(path16)))
|
|
21048
21050
|
throw new MapReplayConflict();
|
|
21049
21051
|
const units = [...staged, ...reused].sort(
|
|
21050
21052
|
(left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
|
|
@@ -21095,7 +21097,7 @@ var CodeIndexStore = class {
|
|
|
21095
21097
|
const member = this.database.prepare(
|
|
21096
21098
|
"INSERT INTO project_map_version_units VALUES (?, ?, ?)"
|
|
21097
21099
|
);
|
|
21098
|
-
for (const { path:
|
|
21100
|
+
for (const { path: path16, unit } of reused) member.run(version2.version, path16, unit);
|
|
21099
21101
|
this.database.prepare("INSERT INTO project_map_coverage VALUES (?, ?)").run(version2.version, canonicalJson(coverage));
|
|
21100
21102
|
}
|
|
21101
21103
|
this.database.exec("COMMIT");
|
|
@@ -21159,7 +21161,7 @@ var CodeIndexStore = class {
|
|
|
21159
21161
|
corrupt2();
|
|
21160
21162
|
}
|
|
21161
21163
|
if (linked) {
|
|
21162
|
-
const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((
|
|
21164
|
+
const unlinked = database.prepare("SELECT path FROM project_map_version_units WHERE version_ref = ?").all(linked.version).map((row) => String(row.path)).filter((path16) => !linked.paths.has(path16));
|
|
21163
21165
|
if (database.prepare(`SELECT 1 FROM project_map_objects gone
|
|
21164
21166
|
WHERE gone.version_ref = ? AND gone.path IN (SELECT value FROM json_each(?))
|
|
21165
21167
|
AND gone.entity_ref NOT IN (SELECT entity_ref FROM project_map_publish_objects)
|
|
@@ -21184,17 +21186,17 @@ var CodeIndexStore = class {
|
|
|
21184
21186
|
const units = [];
|
|
21185
21187
|
for (const row of database.prepare(`SELECT path FROM project_map_publish_objects
|
|
21186
21188
|
UNION SELECT path FROM project_map_publish_relations ORDER BY path`).all()) {
|
|
21187
|
-
const
|
|
21188
|
-
const hash2 = createHash3("sha256").update(
|
|
21189
|
+
const path16 = String(row.path);
|
|
21190
|
+
const hash2 = createHash3("sha256").update(path16).update("\0");
|
|
21189
21191
|
for (const [mark, statement] of [
|
|
21190
21192
|
["object", objects2],
|
|
21191
21193
|
["relation", relations],
|
|
21192
21194
|
["note", pathNotes]
|
|
21193
21195
|
])
|
|
21194
|
-
for (const fact of statement.all(
|
|
21196
|
+
for (const fact of statement.all(path16))
|
|
21195
21197
|
for (const value of Object.values(fact))
|
|
21196
21198
|
hash2.update(mark).update("\0").update(String(value)).update("\0");
|
|
21197
|
-
units.push({ path:
|
|
21199
|
+
units.push({ path: path16, unit: hash2.digest("hex") });
|
|
21198
21200
|
}
|
|
21199
21201
|
return units;
|
|
21200
21202
|
}
|
|
@@ -21212,13 +21214,13 @@ var CodeIndexStore = class {
|
|
|
21212
21214
|
"INSERT INTO project_map_unit_notes SELECT ?, * FROM project_map_publish_notes WHERE path = ?"
|
|
21213
21215
|
);
|
|
21214
21216
|
const member = database.prepare("INSERT INTO project_map_version_units VALUES (?, ?, ?)");
|
|
21215
|
-
for (const { path:
|
|
21216
|
-
if (insertUnit.run(unit,
|
|
21217
|
-
unitObjects.run(unit,
|
|
21218
|
-
unitRelations.run(unit,
|
|
21219
|
-
unitNotes.run(unit,
|
|
21217
|
+
for (const { path: path16, unit } of units) {
|
|
21218
|
+
if (insertUnit.run(unit, path16).changes) {
|
|
21219
|
+
unitObjects.run(unit, path16);
|
|
21220
|
+
unitRelations.run(unit, path16);
|
|
21221
|
+
unitNotes.run(unit, path16);
|
|
21220
21222
|
}
|
|
21221
|
-
member.run(version2,
|
|
21223
|
+
member.run(version2, path16, unit);
|
|
21222
21224
|
}
|
|
21223
21225
|
}
|
|
21224
21226
|
/**
|
|
@@ -21474,21 +21476,21 @@ var contextFiles = (context) => [
|
|
|
21474
21476
|
function replayableContexts(parent, digests) {
|
|
21475
21477
|
const sharing = /* @__PURE__ */ new Map();
|
|
21476
21478
|
for (const [ref, { context }] of parent.contexts)
|
|
21477
|
-
for (const
|
|
21478
|
-
const refs = sharing.get(
|
|
21479
|
+
for (const path16 of contextFiles(context)) {
|
|
21480
|
+
const refs = sharing.get(path16) ?? /* @__PURE__ */ new Set();
|
|
21479
21481
|
refs.add(ref);
|
|
21480
|
-
sharing.set(
|
|
21482
|
+
sharing.set(path16, refs);
|
|
21481
21483
|
}
|
|
21482
21484
|
const unchanged = /* @__PURE__ */ new Set();
|
|
21483
21485
|
for (const [ref, { context }] of parent.contexts)
|
|
21484
21486
|
if (contextFiles(context).every(
|
|
21485
|
-
(
|
|
21487
|
+
(path16) => digests.get(path16) !== void 0 && digests.get(path16) === parent.entries.get(path16)
|
|
21486
21488
|
))
|
|
21487
21489
|
unchanged.add(ref);
|
|
21488
21490
|
const replayable = /* @__PURE__ */ new Set();
|
|
21489
21491
|
for (const [ref, { context }] of parent.contexts)
|
|
21490
21492
|
if (unchanged.has(ref) && contextFiles(context).every(
|
|
21491
|
-
(
|
|
21493
|
+
(path16) => [...sharing.get(path16) ?? []].every((other) => unchanged.has(other))
|
|
21492
21494
|
))
|
|
21493
21495
|
replayable.add(ref);
|
|
21494
21496
|
return { replayable, sharing };
|
|
@@ -21521,8 +21523,8 @@ var ProjectMapAnalyzer = class {
|
|
|
21521
21523
|
languages;
|
|
21522
21524
|
observe;
|
|
21523
21525
|
id;
|
|
21524
|
-
claims(
|
|
21525
|
-
return this.languages.some((language) => language.claims(
|
|
21526
|
+
claims(path16) {
|
|
21527
|
+
return this.languages.some((language) => language.claims(path16));
|
|
21526
21528
|
}
|
|
21527
21529
|
references(input, reference, signal) {
|
|
21528
21530
|
const language = this.languages.find((language2) => language2.claims(reference.targetPath));
|
|
@@ -21562,7 +21564,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21562
21564
|
const reuse = (contextRef2, request, files2) => {
|
|
21563
21565
|
const digest = digestValue({
|
|
21564
21566
|
request,
|
|
21565
|
-
files: files2.map((
|
|
21567
|
+
files: files2.map((path16) => [path16, digests.get(path16) ?? null])
|
|
21566
21568
|
});
|
|
21567
21569
|
requests.set(contextRef2, digest);
|
|
21568
21570
|
if (!parent || !replayable.has(contextRef2)) return void 0;
|
|
@@ -21601,7 +21603,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21601
21603
|
const ref = analysis.contexts[0]?.ref ?? "";
|
|
21602
21604
|
if (options?.linked?.length) {
|
|
21603
21605
|
if (!parent || analysis.contexts.length !== 1) return invalidParent();
|
|
21604
|
-
for (const
|
|
21606
|
+
for (const path16 of options.linked) linked.add(path16);
|
|
21605
21607
|
this.observe?.({
|
|
21606
21608
|
operation: "LINK",
|
|
21607
21609
|
phase: "FINISHED",
|
|
@@ -21628,7 +21630,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21628
21630
|
});
|
|
21629
21631
|
for (const file2 of analysis.parsedFiles) parsed.add(file2);
|
|
21630
21632
|
const staged = factPaths(analysis);
|
|
21631
|
-
for (const
|
|
21633
|
+
for (const path16 of staged) stagedPaths.add(path16);
|
|
21632
21634
|
for (const context of analysis.contexts) {
|
|
21633
21635
|
for (const file2 of context.configurationFiles) configurationInputs.add(file2);
|
|
21634
21636
|
if (!replayed.has(context.ref))
|
|
@@ -21657,7 +21659,7 @@ var ProjectMapAnalyzer = class {
|
|
|
21657
21659
|
accept,
|
|
21658
21660
|
reuse,
|
|
21659
21661
|
previous,
|
|
21660
|
-
configuration: (
|
|
21662
|
+
configuration: (path16) => configurationInputs.add(path16),
|
|
21661
21663
|
observe: this.observe
|
|
21662
21664
|
},
|
|
21663
21665
|
signal
|
|
@@ -21694,12 +21696,12 @@ var ProjectMapAnalyzer = class {
|
|
|
21694
21696
|
if (files.objects.length) accept(files);
|
|
21695
21697
|
if (parent && (replayed.size || linked.size)) {
|
|
21696
21698
|
for (const ref of replayed.keys())
|
|
21697
|
-
for (const
|
|
21698
|
-
if (analyzedFiles.has(
|
|
21699
|
+
for (const path16 of contextFiles(parent.contexts.get(ref)?.context ?? invalidParent()))
|
|
21700
|
+
if (analyzedFiles.has(path16) || [...sharing.get(path16) ?? []].some((other) => !replayed.has(other)))
|
|
21699
21701
|
throw new MapReplayConflict();
|
|
21700
|
-
for (const paths of replayed.values()) for (const
|
|
21701
|
-
for (const
|
|
21702
|
-
if (analyzedFiles.has(
|
|
21702
|
+
for (const paths of replayed.values()) for (const path16 of paths) linked.add(path16);
|
|
21703
|
+
for (const path16 of linked)
|
|
21704
|
+
if (analyzedFiles.has(path16) || stagedPaths.has(path16)) throw new MapReplayConflict();
|
|
21703
21705
|
parent.link([...linked]);
|
|
21704
21706
|
}
|
|
21705
21707
|
result.parsedFiles = [...parsed].sort();
|
|
@@ -21994,8 +21996,8 @@ var CodeIndex = class {
|
|
|
21994
21996
|
for (const entry of this.store.listEntries(candidate))
|
|
21995
21997
|
if (entry.contentDigest) entries2.set(entry.path, entry.contentDigest);
|
|
21996
21998
|
let changed = 0;
|
|
21997
|
-
for (const [
|
|
21998
|
-
for (const
|
|
21999
|
+
for (const [path16, digest] of digests) if (entries2.get(path16) !== digest) changed++;
|
|
22000
|
+
for (const path16 of entries2.keys()) if (!digests.has(path16)) changed++;
|
|
21999
22001
|
if (!best || changed < best.changed) best = { version: candidate, entries: entries2, changed };
|
|
22000
22002
|
}
|
|
22001
22003
|
if (!best) return void 0;
|
|
@@ -22171,16 +22173,16 @@ var LITERAL = /(["'`])((?:\\.|(?!\1)[^\\])*)\1/gu;
|
|
|
22171
22173
|
var MOUNTING = /(?:\b(?:prefix|root_path|base_path|basePath|baseURL|baseUrl)\s*[=:]|\b(?:Group|Route|Mount|mount|use|include_router|PathPrefix|StripPrefix)\s*\()\s*$/u;
|
|
22172
22174
|
var LIMIT = Object.freeze({ routes: 40, clients: 5 });
|
|
22173
22175
|
var ROUTE = /^(?:[A-Z]+(?:\|[A-Z]+)* +)?\/\S*$/u;
|
|
22174
|
-
var segments = (
|
|
22176
|
+
var segments = (path16) => path16.split("/").filter(Boolean).map((text) => ({ text, param: PARAM.test(text) || /[{}$<>%]/u.test(text) }));
|
|
22175
22177
|
var routeSegments = (label) => segments(label.slice(label.indexOf("/")));
|
|
22176
22178
|
function requestedPath(literal3, joined) {
|
|
22177
22179
|
const match = /^(?:https?:\/\/[^/\s]+|(?:\$\{[^}]*\})+|@\{|redirect:|forward:)?(\/[^\s?#()"'`,;|]*)/u.exec(
|
|
22178
22180
|
literal3
|
|
22179
22181
|
) ?? void 0;
|
|
22180
|
-
const
|
|
22181
|
-
if (!
|
|
22182
|
-
const parts = segments(
|
|
22183
|
-
if (joined &&
|
|
22182
|
+
const path16 = match?.[1];
|
|
22183
|
+
if (!path16 || path16.startsWith("//") || path16.length < 3) return void 0;
|
|
22184
|
+
const parts = segments(path16);
|
|
22185
|
+
if (joined && path16.endsWith("/")) parts.push({ text: "*", param: true });
|
|
22184
22186
|
return parts;
|
|
22185
22187
|
}
|
|
22186
22188
|
var same = (route, requested) => route.param || !requested.param && route.text === requested.text;
|
|
@@ -22288,9 +22290,9 @@ var routeClientsLine = ({ route, removed, clients }) => `${JSON.stringify(route)
|
|
|
22288
22290
|
|
|
22289
22291
|
// src/project-map-dependencies.ts
|
|
22290
22292
|
var IMPORT_KINDS2 = /* @__PURE__ */ new Set(["IMPORTS", "TEST_IMPORTS"]);
|
|
22291
|
-
function imports(graph,
|
|
22293
|
+
function imports(graph, path16) {
|
|
22292
22294
|
const found = [];
|
|
22293
|
-
for (const relation of graph.relationsFrom(graph.objectsAt(
|
|
22295
|
+
for (const relation of graph.relationsFrom(graph.objectsAt(path16).map((object2) => object2.id)))
|
|
22294
22296
|
if (IMPORT_KINDS2.has(relation.kind) && relation.to !== void 0)
|
|
22295
22297
|
found.push({
|
|
22296
22298
|
target: graph.object(relation.to).anchor.path,
|
|
@@ -22307,9 +22309,9 @@ function pathBetween(edges, from, to) {
|
|
|
22307
22309
|
if (via.has(target)) continue;
|
|
22308
22310
|
via.set(target, module);
|
|
22309
22311
|
if (target === to) {
|
|
22310
|
-
const
|
|
22311
|
-
for (let step = module; step !== from; step = via.get(step) ?? from)
|
|
22312
|
-
return [from, ...
|
|
22312
|
+
const path16 = [to];
|
|
22313
|
+
for (let step = module; step !== from; step = via.get(step) ?? from) path16.unshift(step);
|
|
22314
|
+
return [from, ...path16];
|
|
22313
22315
|
}
|
|
22314
22316
|
next.push(target);
|
|
22315
22317
|
}
|
|
@@ -22529,9 +22531,9 @@ var KEYWORDS = new Set(
|
|
|
22529
22531
|
);
|
|
22530
22532
|
var ROWS = `SELECT entity_ref AS id, path, name, kind, object_json AS object
|
|
22531
22533
|
FROM project_map_objects WHERE version_ref = ? AND kind <> 'PROPERTY'`;
|
|
22532
|
-
function rows(store, version2,
|
|
22533
|
-
const statement = store.database.prepare(
|
|
22534
|
-
return (
|
|
22534
|
+
function rows(store, version2, path16) {
|
|
22535
|
+
const statement = store.database.prepare(path16 === void 0 ? ROWS : `${ROWS} AND path = ?`);
|
|
22536
|
+
return (path16 === void 0 ? statement.all(version2) : statement.all(version2, path16)).map((row) => {
|
|
22535
22537
|
const { anchor } = JSON.parse(String(row.object));
|
|
22536
22538
|
return {
|
|
22537
22539
|
id: String(row.id),
|
|
@@ -22572,10 +22574,10 @@ function lineWords(line) {
|
|
|
22572
22574
|
}
|
|
22573
22575
|
var within2 = (lines, declaration) => lines.some(([from, to]) => from <= declaration.startLine && declaration.endLine <= to);
|
|
22574
22576
|
async function similarCode(store, working, base, files, read) {
|
|
22575
|
-
const code = (
|
|
22577
|
+
const code = (path16) => mapCodePath(path16) !== void 0 && !mapTestPath(path16);
|
|
22576
22578
|
const changed = files.filter((file2) => file2.status !== "DELETED" && code(file2.path));
|
|
22577
22579
|
if (!changed.length) return [];
|
|
22578
|
-
const names = (version2,
|
|
22580
|
+
const names = (version2, path16) => new Set(declarations(rows(store, version2, path16)).map((item) => item.qualifiedName));
|
|
22579
22581
|
const movedOut = /* @__PURE__ */ new Set();
|
|
22580
22582
|
if (base !== void 0)
|
|
22581
22583
|
for (const file2 of files) {
|
|
@@ -22601,10 +22603,10 @@ async function similarCode(store, working, base, files, read) {
|
|
|
22601
22603
|
}
|
|
22602
22604
|
const all = [];
|
|
22603
22605
|
await Promise.all(
|
|
22604
|
-
[...byPath].map(async ([
|
|
22606
|
+
[...byPath].map(async ([path16, inFile]) => {
|
|
22605
22607
|
const found2 = declarations(inFile).filter(eligible);
|
|
22606
22608
|
if (!found2.length) return;
|
|
22607
|
-
const text = await read(
|
|
22609
|
+
const text = await read(path16);
|
|
22608
22610
|
if (text === void 0) return;
|
|
22609
22611
|
const lines = text.split("\n").map(lineWords);
|
|
22610
22612
|
for (const declaration of found2) {
|
|
@@ -22738,9 +22740,9 @@ async function readMapChanges(project, base, signal) {
|
|
|
22738
22740
|
...file2,
|
|
22739
22741
|
baseText: (await git.run(["show", `${commit}:${file2.basePath}`], gitOptions(project, signal))).stdout.toString("utf8")
|
|
22740
22742
|
};
|
|
22741
|
-
const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((
|
|
22742
|
-
for (const
|
|
22743
|
-
files.push({ path:
|
|
22743
|
+
const untracked = (await git.run(["ls-files", "--others", "--exclude-standard", "-z"], gitOptions(project, signal))).stdout.toString("utf8").split("\0").filter((path16) => path16 && !inExcludedDirectory(path16));
|
|
22744
|
+
for (const path16 of untracked)
|
|
22745
|
+
files.push({ path: path16, status: "ADDED", lines: [EVERYTHING], baseLines: [], binary: false });
|
|
22744
22746
|
const stranded = await strandedNames(
|
|
22745
22747
|
project,
|
|
22746
22748
|
diff,
|
|
@@ -22818,7 +22820,7 @@ var NON_CODE = [
|
|
|
22818
22820
|
[/(?:^|\/)\.env[^/]*$|\.(?:ya?ml|toml|ini|properties|conf|cfg)$/iu, "configuration"],
|
|
22819
22821
|
[/\.(?:html?|jinja2?|j2|hbs|ejs|tmpl|tpl|gohtml|vue|svelte|wxml)$/iu, "template"]
|
|
22820
22822
|
];
|
|
22821
|
-
var nonCodeKind = (
|
|
22823
|
+
var nonCodeKind = (path16) => NON_CODE.find(([pattern]) => pattern.test(path16))?.[1];
|
|
22822
22824
|
var LIMITS = Object.freeze({ depth: 8, declarations: 800, changed: 200, chain: 3, byName: 40 });
|
|
22823
22825
|
var CALLER_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES"]);
|
|
22824
22826
|
var NAMING_KINDS = /* @__PURE__ */ new Set(["CALLS", "REFERENCES", "EXTENDS", "IMPLEMENTS"]);
|
|
@@ -22845,8 +22847,11 @@ var Tracer = class {
|
|
|
22845
22847
|
unclear = [];
|
|
22846
22848
|
truncated = false;
|
|
22847
22849
|
callerCount = /* @__PURE__ */ new Map();
|
|
22850
|
+
known = /* @__PURE__ */ new Map();
|
|
22848
22851
|
// Declarations a decorator maps to a route: entry points already, never "top of a chain".
|
|
22849
22852
|
routes = /* @__PURE__ */ new Set();
|
|
22853
|
+
/** The declarations each route entry reaches the change through: its handlers. */
|
|
22854
|
+
handlers = /* @__PURE__ */ new Map();
|
|
22850
22855
|
/** Test support files that call the changed code; the tests beside and below them may use it. */
|
|
22851
22856
|
support = /* @__PURE__ */ new Set();
|
|
22852
22857
|
name = (ref) => this.graph.qualifiedName(ref);
|
|
@@ -22956,7 +22961,56 @@ var Tracer = class {
|
|
|
22956
22961
|
uses.push(`decorated by ${relation.target}`);
|
|
22957
22962
|
return [...new Set(uses)];
|
|
22958
22963
|
}
|
|
22964
|
+
/**
|
|
22965
|
+
* How code in the files runs each declaration: "call" when it calls it, directly or through other
|
|
22966
|
+
* code (their module-scope code counts, and other test code is passed through); "route" when it
|
|
22967
|
+
* does not, but one of the handlers is the declaration or calls it. Callers are followed from all
|
|
22968
|
+
* the declarations at once, as the trace follows them, and what reaches a caller reaches what it
|
|
22969
|
+
* calls.
|
|
22970
|
+
*/
|
|
22971
|
+
reach(refs, files, handlers) {
|
|
22972
|
+
const how = /* @__PURE__ */ new Map();
|
|
22973
|
+
const below = /* @__PURE__ */ new Map();
|
|
22974
|
+
const seen = new Set(refs);
|
|
22975
|
+
let truncated = false;
|
|
22976
|
+
let frontier = [...seen];
|
|
22977
|
+
for (let depth = 0; frontier.length; depth++) {
|
|
22978
|
+
const next = [];
|
|
22979
|
+
for (const current of frontier) {
|
|
22980
|
+
if (handlers.has(current)) how.set(current, "route");
|
|
22981
|
+
for (const caller of this.callers(current)) {
|
|
22982
|
+
if (files.has(this.graph.object(caller.ref).anchor.path)) {
|
|
22983
|
+
how.set(current, "call");
|
|
22984
|
+
continue;
|
|
22985
|
+
}
|
|
22986
|
+
const callees = below.get(caller.ref);
|
|
22987
|
+
if (callees) callees.push(current);
|
|
22988
|
+
else below.set(caller.ref, [current]);
|
|
22989
|
+
if (seen.has(caller.ref)) continue;
|
|
22990
|
+
if (depth + 1 > LIMITS.depth || seen.size >= LIMITS.declarations) {
|
|
22991
|
+
truncated = true;
|
|
22992
|
+
continue;
|
|
22993
|
+
}
|
|
22994
|
+
seen.add(caller.ref);
|
|
22995
|
+
next.push(caller.ref);
|
|
22996
|
+
}
|
|
22997
|
+
}
|
|
22998
|
+
frontier = next;
|
|
22999
|
+
}
|
|
23000
|
+
for (const kind of ["call", "route"]) {
|
|
23001
|
+
const pending = [...how].filter(([, found]) => found === kind).map(([ref]) => ref);
|
|
23002
|
+
for (let ref = pending.pop(); ref !== void 0; ref = pending.pop())
|
|
23003
|
+
for (const callee of below.get(ref) ?? [])
|
|
23004
|
+
if (!how.has(callee)) {
|
|
23005
|
+
how.set(callee, kind);
|
|
23006
|
+
pending.push(callee);
|
|
23007
|
+
}
|
|
23008
|
+
}
|
|
23009
|
+
return { how, truncated };
|
|
23010
|
+
}
|
|
22959
23011
|
callers(ref) {
|
|
23012
|
+
const known = this.known.get(ref);
|
|
23013
|
+
if (known) return known;
|
|
22960
23014
|
const callers = [];
|
|
22961
23015
|
for (const relation of this.graph.relationsTo([ref]))
|
|
22962
23016
|
if (CALLER_KINDS.has(relation.kind)) {
|
|
@@ -22996,6 +23050,7 @@ var Tracer = class {
|
|
|
22996
23050
|
}
|
|
22997
23051
|
}
|
|
22998
23052
|
}
|
|
23053
|
+
this.known.set(ref, callers);
|
|
22999
23054
|
return callers;
|
|
23000
23055
|
}
|
|
23001
23056
|
decoratorRoutes(current) {
|
|
@@ -23025,6 +23080,7 @@ var Tracer = class {
|
|
|
23025
23080
|
);
|
|
23026
23081
|
}
|
|
23027
23082
|
entry(label, route, at, site, certain, top = false) {
|
|
23083
|
+
if (route) this.handlers.set(label, (this.handlers.get(label) ?? /* @__PURE__ */ new Set()).add(at.ref));
|
|
23028
23084
|
const chain = [];
|
|
23029
23085
|
let step = !top ? at : at.via ? this.reached.get(at.via) : void 0;
|
|
23030
23086
|
for (; step && chain.length < LIMITS.chain; ) {
|
|
@@ -23045,34 +23101,35 @@ var Tracer = class {
|
|
|
23045
23101
|
this.areas.set(area, known);
|
|
23046
23102
|
}
|
|
23047
23103
|
/** A related test file; the closest relation (lowest rank) explains it. */
|
|
23048
|
-
test(
|
|
23049
|
-
if (!mapRunnableTest(
|
|
23050
|
-
const known = this.tests.get(
|
|
23104
|
+
test(path16, name, why, rank2) {
|
|
23105
|
+
if (!mapRunnableTest(path16)) return;
|
|
23106
|
+
const known = this.tests.get(path16) ?? { names: /* @__PURE__ */ new Set(), why, rank: rank2 };
|
|
23051
23107
|
if (rank2 < known.rank) Object.assign(known, { why, rank: rank2 });
|
|
23052
23108
|
if (name && !name.startsWith("<")) known.names.add(name);
|
|
23053
|
-
this.tests.set(
|
|
23109
|
+
this.tests.set(path16, known);
|
|
23054
23110
|
}
|
|
23055
23111
|
};
|
|
23056
23112
|
var mapRunnableTest = (file2) => /_test\.(?:go|py)$|(?:^|\/)test_[^/]*\.py$|\.(?:test|spec)\.[cm]?[jt]sx?$|(?:Test|Tests|IT)\.(?:java|kt)$/u.test(
|
|
23057
23113
|
file2
|
|
23058
23114
|
);
|
|
23059
23115
|
var renamedTemplate = (file2) => file2.status === "RENAMED" && file2.basePath !== void 0 && mapMiniprogramTemplate(file2.basePath);
|
|
23060
|
-
function mapChangeImpact(store, working, base, changes, project) {
|
|
23116
|
+
function mapChangeImpact(store, working, base, changes, project, tests) {
|
|
23061
23117
|
const graph = new MapViewGraph(store, working);
|
|
23062
23118
|
const cache = new MapViewCache();
|
|
23063
|
-
const
|
|
23119
|
+
const memberCalls = cache.memberCalls(store, working);
|
|
23120
|
+
const tracer = new Tracer(graph, memberCalls);
|
|
23064
23121
|
const changed = [];
|
|
23065
23122
|
const unclear = [];
|
|
23066
23123
|
const removed = [];
|
|
23067
|
-
const declarations2 = (g,
|
|
23068
|
-
const units = (g,
|
|
23124
|
+
const declarations2 = (g, path16) => g.objectsAt(path16).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
|
|
23125
|
+
const units = (g, path16) => mapMiniprogramTemplate(path16) ? g.objectsAt(path16).filter((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : declarations2(g, path16);
|
|
23069
23126
|
let changedCount = 0;
|
|
23070
23127
|
const starts = [];
|
|
23071
23128
|
const importers = /* @__PURE__ */ new Map();
|
|
23072
23129
|
let mapped;
|
|
23073
23130
|
const mappedPaths = () => mapped ??= store.database.prepare("SELECT DISTINCT path FROM project_map_objects WHERE version_ref = ?").all(working).map((row) => String(row.path));
|
|
23074
|
-
const topLevelChanged = (
|
|
23075
|
-
const note = `top-level code of ${
|
|
23131
|
+
const topLevelChanged = (path16) => {
|
|
23132
|
+
const note = `top-level code of ${path16} changed (imports, constants or registrations)`;
|
|
23076
23133
|
if (!unclear.includes(note)) unclear.push(note);
|
|
23077
23134
|
};
|
|
23078
23135
|
for (const file2 of changes.files) {
|
|
@@ -23124,6 +23181,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23124
23181
|
mirroredTests(mappedPaths(), file2.path, tracer);
|
|
23125
23182
|
}
|
|
23126
23183
|
tracer.trace(starts);
|
|
23184
|
+
const untested = tests && untestedChanges(project, graph, tracer, memberCalls, starts, changed, tests);
|
|
23127
23185
|
if (project) routeTests(project, store, working, [...tracer.entries.values()], tracer);
|
|
23128
23186
|
supportTests(store, working, tracer);
|
|
23129
23187
|
const rewrittenTests = [];
|
|
@@ -23208,13 +23266,13 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23208
23266
|
};
|
|
23209
23267
|
const lost = /* @__PURE__ */ new Map();
|
|
23210
23268
|
const changedAt = new Map(changes.files.map((file2) => [file2.path, file2]));
|
|
23211
|
-
for (const
|
|
23212
|
-
const template = graph.objectsAt(
|
|
23269
|
+
for (const path16 of mappedPaths().filter(mapMiniprogramTemplate)) {
|
|
23270
|
+
const template = graph.objectsAt(path16).find((object2) => mapIsModule(object2));
|
|
23213
23271
|
if (!template) continue;
|
|
23214
23272
|
const broken = graph.relationsFrom(graph.scope(template.id).refs).filter((relation) => relation.to === void 0 && NAMING_KINDS.has(relation.kind));
|
|
23215
23273
|
if (!broken.length) continue;
|
|
23216
|
-
const file2 = changedAt.get(
|
|
23217
|
-
const basePath = file2 ? file2.basePath :
|
|
23274
|
+
const file2 = changedAt.get(path16);
|
|
23275
|
+
const basePath = file2 ? file2.basePath : path16;
|
|
23218
23276
|
const was = basePath === void 0 ? void 0 : before.objectsAt(basePath).find(mapIsModule);
|
|
23219
23277
|
const links = was ? before.relationsFrom(before.scope(was.id).refs) : [];
|
|
23220
23278
|
for (const relation of broken) {
|
|
@@ -23223,7 +23281,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23223
23281
|
);
|
|
23224
23282
|
if (earlier.some((link) => link.to === void 0)) continue;
|
|
23225
23283
|
const event = miniprogramEventOf(relation.target);
|
|
23226
|
-
const at = `${
|
|
23284
|
+
const at = `${path16}:${relation.anchor.startLine}`;
|
|
23227
23285
|
if (file2 && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine)) {
|
|
23228
23286
|
unclear.push(
|
|
23229
23287
|
event ? `${at} binds the ${event.event} event of <${event.tag}>, which it does not emit` : relation.kind === "REFERENCES" ? `${at} puts <${relation.target}>, which its registration does not find` : `${at} binds ${relation.target}, which its page or component does not register`
|
|
@@ -23235,7 +23293,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23235
23293
|
const object2 = before.object(reached);
|
|
23236
23294
|
const name = mapIsModule(object2) ? `${object2.anchor.path} (template)${event ? `: ${event.event} event` : ""}` : `${object2.anchor.path}: ${before.qualifiedName(reached)} ${mapDeclarationLabel(object2)}`;
|
|
23237
23295
|
const users = lost.get(name) ?? /* @__PURE__ */ new Set();
|
|
23238
|
-
users.add(`${
|
|
23296
|
+
users.add(`${path16} (template)`);
|
|
23239
23297
|
lost.set(name, users);
|
|
23240
23298
|
}
|
|
23241
23299
|
}
|
|
@@ -23253,18 +23311,18 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23253
23311
|
beforeTracer.trace(gone);
|
|
23254
23312
|
for (const entry of beforeTracer.entries.values())
|
|
23255
23313
|
if (!tracer.entries.has(entry.label)) tracer.entries.set(entry.label, entry);
|
|
23256
|
-
for (const [
|
|
23257
|
-
const known = tracer.tests.get(
|
|
23314
|
+
for (const [path16, test] of beforeTracer.tests) {
|
|
23315
|
+
const known = tracer.tests.get(path16);
|
|
23258
23316
|
if (known) for (const name of test.names) known.names.add(name);
|
|
23259
|
-
else tracer.tests.set(
|
|
23317
|
+
else tracer.tests.set(path16, test);
|
|
23260
23318
|
}
|
|
23261
23319
|
for (const [area, known] of beforeTracer.areas) {
|
|
23262
23320
|
const now = tracer.areas.get(area);
|
|
23263
23321
|
if (!now) tracer.areas.set(area, known);
|
|
23264
23322
|
else {
|
|
23265
23323
|
for (const name of known.through) now.through.add(name);
|
|
23266
|
-
for (const [
|
|
23267
|
-
now.tests.set(
|
|
23324
|
+
for (const [path16, names] of known.tests)
|
|
23325
|
+
now.tests.set(path16, /* @__PURE__ */ new Set([...now.tests.get(path16) ?? [], ...names]));
|
|
23268
23326
|
}
|
|
23269
23327
|
}
|
|
23270
23328
|
unclear.push(...beforeTracer.unclear.filter((line) => !line.includes("has no callers")));
|
|
@@ -23289,10 +23347,10 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23289
23347
|
for (const ref of called) {
|
|
23290
23348
|
const object2 = before.object(ref);
|
|
23291
23349
|
if (mapIsModule(object2) || testCode(object2.anchor.path) || gone.includes(ref)) continue;
|
|
23292
|
-
const
|
|
23293
|
-
if (
|
|
23350
|
+
const path16 = moved.has(object2.anchor.path) ? moved.get(object2.anchor.path) : object2.anchor.path;
|
|
23351
|
+
if (path16 === void 0) continue;
|
|
23294
23352
|
const name = before.qualifiedName(ref);
|
|
23295
|
-
const now = declarations2(graph,
|
|
23353
|
+
const now = declarations2(graph, path16).find(
|
|
23296
23354
|
(candidate) => candidate.kind === object2.kind && graph.qualifiedName(candidate.id) === name
|
|
23297
23355
|
);
|
|
23298
23356
|
if (!now || outsideTests(tracer.callers(now.id), graph).length || tracer.usesWithoutCalls(now.id).length)
|
|
@@ -23300,7 +23358,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23300
23358
|
if (!outsideTests(beforeTracer.callers(ref), before).length) continue;
|
|
23301
23359
|
const tested = tracer.callers(now.id).length > 0;
|
|
23302
23360
|
uncalled.push(
|
|
23303
|
-
`${
|
|
23361
|
+
`${path16}: ${name} ${mapDeclarationLabel(now)}${tested ? " (only tests call it now)" : ""}`
|
|
23304
23362
|
);
|
|
23305
23363
|
}
|
|
23306
23364
|
uncalled.sort();
|
|
@@ -23309,11 +23367,9 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23309
23367
|
changed,
|
|
23310
23368
|
removed,
|
|
23311
23369
|
rewrittenTests,
|
|
23312
|
-
entries: [...tracer.entries.values()].sort(
|
|
23313
|
-
|
|
23314
|
-
|
|
23315
|
-
tests: [...tracer.tests].map(([path15, test]) => ({
|
|
23316
|
-
path: path15,
|
|
23370
|
+
entries: [...tracer.entries.values()].sort(entryOrder),
|
|
23371
|
+
tests: [...tracer.tests].map(([path16, test]) => ({
|
|
23372
|
+
path: path16,
|
|
23317
23373
|
names: [...test.names].sort(),
|
|
23318
23374
|
why: test.why,
|
|
23319
23375
|
rank: test.rank
|
|
@@ -23323,15 +23379,55 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23323
23379
|
areas: [...tracer.areas].map(([area, known]) => ({
|
|
23324
23380
|
area,
|
|
23325
23381
|
through: [...known.through].sort(),
|
|
23326
|
-
tests: [...known.tests].map(([
|
|
23382
|
+
tests: [...known.tests].map(([path16, names]) => ({ path: path16, names: [...names].sort() })).sort((left, right) => right.names.length - left.names.length)
|
|
23327
23383
|
})).sort((left, right) => right.tests.length - left.tests.length),
|
|
23328
23384
|
unclear: [.../* @__PURE__ */ new Set([...unclear, ...tracer.unclear])],
|
|
23329
23385
|
removedRoutes,
|
|
23330
23386
|
uncalled,
|
|
23331
23387
|
dependencies: newModuleDependencies(store, cache, working, base, changes.files),
|
|
23388
|
+
...untested ? { untested } : {},
|
|
23332
23389
|
truncated: tracer.truncated
|
|
23333
23390
|
};
|
|
23334
23391
|
}
|
|
23392
|
+
var entryOrder = (left, right) => Number(right.certain) - Number(left.certain) || Number(right.route) - Number(left.route) || (left.label < right.label ? -1 : left.label > right.label ? 1 : 0);
|
|
23393
|
+
function untestedChanges(project, graph, tracer, memberCalls, starts, changed, tests) {
|
|
23394
|
+
const given = new Set(tests);
|
|
23395
|
+
const routes = /* @__PURE__ */ new Set();
|
|
23396
|
+
const handlers = /* @__PURE__ */ new Set();
|
|
23397
|
+
if (project)
|
|
23398
|
+
for (const test of given) {
|
|
23399
|
+
let text;
|
|
23400
|
+
try {
|
|
23401
|
+
text = readFileSync3(path10.join(project, test), "utf8");
|
|
23402
|
+
} catch {
|
|
23403
|
+
continue;
|
|
23404
|
+
}
|
|
23405
|
+
for (const [label, refs] of tracer.handlers) {
|
|
23406
|
+
const fragment = routeFragment(label);
|
|
23407
|
+
if (!fragment || !text.includes(fragment)) continue;
|
|
23408
|
+
routes.add(label);
|
|
23409
|
+
for (const ref of refs) handlers.add(ref);
|
|
23410
|
+
}
|
|
23411
|
+
}
|
|
23412
|
+
const { how, truncated } = tracer.reach(starts, given, handlers);
|
|
23413
|
+
const unreached = [];
|
|
23414
|
+
const throughRoutes = [];
|
|
23415
|
+
for (const [at, ref] of starts.entries()) {
|
|
23416
|
+
const found = how.get(ref);
|
|
23417
|
+
if (found === "route") throughRoutes.push(changed[at] ?? "");
|
|
23418
|
+
else if (!found) unreached.push(at);
|
|
23419
|
+
}
|
|
23420
|
+
const above = new Tracer(graph, memberCalls);
|
|
23421
|
+
above.trace(unreached.map((at) => starts[at] ?? ""));
|
|
23422
|
+
return {
|
|
23423
|
+
changed: unreached.map((at) => changed[at] ?? ""),
|
|
23424
|
+
entries: [...above.entries.values()].sort(entryOrder),
|
|
23425
|
+
throughRoutes,
|
|
23426
|
+
routes: throughRoutes.length ? [...routes].sort() : [],
|
|
23427
|
+
missing: tests.filter((test) => !graph.objectsAt(test).length),
|
|
23428
|
+
truncated: unreached.length > 0 && (truncated || above.truncated)
|
|
23429
|
+
};
|
|
23430
|
+
}
|
|
23335
23431
|
function existingTestsChanged(before, after, file2, project) {
|
|
23336
23432
|
if (!file2.basePath || file2.baseText === void 0) return [];
|
|
23337
23433
|
const baseLines = file2.baseText.split("\n");
|
|
@@ -23377,10 +23473,10 @@ function importerTests(graph, objects2, tracer, importers) {
|
|
|
23377
23473
|
}
|
|
23378
23474
|
const next = [];
|
|
23379
23475
|
for (const imported of modules)
|
|
23380
|
-
for (const { path:
|
|
23381
|
-
if (testCode(
|
|
23476
|
+
for (const { path: path16, module } of importers.get(imported) ?? [])
|
|
23477
|
+
if (testCode(path16))
|
|
23382
23478
|
tracer.test(
|
|
23383
|
-
|
|
23479
|
+
path16,
|
|
23384
23480
|
void 0,
|
|
23385
23481
|
hop ? "imports a changed file indirectly" : "imports a changed file",
|
|
23386
23482
|
hop ? 4 : 2
|
|
@@ -23418,10 +23514,8 @@ function mirroredTests(paths, file2, tracer) {
|
|
|
23418
23514
|
function routeTests(project, store, version2, entries, tracer) {
|
|
23419
23515
|
const fragments = /* @__PURE__ */ new Map();
|
|
23420
23516
|
for (const entry of entries) {
|
|
23421
|
-
|
|
23422
|
-
|
|
23423
|
-
const longest = route.split(/\/(?:\{[^}]*\}|:[^/]+|<[^>]*>|\*)(?=\/|$)/u).sort((left, right) => right.length - left.length)[0];
|
|
23424
|
-
if (longest && longest.replace(/\//gu, "").length >= 4) fragments.set(longest, entry.label);
|
|
23517
|
+
const fragment = entry.route ? routeFragment(entry.label) : void 0;
|
|
23518
|
+
if (fragment) fragments.set(fragment, entry.label);
|
|
23425
23519
|
}
|
|
23426
23520
|
if (!fragments.size) return;
|
|
23427
23521
|
let budget = 32 * 1024 * 1024;
|
|
@@ -23448,9 +23542,9 @@ function routeTests(project, store, version2, entries, tracer) {
|
|
|
23448
23542
|
}
|
|
23449
23543
|
}
|
|
23450
23544
|
}
|
|
23451
|
-
function sameDirectoryTests(paths,
|
|
23452
|
-
const slash =
|
|
23453
|
-
const directory = slash < 0 ? "" :
|
|
23545
|
+
function sameDirectoryTests(paths, path16, tracer) {
|
|
23546
|
+
const slash = path16.lastIndexOf("/");
|
|
23547
|
+
const directory = slash < 0 ? "" : path16.slice(0, slash + 1);
|
|
23454
23548
|
for (const candidate of paths) {
|
|
23455
23549
|
if (!candidate.startsWith(directory)) continue;
|
|
23456
23550
|
if (candidate.slice(directory.length).includes("/") || !mapTestPath(candidate)) continue;
|
|
@@ -23481,15 +23575,19 @@ var LIST = Object.freeze({
|
|
|
23481
23575
|
similar: 10,
|
|
23482
23576
|
similarNames: 3
|
|
23483
23577
|
});
|
|
23484
|
-
function routesIn(graph,
|
|
23578
|
+
function routesIn(graph, path16) {
|
|
23485
23579
|
const routes = /* @__PURE__ */ new Set();
|
|
23486
|
-
for (const relation of graph.relationsFrom(graph.objectsAt(
|
|
23580
|
+
for (const relation of graph.relationsFrom(graph.objectsAt(path16).map((object2) => object2.id))) {
|
|
23487
23581
|
const route = relation.kind === "DECORATED_BY" ? relation.route ?? relation.argument : relation.argument;
|
|
23488
23582
|
if (route && ROUTE2.test(route)) routes.add(route);
|
|
23489
23583
|
}
|
|
23490
23584
|
return routes;
|
|
23491
23585
|
}
|
|
23492
23586
|
var routePath = (route) => route.slice(route.indexOf("/"));
|
|
23587
|
+
function routeFragment(label) {
|
|
23588
|
+
const longest = routePath(label).split(/\/(?:\{[^}]*\}|:[^/]+|<[^>]*>|\*)(?=\/|$)/u).sort((left, right) => right.length - left.length)[0];
|
|
23589
|
+
return longest && longest.replace(/\//gu, "").length >= 4 ? longest : void 0;
|
|
23590
|
+
}
|
|
23493
23591
|
async function checkMapChanges(input, signal) {
|
|
23494
23592
|
const { index, project, working } = input;
|
|
23495
23593
|
const changes = await readMapChanges(project, input.base, signal);
|
|
@@ -23497,7 +23595,7 @@ async function checkMapChanges(input, signal) {
|
|
|
23497
23595
|
const base = changes.files.some(
|
|
23498
23596
|
(file2) => file2.basePath !== void 0 && (file2.baseLines.length || file2.baseText !== void 0 || renamedTemplate(file2))
|
|
23499
23597
|
) ? await input.baseVersion(changes.commit, signal) : void 0;
|
|
23500
|
-
const impact = mapChangeImpact(index.store, working, base, changes, project);
|
|
23598
|
+
const impact = mapChangeImpact(index.store, working, base, changes, project, input.tests);
|
|
23501
23599
|
return {
|
|
23502
23600
|
text: mapChangesText(
|
|
23503
23601
|
changes,
|
|
@@ -23535,7 +23633,7 @@ function mapChangesText(changes, impact, clients = [], similar = []) {
|
|
|
23535
23633
|
const indirect = impact.tests.filter((test) => test.rank >= 4);
|
|
23536
23634
|
const routes = impact.entries.filter((entry2) => entry2.route);
|
|
23537
23635
|
const lines = [
|
|
23538
|
-
`PROJECT MAP \xB7 CHANGES against ${changes.base} (${changes.commit.slice(0, 12)}) \xB7 ${files} changed file${files === 1 ? "" : "s"} \xB7 ${impact.changed.length} changed and ${impact.removed.length} removed declarations \xB7 ${routes.length} routes and ${impact.entries.length - routes.length} other entry points reached \xB7 ${direct.length} related test files${indirect.length ? ` (+${indirect.length} importing the changes indirectly)` : ""}`
|
|
23636
|
+
`PROJECT MAP \xB7 CHANGES against ${changes.base} (${changes.commit.slice(0, 12)}) \xB7 ${files} changed file${files === 1 ? "" : "s"} \xB7 ${impact.changed.length} changed and ${impact.removed.length} removed declarations \xB7 ${routes.length} routes and ${impact.entries.length - routes.length} other entry points reached \xB7 ${direct.length} related test files${indirect.length ? ` (+${indirect.length} importing the changes indirectly)` : ""}${impact.untested ? ` \xB7 ${impact.untested.changed.length} changed declarations not reached by the given tests` : ""}`
|
|
23539
23637
|
];
|
|
23540
23638
|
if (!files) return `${lines[0]}
|
|
23541
23639
|
Nothing changed against ${changes.base}.`;
|
|
@@ -23662,6 +23760,43 @@ Nothing changed against ${changes.base}.`;
|
|
|
23662
23760
|
impact.entries.filter((e) => !e.certain).map(entry),
|
|
23663
23761
|
LIST.entries
|
|
23664
23762
|
);
|
|
23763
|
+
if (impact.untested) {
|
|
23764
|
+
const { changed, entries, throughRoutes, routes: routes2, missing, truncated } = impact.untested;
|
|
23765
|
+
const items = (shown, limit) => {
|
|
23766
|
+
lines.push(...shown.slice(0, limit).map((item) => ` ${item}`));
|
|
23767
|
+
if (shown.length > limit) lines.push(` +${shown.length - limit} more`);
|
|
23768
|
+
};
|
|
23769
|
+
lines.push("NOT REACHED BY THE GIVEN TESTS");
|
|
23770
|
+
if (missing.length)
|
|
23771
|
+
lines.push(` the map has no code for these given files: ${missing.join(", ")}`);
|
|
23772
|
+
if (changed.length) {
|
|
23773
|
+
lines.push(
|
|
23774
|
+
` ${changed.length} of ${impact.changed.length} changed declarations are reached by none of the given tests; ${entries.length ? "the entry points above them, then the declarations:" : "the declarations:"}`
|
|
23775
|
+
);
|
|
23776
|
+
items(
|
|
23777
|
+
entries.map((item) => `${entry(item)}${item.certain ? "" : " (possibly)"}`),
|
|
23778
|
+
LIST.entries
|
|
23779
|
+
);
|
|
23780
|
+
items(changed, LIST.changed);
|
|
23781
|
+
} else
|
|
23782
|
+
lines.push(
|
|
23783
|
+
impact.changed.length ? ` none: the given tests reach all ${impact.changed.length} changed declarations` : " none: the diff changes no declarations outside the tests"
|
|
23784
|
+
);
|
|
23785
|
+
if (throughRoutes.length) {
|
|
23786
|
+
lines.push(
|
|
23787
|
+
` ${throughRoutes.length} changed declarations are reached only through a route whose path a given test names, found by text (${routes2.map((route) => JSON.stringify(route)).join(", ")}):`
|
|
23788
|
+
);
|
|
23789
|
+
items(throughRoutes, LIST.changed);
|
|
23790
|
+
}
|
|
23791
|
+
if (truncated)
|
|
23792
|
+
lines.push(
|
|
23793
|
+
` callers were followed ${LIMITS.depth} levels or ${LIMITS.declarations} declarations up; a given test or entry point further up is not seen`
|
|
23794
|
+
);
|
|
23795
|
+
if (impact.changed.length)
|
|
23796
|
+
lines.push(
|
|
23797
|
+
"Reach is followed through resolved calls from the given files and the routes whose paths they name. Reached means a given test calls code that leads to it, not that the test takes that path or checks what it does; a call through dependency injection, reflection or a receiver of unknown type, or a path built at run time, may run code the map does not see."
|
|
23798
|
+
);
|
|
23799
|
+
}
|
|
23665
23800
|
if (clients.length) {
|
|
23666
23801
|
list(
|
|
23667
23802
|
"REQUESTED BY (code and templates outside the tests that request these routes' paths, found by text)",
|
|
@@ -24024,7 +24159,8 @@ var LayerMap = class _LayerMap {
|
|
|
24024
24159
|
/**
|
|
24025
24160
|
* What the working tree's changes against a commit (HEAD by default) affect: the changed and
|
|
24026
24161
|
* removed declarations, the entry points and tests their callers reach, and what the map cannot
|
|
24027
|
-
* see
|
|
24162
|
+
* see; with test files, by path from the repository root, also the changed code they do not run.
|
|
24163
|
+
* The base commit's map is built only when the diff removes or changes lines there.
|
|
24028
24164
|
*/
|
|
24029
24165
|
checkChanges(input, signal) {
|
|
24030
24166
|
return this.using(
|
|
@@ -24034,7 +24170,8 @@ var LayerMap = class _LayerMap {
|
|
|
24034
24170
|
project: this.project,
|
|
24035
24171
|
working: await this.current(signal, hold),
|
|
24036
24172
|
base: input.base ?? "HEAD",
|
|
24037
|
-
baseVersion: (commit, baseSignal) => this.versionAt(commit, baseSignal, hold)
|
|
24173
|
+
baseVersion: (commit, baseSignal) => this.versionAt(commit, baseSignal, hold),
|
|
24174
|
+
...input.tests ? { tests: input.tests } : {}
|
|
24038
24175
|
},
|
|
24039
24176
|
signal
|
|
24040
24177
|
)
|
|
@@ -24276,7 +24413,7 @@ var MAP_TOOL_NAMES = Object.freeze({
|
|
|
24276
24413
|
references: "project_find_references",
|
|
24277
24414
|
check: "project_check_changes"
|
|
24278
24415
|
});
|
|
24279
|
-
var mapDirectoryPath = (
|
|
24416
|
+
var mapDirectoryPath = (path16) => path16.length > 1 && path16.endsWith("/") && !path16.endsWith("//") ? path16.slice(0, -1) : path16;
|
|
24280
24417
|
var ProjectMapSearchInputSchema = external_exports.object({
|
|
24281
24418
|
path: external_exports.string().default("."),
|
|
24282
24419
|
query: external_exports.string().min(1).max(256),
|
|
@@ -24307,6 +24444,9 @@ var ProjectMapCheckInputSchema = external_exports.object({
|
|
|
24307
24444
|
),
|
|
24308
24445
|
path: external_exports.string().optional().describe(
|
|
24309
24446
|
"A file or directory in the repository to check, when the session works in more than one; the check covers that repository's whole working tree."
|
|
24447
|
+
),
|
|
24448
|
+
tests: external_exports.array(external_exports.string().min(1).max(1e3)).max(200).optional().describe(
|
|
24449
|
+
"Test files that should cover the change, such as the ones you wrote for it, as paths are given to the other tools: the report then adds NOT REACHED BY THE GIVEN TESTS, the changed declarations none of them calls or requests through a route, with the entry points above them."
|
|
24310
24450
|
)
|
|
24311
24451
|
}).strip();
|
|
24312
24452
|
var locatorSchema = MapObjectLocatorSchema.describe(
|
|
@@ -24333,7 +24473,7 @@ var mapToolDescriptions = (host) => {
|
|
|
24333
24473
|
return Object.freeze({
|
|
24334
24474
|
search: `${lead("search")}Find declarations and files whose names, paths or source documentation match query terms. ANY (default) matches any term, ALL requires every term, LITERAL matches the exact text. Results are ranked by relevance and grouped by file with the declaration name, kind, 1-based line range and matched fields (${MAP_KINDS_LEGEND}). Zoom into a result with project_explore_map({path,name}) or ${host.readResult}. This is not a full-text search and does not prove absence; ${host.textSearch}. Continue with offset and unchanged conditions.`,
|
|
24335
24475
|
explore: `${lead("explore")}Read the static project map, zooming from the whole project to one declaration. path "." or a directory lists modules, module imports, external packages and its files: with exported declarations when the listing is small, as file names and line counts by directory when larger, and as modules only when very large. Start here to see what exists before searching or reading. A file path lists its declarations and members, imports, importers and top-level statements. A file path with name (or Container.member), optionally narrowed by its start line, or with a line alone, shows that declaration's calls, callers (including uses as a value), writes, heritage, decorators and members, aggregated per related declaration with @line sites; closures and locals are folded into their named container. depth also expands the related declarations hop by hop: up to 8 in one direction, which traces callers up to entry points (INCOMING) or callees down (OUTGOING), and up to 3 for BOTH. To find what a change affects, select the declaration with direction INCOMING and a depth up to 8, continue from any NOT EXPANDED declarations the view names, then confirm the entry points in source. Test files and standard-library call targets are hidden and counted by default; includeTests and includeUnresolved show them. Views use ${MAP_KINDS_LEGEND}. In a declaration view, ${MAP_DECLARATION_LEGEND} ${host.readSource} The map is static: trace stops, possible callers by name, framework wiring and unresolved targets need source reading, and a missing relationship does not prove absence. When a page reports more entries, continue with offset and otherwise unchanged arguments.`,
|
|
24336
|
-
check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; REQUESTED BY, the code and templates outside the tests that request the path of a route whose handler the change reaches or a route it removed, found by text; EXISTING TESTS CHANGED, the tests that existed before the diff and whose code it changed or removed; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; NAMES STILL USED ELSEWHERE, environment variables and configuration keys the diff removed from a file that other files still read or set, found by text; NEW MODULE DEPENDENCIES, imports between the modules of the project overview that the base did not have, and those that make two modules depend on each other, for you to judge against the project's layers; EXISTING CODE LIKE THE NEW CODE, declarations the diff adds whose code reads almost the same as code the project already has; LEFT WITHOUT CALLERS, declarations whose last callers outside the tests the diff removed or changed, and that nothing extends, implements, overrides or wires with a decorator; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it. It does not run or write tests: run the related ones if the change needs verifying; a failing or rewritten test of a feature the request is not about means the change leaked, so restore the test and narrow the change; a new dependency that runs against the layers or closes a cycle means moving what both modules need down rather than importing upward; new code like existing code means using the existing code, or removing the old if the new replaces it; code left without callers means deleting it, with the tests that only test it, when the change replaced it; call it once when the edits are done; and confirm the entry points in source, since an empty list does not prove a change safe.`,
|
|
24476
|
+
check: `${lead("check")}Compares the working tree with a commit (HEAD by default, so uncommitted and untracked changes), finds the declarations the diff changed, removed or renamed, and follows their callers up to 8 levels. It reports, conclusion first: AFFECTED ENTRY POINTS reached through resolved calls, each route with its HTTP methods and full path and the chain to the change; POSSIBLY AFFECTED ones reached only through a call on an interface or base member; REQUESTED BY, the code and templates outside the tests that request the path of a route whose handler the change reaches or a route it removed, found by text; EXISTING TESTS CHANGED, the tests that existed before the diff and whose code it changed or removed; SHARED BY, when tests reach the changed code through more than one area (package or module), so a change meant for one feature may change others; NAMES STILL USED ELSEWHERE, environment variables and configuration keys the diff removed from a file that other files still read or set, found by text; NEW MODULE DEPENDENCIES, imports between the modules of the project overview that the base did not have, and those that make two modules depend on each other, for you to judge against the project's layers; EXISTING CODE LIKE THE NEW CODE, declarations the diff adds whose code reads almost the same as code the project already has; LEFT WITHOUT CALLERS, declarations whose last callers outside the tests the diff removed or changed, and that nothing extends, implements, overrides or wires with a decorator; CHECK BY HAND for what a static map cannot follow (changed configuration, templates, migrations or dependency files, changed route registrations, declarations with no callers, calls by name on receivers of unknown type); and RELATED TESTS, the existing test files that call the changed code, import a changed file or sit beside it; given tests, NOT REACHED BY THE GIVEN TESTS, the changed declarations none of them calls or requests through a route, with the entry points above them. It does not run or write tests: run the related ones if the change needs verifying; a failing or rewritten test of a feature the request is not about means the change leaked, so restore the test and narrow the change; a new dependency that runs against the layers or closes a cycle means moving what both modules need down rather than importing upward; new code like existing code means using the existing code, or removing the old if the new replaces it; code left without callers means deleting it, with the tests that only test it, when the change replaced it; call it once when the edits are done; and confirm the entry points in source, since an empty list does not prove a change safe.`,
|
|
24337
24477
|
references: `${lead("references")}Compute usages of a mapped declaration from current source, including aliases, re-exports and non-call references. Select it with symbol {path,name,line?} as printed by project_explore_map or project_search_map (line is its start line when names repeat), or with an entityRef or locator {path,start,kind}. Broader and more expensive than the cached callers in project_explore_map; file or unsupported declarations may lack a reference target. path and kinds filter usage locations before paging. ${host.grantRules}objects contains compact declarations; targetRef and reference ownerRef identify them. ${host.readReference} A file that several compiler contexts read (such as packages of one workspace) lists its references once per context, each with that context's configPath. Continue with nextCursor and unchanged conditions, including after an empty partial page. Filtered exhaustion and missing results do not prove absence.`
|
|
24338
24478
|
});
|
|
24339
24479
|
};
|
|
@@ -24375,11 +24515,18 @@ async function routeMapCall(start, { name, args }) {
|
|
|
24375
24515
|
const such = repositories.length ? `, such as ${repositories.join(", ")}` : "";
|
|
24376
24516
|
return named === "." ? `LAYERMAP_NOT_A_GIT_REPOSITORY: This session started in ${start.directory}, which is not in a Git repository. Name a file or directory in one, relative to that folder or absolute${such}.` : `LAYERMAP_NOT_A_GIT_REPOSITORY: ${path13.resolve(start.directory, named)} is not in a Git repository; LayerMap maps Git repositories${start.git ? "" : `. Name a file or directory in one, relative to ${start.directory} or absolute${such}`}.`;
|
|
24377
24517
|
}
|
|
24378
|
-
if (!holder)
|
|
24379
|
-
|
|
24380
|
-
|
|
24381
|
-
|
|
24382
|
-
|
|
24518
|
+
if (!holder) {
|
|
24519
|
+
const routed2 = value === void 0 ? args : { ...args, path: located.path };
|
|
24520
|
+
if (!Array.isArray(args.tests)) return { project: located.project, args: routed2 };
|
|
24521
|
+
const tests = [];
|
|
24522
|
+
for (const test of args.tests) {
|
|
24523
|
+
const within4 = await locate(start, test);
|
|
24524
|
+
if (within4?.project !== located.project)
|
|
24525
|
+
return `PROJECT_PATH_INVALID: test ${test} is not in ${located.project}, the repository checked.`;
|
|
24526
|
+
tests.push(within4.path);
|
|
24527
|
+
}
|
|
24528
|
+
return { project: located.project, args: { ...routed2, tests } };
|
|
24529
|
+
}
|
|
24383
24530
|
const routed = {
|
|
24384
24531
|
...args,
|
|
24385
24532
|
[holder]: { ...args[holder], path: located.path }
|
|
@@ -24475,7 +24622,13 @@ async function runMapTool(map2, { name, args }, signal) {
|
|
|
24475
24622
|
}
|
|
24476
24623
|
if (name === MAP_TOOL_NAMES.check) {
|
|
24477
24624
|
const input2 = args;
|
|
24478
|
-
return {
|
|
24625
|
+
return {
|
|
24626
|
+
text: (await map2.checkChanges(
|
|
24627
|
+
{ base: input2.base, ...input2.tests ? { tests: input2.tests } : {} },
|
|
24628
|
+
signal
|
|
24629
|
+
)).text,
|
|
24630
|
+
isError: false
|
|
24631
|
+
};
|
|
24479
24632
|
}
|
|
24480
24633
|
if (name === MAP_TOOL_NAMES.search) {
|
|
24481
24634
|
const input2 = args;
|
|
@@ -24998,13 +25151,23 @@ Usage:
|
|
|
24998
25151
|
[--depth N] [--tests] [--unresolved] [--offset N]
|
|
24999
25152
|
layermap search QUERY [--path DIR] [--mode ANY|ALL|LITERAL] [--max N] [--offset N]
|
|
25000
25153
|
layermap refs PATH NAME [--line N] [--path DIR] [--max N] [--cursor C]
|
|
25001
|
-
layermap check [--base REF]
|
|
25154
|
+
layermap check [--base REF] [TEST...] what the uncommitted changes (or those since REF) affect,
|
|
25155
|
+
and what of them the test files given do not run
|
|
25002
25156
|
|
|
25003
25157
|
The project is the Git work tree around the current directory unless --project names one; the MCP
|
|
25004
25158
|
server also maps any other repository a tool call's path names.
|
|
25005
25159
|
Maps are kept in ${cacheDirectory()}.`;
|
|
25006
25160
|
var log = (line) => process.stderr.write(`${line}
|
|
25007
25161
|
`);
|
|
25162
|
+
async function checkedTests(project, tests) {
|
|
25163
|
+
const here = await realpath4(process.cwd());
|
|
25164
|
+
return tests.map((test) => {
|
|
25165
|
+
const relative = path15.relative(project, path15.resolve(here, test));
|
|
25166
|
+
if (!relative || relative === ".." || relative.startsWith(`..${path15.sep}`) || path15.isAbsolute(relative))
|
|
25167
|
+
throw new Error(`${test} is not in ${project}.`);
|
|
25168
|
+
return relative.split(path15.sep).join("/");
|
|
25169
|
+
});
|
|
25170
|
+
}
|
|
25008
25171
|
var usage = (code) => {
|
|
25009
25172
|
(code ? process.stderr : process.stdout).write(`${USAGE}
|
|
25010
25173
|
`);
|
|
@@ -25112,7 +25275,13 @@ async function main(argv) {
|
|
|
25112
25275
|
offset: number4(values.offset)
|
|
25113
25276
|
}
|
|
25114
25277
|
],
|
|
25115
|
-
check: [
|
|
25278
|
+
check: [
|
|
25279
|
+
MAP_TOOL_NAMES.check,
|
|
25280
|
+
{
|
|
25281
|
+
base: values.base,
|
|
25282
|
+
tests: command === "check" && rest.length ? await checkedTests(project, rest) : void 0
|
|
25283
|
+
}
|
|
25284
|
+
],
|
|
25116
25285
|
refs: [
|
|
25117
25286
|
MAP_TOOL_NAMES.references,
|
|
25118
25287
|
{
|