Menu

#196 Fix Code Completion Self-Reference Issue with Dotted Unit Filenames in Delphi 7

open
nobody
5
2025-08-01
2025-08-01
bzimage
No

Dear GExperts Author,

I hope this message finds you well. I am a long-time user of Delphi 7 and have been experimenting with organizing larger projects using dotted unit filenames (e.g., Demo.MainForm.pas), mimicking the namespace-style structure available in newer Delphi versions. This approach initially worked well for structuring my codebase, but I’ve encountered a persistent code completion bug that disrupts workflow.

Issue Description:
When using a dotted filename for a form unit (e.g., Demo.MainForm.pas), Delphi 7’s code completion incorrectly adds a self-referential uses clause for the unit itself. This happens when autocompleting identifiers defined within the same unit, which is redundant and invalid.

Reproduction Steps:

1.Create a new VCL Form in Delphi 7.
2.Save the form unit with a dotted filename, e.g., Demo.MainForm.pas (ensure the unit name matches the filename root, as Delphi 7 defaults to this).
3.Add a Label to the form and set its Name property to InfoLabel.
4.Double-click the form to generate the OnCreate event handler (e.g., FormCreate).
5.In the FormCreate method, type InfoL and press Ctrl+Space to trigger code completion.
6.Select InfoLabel from the code completion list and press Enter to autocomplete.

Observed Behavior:
The identifier InfoL correctly autocompletes to InfoLabel, but Delphi 7 erroneously adds uses Demo.MainForm; in the implementation section of the same unit. This creates a self-referential dependency, which is unnecessary and can cause compilation warnings/errors.

Expected Behavior:
Code completion should autocomplete InfoL to InfoLabel without adding a uses clause for the unit itself, as the identifier is defined locally.

Request:
Given that GExperts has a strong history of enhancing Delphi’s functionality (especially for older versions like Delphi 7), I wonder if your team could address this issue. A fix would allow safer use of dotted filenames for project organization, making Delphi 7 more viable for larger codebases.

Alternatively, if a full fix is complex, any guidance or workaround suggestions would be greatly appreciated.

Thank you for your continued work on improving the Delphi ecosystem—GExperts has been an invaluable tool for many developers.

Best regards,

Discussion


Log in to post a comment.

MongoDB Logo MongoDB