Skip to content

DSL: Go-to-definition broken for environment field access #3

@jonaprieto

Description

@jonaprieto

Go-to-definition broken with new DSL

Problem

With the new DSL implementation, IDE go-to-definition functionality is broken for environment field access. When clicking go-to-definition on env.stats.reads, it navigates to the macro internal definition instead of the actual field definition location in the environment block.

Current Behavior

# Clicking go-to-definition on env.stats.reads here:
on_message :get_stats do
  [
    {:reply, {:stats, env.stats.reads, env.stats.writes, env.stats.deletes}}
  ]
end

Takes you to macro internals instead of:

env do
  field :store, default: %{}, type: :map
  field :stats, default: %{reads: 0, writes: 0, deletes: 0}, type: :map
  field :access_counts, default: %{}, type: :map
end

Expected Behavior

Go-to-definition should navigate to the field definition location in the environment block where the field is declared.

Proposed Solution

Implement a Field Registry Approach using module attributes:

Key Benefits:

  • Improved go-to-definition - better than current macros
  • Lighter weight - no full struct generation overhead
  • Source tracking - maintains field location metadata

Implementation Details:

  • Create FieldRegistry.ex to track field locations and provide better macro hygiene
  • Store field metadata at compile-time
  • Generate helper macros that point to actual field definition locations
  • Provide better IDE support without full TypedStruct generation overhead

This approach would maintain field location metadata and generate helper macros that preserve source location information for proper IDE navigation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureArchitectural changes and improvementsbugSomething isn't workingdslDomain Specific Language features

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions