Skip to content
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

Function to resolve references #90

Closed
lars-reimann opened this issue Apr 6, 2023 · 1 comment · Fixed by #120 or #153
Closed

Function to resolve references #90

lars-reimann opened this issue Apr 6, 2023 · 1 comment · Fixed by #120 or #153
Assignees
Labels
enhancement 💡 New feature or request purity Inferring the purity of functions

Comments

@lars-reimann
Copy link
Member

Is your feature request related to a problem?

As a basis for the data flow analysis we need to know the declaration(s) that a reference can point to.

Desired solution

A function resolve_reference that takes an astroid.Name node (or another node that represents a reference) and returns a list of the possible

  • parameters
  • local variables
  • global variables
  • class attributes
  • instance attributes

that the reference can point to.

If we cannot list all candidates, this should be clearly indicated. Since this function is the basis for any further analysis, it should be well tested.

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

No response

@lars-reimann lars-reimann added enhancement 💡 New feature or request purity Inferring the purity of functions labels Apr 6, 2023
@lukarade lukarade linked a pull request May 24, 2023 that will close this issue
@lukarade
Copy link
Contributor

This issue is still in progress, so it should not be closed yet.

@lukarade lukarade reopened this Jun 22, 2023
@lukarade lukarade linked a pull request Aug 15, 2023 that will close this issue
lars-reimann pushed a commit that referenced this issue Oct 2, 2023
Closes #90 

### Summary of Changes

This feature contains many additions to the collection of data when
parsing python code (former scope detection).
We now collect: the scope, the classes, the functions, all global
variables, all value and target nodes, the parameters as well as all
function calls when traversing the AST.
During this traversal, we also determine the symbols for all name nodes.
We distinguish between `GlobalVariables, LocalVariables, ClassVariables,
InstanceVariables, Parameters` and `Builtins`.

Furthermore, this feature resolves the references for all name nodes
(target and value nodes).
For each name node we determine its scope, as mentioned above, and a
list of all referenced symbols and return a `ReferenceNode`.
<!-- Please provide a summary of changes in this pull request, ensuring
all changes are explained. -->

---------

Co-authored-by: megalinter-bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 💡 New feature or request purity Inferring the purity of functions
Projects
Status: ✔️ Done
2 participants