Skip to content

No language emits an edge that points at a member, so "what writes this field" has no graph answer #3012

Open

Description

@durmazoguzhan

Splitting this out of #3006, which I filed with two separate problems bundled into it. #3006 is the declaration gap and has a patch. This is the part that is genuinely undecided.

Nothing in the tree emits an edge that points at a member. Every language stops at the container, which I checked by running them rather than reading the configs:

Java   Status.ACTIVE    ->  .isOn() references Status    (the enum, not the constant)
C++    w.width          ->  area()  references Widget    (the class, not the field)
PHP    Foo::$prop       ->  uses_static_prop -> Foo      (the class)
PHP    Foo::BAR         ->  references_constant -> Foo   (the class)
SQL    a view's SELECT  ->  reads_from -> table          (the table, not the column)

Member nodes themselves do exist: C++ data members and Swift computed properties, Swift enum cases and Java enum constants on case_of, JS/TS callable class fields on method. They are all leaves. Nothing arrives.

So "which code writes this member" has no graph answer in any language, and the question comes up constantly on a data-heavy codebase. A column, a setting, a status field: knowing where it is declared is the easy half.

What it would look like for C#

.UpdateVariantsIsShowCategory()  --writes-->  Variant.IsShowCategory
.SortCategoryVariants()          --reads-->   Variant.IsShowCategory

The machinery is mostly there. _csharp_method_receiver_types and _csharp_scoped_receiver_type already type a receiver at a byte offset, which is how _resolve_csharp_member_calls binds _server.Save() to Server.Save() (#1609). A member access that is not the function of an invocation is that shape minus the call, and the write case is an assignment_expression with the access on the left. It would need the same two tiers as member calls: same-file in the extractor, then a resolver for cross-file with the single-candidate guard.

What I would want decided before building it

  1. reads and writes, or one relation with a context. PHP's single uses_static_prop suggests one relation is the house style. A write is the half that answers the question, though, so folding them together loses most of the value.
  2. Which members get nodes. C#: properties are not nodes, so nothing in the graph can point at a member #3006 emits a node per property, which is +48% nodes on a DTO-heavy corpus, all leaves. The alternative is to mint a member node only when something touches it, which reverses the order: this issue lands first and C#: properties are not nodes, so nothing in the graph can point at a member #3006 becomes a follow-up rather than a prerequisite. That is a real option and I do not have a strong view.
  3. C# only, or the member layers that already exist. C++ and Swift have the nodes already and would only need the access pass. Doing it once in a way that fits both is more work up front and less to undo later.

Happy to build whichever shape you land on. I have the C# side mapped, and #3006 is the declaration half if that is the order you want.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions