-
Notifications
You must be signed in to change notification settings - Fork 88
Renaming proposal for subtree searching extension functions #2391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Renaming proposal for subtree searching extension functions #2391
Conversation
…chain to differentiate them from normal functions on those graph objects
|
This breaks the API, so it will probably be part of CPG version 11. Also, the changes require updating the documentation. |
|
Before we do that I have another suggestion which we might do first. Currently, these extension functions work on all "nodes", which is extremely confusing since they should actually only work on AST Nodes. I would therefore suggest to add an abstract class Then we can make sure that things like When we have that, we should also see if certain properties such as DFG also only make sense on AST Nodes (and possibly overlay nodes), because currently its possible to add DFG / EOG to a |
|
.ast.functions.where {} could be solved with a form of graph traversal or lazy function. () with invokes would be a shorthand for evaluation. I will start with the api first and then implement the functionality. Other Ideas:
|
Renaming extension functions that search in the sub tree or ancestor chain to differentiate them from normal functions on those graph objects.
This PR renames extensions functions to more clearly differentiate them from several properties on nodes as there was a naming ambiguity. Sometimes, depending on the imports, it was unclear that all nodes of a certain type in the AST-Subtree were collected instead of simply accessing the direct ast children, e.g.
statements.This PR refactors
allChildrentoallDescendantsand all functions usingallChildrenand then accessing a fraction of the nodes in the subtree by filtering for the type or some condition. The extension gets the prefixalland the previous name is capitalized. An Example:statementsis nowallStatementsand therefore users will know that if they usestatementsthey access the children and if they useallStatementsthey will access all descendant statements. While users will not know of the existence ofallStatementsand the prefixallit should be discoverable through any IDE and then we clearly avoid the ambiguity.