Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

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 moved this from Backlog to In Progress in Library Analysis Apr 6, 2023
@lukarade lukarade linked a pull request May 24, 2023 that will close this issue
@github-project-automation github-project-automation bot moved this from In Progress to ✔️ Done in Library Analysis Jun 22, 2023
@lukarade
Copy link
Contributor

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

@lukarade lukarade reopened this Jun 22, 2023
@github-project-automation github-project-automation bot moved this from ✔️ Done to Backlog in Library Analysis Jun 22, 2023
@lukarade lukarade moved this from Backlog to In Progress in Library Analysis 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 <129584137+megalinter-bot@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from In Progress to ✔️ Done in Library Analysis Oct 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement 💡 New feature or request purity Inferring the purity of functions
Projects
Status: ✔️ Done
2 participants