andytill/erlyberly

Show argument names in function traces

Open

#162 opened on Feb 1, 2018

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Java (686 stars) (43 forks)batch import
enhancementerlanghelp wantedjava

Description

Erlyberly could show the names of function arguments above the values for function arguments in the term tree. Below is a screenshot of annotated records, it might look similar to this.

image

Module AST is already parsed for record metadata. Finding function argument names would be an expansion of that.

https://github.com/andytill/erlyberly/blob/master/src/main/resources/erlyberly/beam/erlyberly.erl#L172

For example, given the function in lists.

-spec sublist(List1, Start, Len) -> List2 when
      List1 :: [T],
      List2 :: [T],
      Start :: pos_integer(),
      Len :: non_neg_integer(),
      T :: term().

sublist(List, S, L) when is_integer(L), L >= 0 ->

The function may return something like.

{lists, [{sublist,["List","S","L"],...}]}

The dialyzer spec can be used but it may not exist. Functions can have multiple clauses. A binding name should be accepted over _ or a literal e.g. Index is more useful than 0 both of which may be present in different function clauses. There are many variations in function clauses, the AST parser should attempt to return something useful but could return a blank if the argument was too complex or long.

If anyone wants to attempt this, post a comment. I can help with the UI for anyone that doesn't want to code java! :D

Contributor guide