ide: find used unit: search in virtual units

This commit is contained in:
mattias 2025-03-16 15:18:58 +01:00
parent b09fddb930
commit d927aa92cb
2 changed files with 9 additions and 4 deletions

View File

@ -3070,6 +3070,10 @@ var
Result:=false;
if FilenameIsAbsolute(TargetFilename) then exit;
Result:=DoOnFindUsedUnit(CurFilename,TargetUnitName,'')<>nil;
{$IFDEF VerboseFindSourceNameReferences}
if Result then
debugln(['TCodeToolManager.FindSourceNameReferences File ',Filename,', virtual target in unit path']);
{$ENDIF}
end;
begin

View File

@ -10082,6 +10082,7 @@ function TMainIDE.CodeToolBossSearchUsedUnit(const SrcFilename: string;
const TheUnitName, TheUnitInFilename: string): TCodeBuffer;
var
AnUnitInfo: TUnitInfo;
aFilename: String;
begin
Result:=nil;
// check if SrcFilename is project file
@ -10090,11 +10091,11 @@ begin
AnUnitInfo:=Project1.ProjectUnitWithFilename(SrcFilename);
if AnUnitInfo=nil then exit;
// SrcFilename is a project file
// -> search virtual project files
AnUnitInfo:=Project1.ProjectUnitWithUnitname(TheUnitName);
if AnUnitInfo=nil then exit;
// -> search in virtual files
aFilename:=CodeToolBoss.DirectoryCachePool.FindVirtualUnit(TheUnitName);
if aFilename='' then exit;
// virtual unit found
Result:=AnUnitInfo.Source;
Result:=CodeToolBoss.LoadFile(aFilename,false,false);
end;
procedure TMainIDE.CodeToolBossGetVirtualDirectoryAlias(Sender: TObject;