diff --git a/src/domain/hopperValues.test.ts b/src/domain/hopperValues.test.ts index 493d581228..b612a7f3a4 100644 --- a/src/domain/hopperValues.test.ts +++ b/src/domain/hopperValues.test.ts @@ -6,8 +6,6 @@ import { procedureIdentitySchema, parseDocuments, parseListCount, - parseNames, - parseProcedures, parseRelatedAddresses, parseSegments, } from "./hopperValues.js"; @@ -22,27 +20,13 @@ describe("Hopper boundary values", () => { expect(addressDistance("0x0", "0x20000000000000")).toBeNull(); }); - it("parses Hopper's address-keyed name and string maps", () => { - expect(parseNames({ "0x1000": "_main" })).toEqual({ - ok: true, - value: [{ address: "0x1000", name: "_main" }], - }); + it("counts Hopper's address-keyed string maps", () => { expect( parseListCount({ "0x1000": "hello", "0x2000": "world" }, "strings"), ).toEqual({ ok: true, value: 2 }); }); it("parses direct and wrapped protocol shapes", () => { - expect(parseProcedures({ procedures: { "0x1": "main" } })).toEqual({ - ok: true, - value: [{ address: "0x1", name: "main" }], - }); - expect(parseNames({ names: [{ address: "0x2", name: "label" }] }).ok).toBe( - true, - ); - expect(parseNames({ items: [{ address: "0x2", value: "label" }] }).ok).toBe( - false, - ); expect(parseRelatedAddresses({ callers: ["0x3"] }, "callers")).toEqual({ ok: true, value: ["0x3"], @@ -78,8 +62,6 @@ describe("Hopper boundary values", () => { }); it.each([ - ["procedures", () => parseProcedures(["not-a-map"])], - ["names", () => parseNames([{ address: 1, name: "bad" }])], ["relations", () => parseRelatedAddresses([1], "callees")], ["segments", () => parseSegments([{ name: 1 }])], ["documents", () => parseDocuments([1])], diff --git a/src/domain/hopperValues.ts b/src/domain/hopperValues.ts index 2d88397686..dfe42cf987 100644 --- a/src/domain/hopperValues.ts +++ b/src/domain/hopperValues.ts @@ -38,11 +38,6 @@ export const addressDistance = (start: string, end: string): number | null => { return Number(distance); }; -const procedureMapSchema = z.record(z.string(), z.string()); -const addressedNamesSchema = z.array( - z.object({ address: z.string(), name: z.string() }), -); -const addressedNameMapSchema = z.record(z.string(), z.string()); const segmentSchema = z.object({ name: z.string(), start: z.string(), @@ -448,38 +443,6 @@ export const parseFunctionDossier = ( ); }; -/** Parse a provider's direct or wrapped procedure map into stable entries. */ -export const parseProcedures = ( - value: JsonValue, - operation = "list_procedures", -): Result => { - const parsed = procedureMapSchema.safeParse( - unwrapProperty(value, "procedures"), - ); - return parsed.success - ? ok( - Object.entries(parsed.data).map(([address, name]) => ({ - address, - name, - })), - ) - : invalid(operation, "procedure map", parsed.error); -}; - -/** Parse a provider's direct or wrapped list of address/name records. */ -export const parseNames = ( - value: JsonValue, - operation = "list_names", -): Result => { - const unwrapped = unwrapProperty(value, "names"); - const records = addressedNamesSchema.safeParse(unwrapped); - if (records.success) return ok(records.data); - const map = addressedNameMapSchema.safeParse(unwrapped); - return map.success - ? ok(Object.entries(map.data).map(([address, name]) => ({ address, name }))) - : invalid(operation, "name list", map.error); -}; - /** Parse callee/caller strings from direct or wrapped provider results. */ export const parseRelatedAddresses = ( value: JsonValue, diff --git a/src/domain/javascript/javascriptStaticAnalysisHelpers.ts b/src/domain/javascript/javascriptStaticAnalysisHelpers.ts index 674fef983a..f8347c3d68 100644 --- a/src/domain/javascript/javascriptStaticAnalysisHelpers.ts +++ b/src/domain/javascript/javascriptStaticAnalysisHelpers.ts @@ -725,11 +725,7 @@ export const calleeName = (node: t.Node): string => { if (!t.isNode(node.object)) break; node = unwrapJavaScriptExpression(node.object).node; } - const base = t.isIdentifier(node) - ? node.name - : t.isImport(node) - ? "import" - : ""; + const base = t.isIdentifier(node) ? node.name : ""; segments.push(base); segments.reverse(); const first = segments.findIndex((segment) => segment !== ""); diff --git a/src/domain/referenceSourceImportParsing.ts b/src/domain/referenceSourceImportParsing.ts index c6864ede92..ded8375331 100644 --- a/src/domain/referenceSourceImportParsing.ts +++ b/src/domain/referenceSourceImportParsing.ts @@ -3,7 +3,6 @@ import type { File, ImportExpression, Node, - StringLiteral, } from "@babel/types"; import { traverseJavaScriptAst } from "./javascript/javascriptSemanticTraversal.js"; import { readExactJavaScriptLiteral } from "./javascript/javascriptAstValues.js"; @@ -20,7 +19,6 @@ import { isCallExpression, isExportAllDeclaration, isExportNamedDeclaration, - isImport, isImportDeclaration, isImportExpression, isStringLiteral, @@ -96,31 +94,6 @@ const resolveSpecifier = ( return "external"; }; -const isModuleExpression = ( - expression: Node | null | undefined, -): expression is StringLiteral | CallExpression => - isStringLiteral(expression) || isCallExpression(expression); - -const moduleSpecifierFromExpression = ( - expression: Node | null | undefined, -): - | { specifier: string; parseState: ReferenceSourceImportParseState } - | undefined => { - const specifier = exactStringModuleName(expression); - if (specifier !== undefined) return { specifier, parseState: "parsed" }; - if ( - isCallExpression(expression) && - isImport(expression.callee) && - expression.arguments.length > 0 - ) { - const nestedSpecifier = exactStringModuleName(expression.arguments[0]); - return nestedSpecifier === undefined - ? { specifier: "", parseState: "partial" } - : { specifier: nestedSpecifier, parseState: "parsed" }; - } - return undefined; -}; - const appendRelationship = ( relationships: ReferenceSourceImportRelationship[], limitations: string[], @@ -276,14 +249,14 @@ const extractRequireAndDynamicImports = ( // admits quoted and expression-free template spellings alike. const requireCall = requireCalls.get(call); if (requireCall !== undefined) { - const result = moduleSpecifierFromExpression(requireCall.arguments?.[0]); - if (result !== undefined) { + const specifier = exactStringModuleName(requireCall.arguments?.[0]); + if (specifier !== undefined) { const uncertainResolution = requireCall.resolutionBase === "unknown"; appendRelationship(relationships, limitations, { fromPath: from_path, - to: result.specifier, + to: specifier, kind: "requires", - parseState: uncertainResolution ? "partial" : result.parseState, + parseState: uncertainResolution ? "partial" : "parsed", ...(uncertainResolution ? { resolution: "unknown" } : {}), ...(uncertainResolution ? {} @@ -295,20 +268,6 @@ const extractRequireAndDynamicImports = ( : {}), }); } - continue; - } - - const first = call.arguments[0]; - if (isImport(call.callee) && isModuleExpression(first)) { - const result = moduleSpecifierFromExpression(first); - if (result !== undefined) { - appendRelationship(relationships, limitations, { - fromPath: from_path, - to: result.specifier, - kind: "imports", - parseState: result.parseState, - }); - } } } }; diff --git a/src/domain/webModuleImports.ts b/src/domain/webModuleImports.ts index 0f98468715..c7cb8a639c 100644 --- a/src/domain/webModuleImports.ts +++ b/src/domain/webModuleImports.ts @@ -75,12 +75,6 @@ export const collectWebModuleImports = ( add("re-export", node.source); } else if (node.type === "ImportExpression") add("dynamic-import", node.source); - else if ( - node.type === "CallExpression" && - node.callee.type === "Import" && - node.arguments[0] !== undefined - ) - add("dynamic-import", node.arguments[0]); }, }); imports.sort((a, b) => a.start.offset - b.start.offset);