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

Sub/Function in Class - references missing between various Projects #6070

Open
hwnd-git opened this issue Jan 6, 2023 · 4 comments
Open
Labels
bug Identifies work items for known bugs resolver Issue is easier to resolve with knowledge of the internal resolver API and the Antlr4 parse trees.
Milestone

Comments

@hwnd-git
Copy link

hwnd-git commented Jan 6, 2023

Rubberduck version information
The info below can be copy-paste-completed from the first lines of Rubberduck's log or the About box:

Rubberduck version [2.5.2.5906]
Operating System: [Microsoft Windows NT 10.0.19044.0, x64]
Host Product: [Dassault Systemes Product x64] (Catia v5)
Host Version: [5.28.0.17255]
Host Executable: [CNEXT.EXE]

Description
Rubberduck -> Navigate -> Find all referencess... does not seem to work for Subs or Functions located inside a Class, when the Class resides in one Project but is being accessed/invoked in another Project linked through References.

To Reproduce
Steps to reproduce the behavior:

  1. Create simple structure:
    obraz
  • Project 'test1' contains Main_Module with main subroutine. It is referencing Project 'test2' via Tools -> References:
'Main_Module:
Sub CATMain()
    Debug.Print cls.testFunction("xxx")
    Call cls.TestSub
End Sub
  • Project 'test2' contains a private Class 'cCls' and a public instance of this class called 'cls' inside its Module 'Module_with_public_cls':
'cCls:
Public Function testFunction(iStr As String) As String
    testFunction = "testing function: '" & iStr & "'"
End Function

Public Sub TestSub()
    Debug.Print Me.testFunction("Testing SUB")
End Sub
'Module_with_public_cls:
Public cls As New cCls
  1. Click on 'Rubberduck -> Refresh'

  2. Go to class 'cCls' in project 'test2'

  3. Set cursor on 'testFunction'

  4. Click on 'Rubberduck -> Navigate -> Find all references...'

  5. Only two references will be found (contained inside project 'test2'. References to function calls in project 'test1' are missing.

  6. Go to module 'Main_Module'

  7. Set cursor on 'testFunction'

  8. 0 references found

  9. Click on 'Rubberduck -> Refactor -> Rename'. BUG: it wants to rename 'CATMain' instead on 'testFunction'

  10. Repeat steps 3,4.

  11. Click on 'Rubberduck -> Refactor -> Rename'; enter new name; click on OK

  12. Code execution fails as the 'testFunction' name is changed only in project 'test2', while 'CATMain' in project 'test1' still tries to call the function by its old name.

  13. Revert recent refactoring

  14. Repeat step 7.

  15. Set cursor on 'cls'

  16. Only two references found (from project 'test1')

  17. Click on 'Rubberduck -> Refactor -> Rename'; enter new name; click on OK

  18. This time refactoring went OK - 'cls' has been changed in both 'test1' and 'test2'; code executes properly

Expected behavior
I would expect Rubberduck finding the references to function calls within various projects, provided that these projects are linked by referencing each other. Especially when the Code Explorer is aware of this connection. Even the native VBA functionality 'Definition' accessible through right click context menu sends the mouse cursor to proper definition in other project.

Screenshots
None

Logfile
Log has not been created

Additional context
Nothing

@hwnd-git hwnd-git added the bug Identifies work items for known bugs label Jan 6, 2023
@retailcoder retailcoder added the resolver Issue is easier to resolve with knowledge of the internal resolver API and the Antlr4 parse trees. label Jan 6, 2023
@retailcoder
Copy link
Member

Thanks for the report! Probably a little oversight somewhere in the resolver causing too much filtering and excluding declarations in other projects that should be accessible.

@Vogel612
Copy link
Member

Vogel612 commented Jan 6, 2023

honestly to a certain extent I want to believe that that's by design. After all the number of declarations that needs to be searched is quite large enough already for find references even when not checking all open projects.

@retailcoder
Copy link
Member

Hm to me that's definitely a scenario (cross-project refs) that should be handled correctly. There's no reason we can get refs for MsgBox but not for exposed classes & their public members in a user-code referenced project.

@hwnd-git
Copy link
Author

hwnd-git commented Jan 6, 2023

@Vogel612 I have been wondering it that was intended behavior to maybe reduce the amount of computations needed to analyze all open projects that are referencing each other. But then, why the inconsistency during refactoring? Why can I refactor the name of the public object, and it is renamed in both projects, but can not refactor properly the names of its functions? This is what gave me an impression, that it might be a bug or kind of oversight.

@retailcoder retailcoder added this to the 2.x Cycle milestone Jan 31, 2025
@retailcoder retailcoder moved this to Backlog | Resolver in Board-v2.99 Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies work items for known bugs resolver Issue is easier to resolve with knowledge of the internal resolver API and the Antlr4 parse trees.
Projects
Status: Backlog | Resolver
Development

No branches or pull requests

3 participants