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

Add qualifying references to identifier references #5744

Merged
merged 4 commits into from
May 7, 2021

Conversation

MDoerner
Copy link
Contributor

There are multiple pieces in the codebase that need information about the qualifying reference/declaration of a reference, e.g. to determine whether the reference is a member access on the return value of a specific member. Currently, checking this is achieved by navigating the parse tree each time, also taking into account with blocks. This PR moves the qualifier resolution to the BoundExpressionVisitor, which already has all the information present to easily determine the qualifying reference.

The following qualifier structure has been implemented:

  • Member accesses are qualified by the reference for their lExpression.
  • Member accesses return their own reference as the one qualifying a potential access.
  • For (recursive) default member accesses the innermost access is qualified by the reference of the lExpression and each other access is qualified by the immediately contained one.
  • For (recursive) default member accesses the outermost access is returned as potentially qualifying.
  • Array accessed are qualified by the reference of their lExpression (potentially with default member accesses in between), i.e. by the reference of the array variable or array returning member.
  • Array accesses return themselves as potentially qualifying. (To get the array, one has to go up the chain again.)
  • Index accesses other than array and default member accesses are qualified by the reference of their lExpression.
  • Index accesses other than array and default member accesses return the reference of their lExpression as potentially qualifying.
  • Dictionary access expressions work like default member access expressions.
  • Other expressions neither take nor return a reference as (potentially) qualifying.

This PR is still WIP; it needs a lot more tests. Moreover, the places currently doing the work manually should be ported to use the qualifying reference, if possible.

There are multiple pieces in the codebase that need information about the qualifying reference/declaration of a reference, e.g. to determine whether the reference is a member access on the return value of a specific member. Currently, checking this is achieved by navigating the parse tree each time, also taking into account with blocks. This commit moves the qualifier resolution to the BoundExpressionVisitor, which already has all the information present to easily determine the qualifying reference.

The following qualifier structure has been implemented:

- Member accesses are qualified by the reference for their lExpression.
- Member accesses return their own reference as the one qualifying a potential access.
- For (recursive) default member accesses the innermost access is qualified by the reference of the lExpression and each other access is qualified by the immediately contained one.
- For (recursive) default member accesses the outermost access is returned as potentially qualifying.
- Array accessed are qualified by the reference of their lExpression (potentially with default member accesses in between), i.e. by the reference of the array variable or array returning member.
- Array accesses return themselves as potentially qualifying. (To get the array, one has to go up the chain again.)
- Index accesses other than array and default member accesses are qualified by the reference of their lExpression.
- Index accesses other than array and default member accesses return the reference of their lExpression as potentially qualifying.
- Dictionary access expressions work like default member access expressions.
- Other expressions neither take nor return a reference as (potentially) qualifying.
@MDoerner MDoerner added the PR-Status: WIP Pull request is work-in-progress, more commits should be expected. label Apr 23, 2021
…rences

Also deals with caching issues in these inspections and extends the ImplicitActiveWorkbookInspection to all Application member calls in the Excel OM.
Previously only the members on Worksheet and Workbook were covered.
# Conflicts:
#	Rubberduck.CodeAnalysis/Inspections/Concrete/ImplicitActiveSheetReferenceInspection.cs
@MDoerner MDoerner removed the PR-Status: WIP Pull request is work-in-progress, more commits should be expected. label Apr 25, 2021
@retailcoder retailcoder merged commit 2026e69 into rubberduck-vba:next May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants