aibolit icon indicating copy to clipboard operation
aibolit copied to clipboard

Copmuted field 'statements_by_scope'

Open aravij opened this issue 3 years ago • 2 comments

To provide seamless functionality with JavalangImproved we need to be able to provide all method statements grouped by scope.

aravij avatar Jul 25 '20 09:07 aravij

At this point it is quite hard to create such functionality as computed field, because some scopes (like lambdas) may be inside expressions. To be able to search inside expression, we need on of this:

  • decompose expression to atoms (literals, variables and lambdas)
  • use DFS

First option is seamed to me right, but quite expensive. Second cannot be done without retrieving AST, which, unfortunately, not possible with computed fields, as they only based on ASTNode.

Assuming this, I decided to create a ScopesGraph as a separate class, which is built by accepting method ast. So it is now can use all AST functionality and find lambdas (and anonymous classes) with help of DFS.

aravij avatar Aug 05 '20 08:08 aravij

Currently scope graph does not provide all the needed information. To correct it the concept of the graph have to be changed. Now graph vertexes should either represent scope or statement. Graph becomes bipartite. Edges go from scope to statement is that statement is contained in that scope. Edges from statement goes to scope if it is created by that statement.

aravij avatar Aug 17 '20 08:08 aravij