mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 04:27:55 +02:00
ide: comment, codetools: FindSourceNameReferences: search virtual files
This commit is contained in:
parent
435a011e8a
commit
b09fddb930
@ -167,6 +167,8 @@ type
|
||||
procedure DoOnGlobalValuesChanged;
|
||||
function DoOnFindUsedUnit(SrcTool: TFindDeclarationTool; const TheUnitName,
|
||||
TheUnitInFilename: string): TCodeBuffer;
|
||||
function DoOnFindUsedUnit(const SrcFilename, TheUnitName,
|
||||
TheUnitInFilename: string): TCodeBuffer;
|
||||
function DoOnGetSrcPathForCompiledUnit(Sender: TObject;
|
||||
const AFilename: string): string;
|
||||
function DoOnInternalGetMethodName(const AMethod: TMethod;
|
||||
@ -3054,7 +3056,7 @@ function TCodeToolManager.FindSourceNameReferences(TargetFilename: string; Files
|
||||
SkipComments: boolean; out ListOfSrcNameRefs: TObjectList; WithDuplicates: boolean): boolean;
|
||||
var
|
||||
i, j, InFilenameCleanPos: Integer;
|
||||
Filename, Dir, TargetUnitName, InFilename, LocalSrcName: String;
|
||||
Filename, Dir, TargetUnitName, InFilename, LocalSrcName, CurUnitName: String;
|
||||
Code: TCodeBuffer;
|
||||
Tools, DirCachesSearch, DirCachesSkip: TFPList;
|
||||
DirCache: TCTDirectoryCache;
|
||||
@ -3062,11 +3064,20 @@ var
|
||||
Refs: TSrcNameRefs;
|
||||
Node, NextNode: TAVLTreeNode;
|
||||
CodeXYPos: PCodeXYPosition;
|
||||
|
||||
function CanFindFile(const CurFilename: string): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
if FilenameIsAbsolute(TargetFilename) then exit;
|
||||
Result:=DoOnFindUsedUnit(CurFilename,TargetUnitName,'')<>nil;
|
||||
end;
|
||||
|
||||
begin
|
||||
{$IFDEF VerboseFindSourceNameReferences}
|
||||
debugln(['TCodeToolManager.FindSourceNameReferences TargetFile="',TargetFilename,'" FileCount=',Files.Count,' SkipComments=',SkipComments]);
|
||||
{$ENDIF}
|
||||
Result:=false;
|
||||
TargetUnitName:=ExtractFileNameOnly(TargetFilename);
|
||||
ListOfSrcNameRefs:=nil;
|
||||
Tools:=TFPList.Create;
|
||||
DirCachesSearch:=TFPList.Create;
|
||||
@ -3089,17 +3100,21 @@ begin
|
||||
// check if directory has target in unitpath
|
||||
Dir:=ExtractFilePath(Filename);
|
||||
DirCache:=DirectoryCachePool.GetCache(Dir,true,false);
|
||||
if DirCachesSkip.IndexOf(DirCache)>=0 then continue;
|
||||
if DirCachesSearch.IndexOf(DirCache)<0 then begin
|
||||
TargetUnitName:=ExtractFileNameOnly(TargetFilename);
|
||||
if DirCachesSkip.IndexOf(DirCache)>=0 then begin
|
||||
// this directory does not have target in unit path
|
||||
// check custom search
|
||||
if not CanFindFile(Filename) then
|
||||
continue;
|
||||
end else if DirCachesSearch.IndexOf(DirCache)<0 then begin
|
||||
CurUnitName:=TargetUnitName;
|
||||
InFilename:='';
|
||||
if DirCache.FindUnitSourceInCompletePath(TargetUnitName,InFilename,true)<>'' then
|
||||
if DirCache.FindUnitSourceInCompletePath(CurUnitName,InFilename,true)<>'' then
|
||||
begin
|
||||
{$IFDEF VerboseFindSourceNameReferences}
|
||||
debugln(['TCodeToolManager.FindSourceNameReferences File ',Filename,', target in unit path']);
|
||||
{$ENDIF}
|
||||
DirCachesSearch.Add(DirCache);
|
||||
end else begin
|
||||
end else if not CanFindFile(Filename) then begin
|
||||
{$IFDEF VerboseFindSourceNameReferences}
|
||||
debugln(['TCodeToolManager.FindSourceNameReferences File ',Filename,', target NOT in unit path, SKIP']);
|
||||
{$ENDIF}
|
||||
@ -6399,8 +6414,16 @@ function TCodeToolManager.DoOnFindUsedUnit(SrcTool: TFindDeclarationTool;
|
||||
const TheUnitName, TheUnitInFilename: string): TCodeBuffer;
|
||||
begin
|
||||
if Assigned(OnSearchUsedUnit) then
|
||||
Result:=OnSearchUsedUnit(SrcTool.MainFilename,
|
||||
TheUnitName,TheUnitInFilename)
|
||||
Result:=OnSearchUsedUnit(SrcTool.MainFilename,TheUnitName,TheUnitInFilename)
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TCodeToolManager.DoOnFindUsedUnit(const SrcFilename, TheUnitName, TheUnitInFilename: string
|
||||
): TCodeBuffer;
|
||||
begin
|
||||
if Assigned(OnSearchUsedUnit) then
|
||||
Result:=OnSearchUsedUnit(SrcFilename,TheUnitName,TheUnitInFilename)
|
||||
else
|
||||
Result:=nil;
|
||||
end;
|
||||
|
@ -6648,7 +6648,7 @@ end;
|
||||
procedure TProjectDefineTemplates.UpdateMain;
|
||||
begin
|
||||
if (Owner as TProject).Destroying then exit;
|
||||
// update the package block define template (the container for all other
|
||||
// update the block define template (the container for all other
|
||||
// define templates of the project)
|
||||
if FMain=nil then begin
|
||||
// create the main project template
|
||||
@ -6768,7 +6768,7 @@ var
|
||||
SrcDirDefTempl: TDefineTemplate;
|
||||
IDHasChanged: Boolean;
|
||||
SrcDirMarkDefTempl: TDefineTemplate;
|
||||
CurUnitPath: String;
|
||||
CurUnitPath, SrcDir: String;
|
||||
begin
|
||||
//DebugLn('TProjectDefineTemplates.UpdateDefinesForSourceDirectories ',Owner.IDAsString,' Active=',dbgs(Active),' TimeStamp=',dbgs(fLastSourceDirStamp),' Project.TimeStamp=',dbgs(Project.SourceDirectories.TimeStamp));
|
||||
if (not Owner.NeedsDefineTemplates) or (not Active) then exit;
|
||||
@ -6822,10 +6822,12 @@ begin
|
||||
UpdateSrcDirIfDef;
|
||||
for i:=0 to fLastSourceDirectories.Count-1 do begin
|
||||
// create directory template
|
||||
SrcDir:=fLastSourceDirectories[i];
|
||||
SrcDirDefTempl:=TDefineTemplate.Create('Source Directory '+IntToStr(i+1),
|
||||
fLastSourceDirectories[i],'',fLastSourceDirectories[i],da_Directory);
|
||||
DisableDefaultsInDirectories(SrcDirDefTempl,false);
|
||||
SrcDir,'',fLastSourceDirectories[i],da_Directory);
|
||||
fLastSourceDirectories.Objects[i]:=SrcDirDefTempl;
|
||||
// add disable defaults
|
||||
DisableDefaultsInDirectories(SrcDirDefTempl,false);
|
||||
// add proj source directory marker
|
||||
SrcDirMarkDefTempl:=TDefineTemplate.Create('ProjectSrcDirMark',
|
||||
lisProjProjectSourceDirectoryMark, '#ProjectSrcMark'+Owner.IDAsWord,
|
||||
|
@ -1758,6 +1758,7 @@ end;
|
||||
function TProjectUnitFileSelector.InitialSelection(aFilename: string): Boolean;
|
||||
begin
|
||||
Result:=False;
|
||||
if aFilename='' then ;
|
||||
end;
|
||||
|
||||
function TProjectUnitFileSelector.Select: TModalResult;
|
||||
@ -5827,7 +5828,7 @@ begin
|
||||
// check new resource file
|
||||
NewLFMFilename:='';
|
||||
if FilenameHasPascalExt(NewFilename) then
|
||||
NewLFMFilename:=ChangeFileExt(NewFilename,'.lfm');
|
||||
NewLFMFilename:=ChangeFileExt(NewFilename,'.lfm');
|
||||
if AnUnitInfo.ComponentName='' then begin
|
||||
// unit has no component
|
||||
// -> remove lfm file, so that it will not be auto loaded on next open
|
||||
|
Loading…
Reference in New Issue
Block a user