metaborg / nabl

Spoofax' Name Binding Language
Apache License 2.0
7 stars 12 forks source link

Show incoming edges in scope graph #87

Open MeAmAnUsername opened 2 years ago

MeAmAnUsername commented 2 years ago

Short description Add a section 'incoming edges' in the scope graph. Rename the section 'edges' to 'outgoing edges'

Problem description. Right now, it is easy to see the outgoing edges of a scope in the a .scopegraph file, but the incoming edges have to be derived by searching for that edge and scope, which is made particularly difficult due to the way Statix lays out multiple targets with the same edge.

Describe the solution you'd like Instead of just edges, show incoming edges and outgoing edges in .scopegraph:

  #.-s_func_instantiated_125-26 {
    relations {
      statics/base!generic_arg : (GenericParameter(#src/main/test.pie-s_func_60-17, "F"), ?.-arg_ty-230)
    }
    outgoing edges {
      statics/base!P : #src/main/test.pie-s_func_inner_16-5
                       #src/main/test.pie-s_func_60-17
    }
    incoming edges {
      statics/base!INHERIT : #src/main/test.pie-s_func_inner_14-23
    }
  }

Describe alternatives you've considered

  1. Some kind of menu action that can be used when on the scope. Sounds awful but would work.
  2. Show references by CTRL+clicking the scope declaration (requires #85). Has two problems: first, it shows every reference, not just incoming edges. More importantly, Eclipse uses menu actions to show references, not just CTRL+click on a declaration like IntelliJ.

Additional context This feature would work very well in combination with #85. The combination of these two would allow more or less effortless following edges back and forth between scopes.

Additional ideas for sections

Some of these might become big very quickly, so it is probably a good idea to make sections collapsible, with menu options like collapse all > {scopes, sections, relations > {all, own, references}, edges > {all, outgoing edges, incoming edges}, queries > {all, started, resolved, pathed}}

Example:

  #.-s_data_def_125-26 {
    relations {
      statics/base!generic_param : ("F", GenericParameter(#src/main/test.pie-s_data_def_125-26, "F"))
                                   ("T", GenericParameter(#src/main/test.pie-s_data_def_125-26, "T"))
    }
    references {
      statics/base!generic_arg : #src/main/test.pie-s_data_instance_16-5 : (GenericParameter(#src/main/test.pie-s_data_def_125-26, "F"), IntType())
                                                                           (GenericParameter(#src/main/test.pie-s_data_def_125-26, "T"), StrType())
                                 #src/main/test.pie-s_data_instance_24-9 : (GenericParameter(#src/main/test.pie-s_data_def_125-26, "F"), BoolType())
                                                                           (GenericParameter(#src/main/test.pie-s_data_def_125-26, "T"), DataType(#src/main/test.pie-s_data_instance_16-5))
    }
    outgoing edges {
      statics/base!P : #src/main/test.pie-s_func_inner_16-5
                       #src/main/test.pie-s_func_60-17
    }
    incoming edges {
      statics/base!INHERIT : #src/main/test.pie-s_data_instance_14-23
    }
    queries originating {
      query var { name' :- name' == "foo" } filter P min P in #.-s_data_def_125-26 |-> []
    }
    queries resolving {
      query data { name' :- name' == "Box" } filter P min P in #.-s_func_124-27 |-> [((<...too lazy to write out path...>), #.-s_data_def_125-26)]
    }
    queries traversing {
    }
  }
AZWN commented 2 years ago

I like the idea's expressed in this issue, but have some questions regarding feasibility.

As I won't have time to implement this issue myself, I'll add an good-first-issue label.