The parser thread behind the Identifiers tab of the Uses Clause Manager (TUnitExportParserThread in GX_UnitExportsParser.pas) takes the project's own units first, then the first .pas file of each unit name in the order of the folders Ota.GetAllPossiblePaths returns. Only for a unit of which no .pas file is found in any of these folders does it look in the browsing path, and only if a .dcu file of that name is in one of these folders (bug [#552]).
Besides the project folder, the project's search path and the library path, GetAllPossiblePaths returns further folders that the compiler does not search: those of the project group and of the file in the editor, the subfolders of the IDE's source folder and the search path favourites. A .pas file in any of these folders is taken even if the compiler finds a .dcu file of that unit in its search path, in which case the Identifiers tab should use that unit's source from the browsing path.
Example: the library path contains C:\Lib\dcu with Foo.dcu, the browsing path contains C:\Lib\src with Foo.pas, and an older copy of Foo.pas is in the folder of the project group. The compiler uses Foo.dcu, but the Identifiers tab and Declare Variable use the older copy of Foo.pas.
Fixing this needs the thread to know which of the folders the compiler searches, and to look for .pas and .dcu files folder by folder in those, before it uses any of the other folders.
Found in a code review of the fix for bug [#554]. The consequences come from reading the code; they have not been reproduced in the IDE.
The proposed fix in the description is wrong: the compiler does not compare
.pasand.dcufiles folder by folder.Measured with dcc32 of Delphi 13 and Delphi 7:
Foo.dcuin one folder of the search path,Foo.paswith different content in another. In all cases the compiler compiledFoo.pas, whichever of the two folders came first, and whether the.pasfile was newer, older or had exactly the timestamp of the source the.dcuwas built from. It wrote the newFoo.dcuover the old one. WithoutFoo.pasin the search path, it usedFoo.dcu.So a
.pasfile anywhere in the compiler's folders (project folder, project search path, library path) wins over a.dcufile, and the thread already handles these folders correctly. The bug is only that the further folders fromOta.GetAllPossiblePaths(those of the project's units and of the file in the editor, the project group folder, the subfolders of the IDE's source folder, the search path favourites) are treated the same way as the compiler's folders.Corrected fix: the thread gets the compiler's folders and the further folders separately and takes, in this order:
.pasfile in the compiler's folders.dcufile: its source from the browsing path.pasfile in the further folders, for units not found so far