Skip to content

fix(native): add prototype method extraction to Rust engine (parity with WASM #1317) #1327

@carlos-alm

Description

@carlos-alm

Context

PR implementing issue #1317 added prototype-based method extraction to the WASM JS extractor:

  • Foo.prototype.bar = function(){} → emits Foo.bar as a method definition
  • Foo.prototype.bar = identifier → seeds typeMap['Foo.bar'] = { type: identifier }
  • Foo.prototype = { bar: fn } → emits method definitions per property

The call resolver was also extended with:

  • Prototype alias lookup: after symbol-DB miss for TypeName.methodName, checks typeMap['TypeName.methodName']
  • Inline new Foo() receiver extraction: regex ^\(?\s*new\s+([A-Z_$]...) extracts the class name when receiver is (new Foo) or (new Foo())

What's missing in native

The Rust extractor (crates/codegraph-core/) does not implement any of the above. Until it does, WASM and native will produce different results for files containing prototype-based OOP patterns.

What needs to be done

  1. In the native Rust extractor, detect the three prototype assignment patterns and:
    • Emit method definitions for function expressions
    • Emit typeMap entries for identifier aliases
  2. In the native call resolver (or its WASM post-processing path), add the prototype alias lookup and inline new-expression receiver handling that were added to call-resolver.ts

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions