ide: identifier completion: gather units in star dirs

This commit is contained in:
mattias 2023-08-03 18:07:38 +02:00
parent ec97acfd17
commit 74f240f5f3
5 changed files with 9 additions and 8 deletions

View File

@ -178,6 +178,7 @@ type
const FileCase: TCTSearchFileCase): string; virtual; abstract;
function FindIncludeFile(const IncFilename: string; AnyCase: boolean): string; virtual; abstract;
function FindUnitSource(const AUnitName: string; AnyCase: boolean): string; virtual; abstract;
procedure UpdateListing; virtual; abstract;
property Directory: string read FDirectory; // with trailing pathdelim
property Pool: TCTDirectoryCachePool read FPool;
end;
@ -232,7 +233,7 @@ type
function FindIncludeFileInCleanPath(IncFilename, SearchPath: string; AnyCase: boolean): string;
procedure IterateFPCUnitsInSet(const Iterate: TCTOnIterateFile);
procedure UpdateListing;
procedure UpdateListing; override;
procedure WriteListing;
procedure Invalidate; inline;
procedure GetFiles(var Files: TStrings; IncludeDirs: boolean = true); // relative to Directory
@ -286,7 +287,7 @@ type
function FindUnitSource(const AUnitName: string; AnyCase: boolean): string; override; // returns relative filename
function IndexOfFileCaseInsensitive(ShortFilename: PChar): integer; override; // ascii insensitive
function IndexOfFileCaseSensitive(ShortFilename: PChar): integer; override;
procedure UpdateListing;
procedure UpdateListing; override;
procedure WriteListing;
procedure Invalidate; inline;
public

View File

@ -1806,7 +1806,6 @@ procedure TIdentCompletionTool.GatherUnitnames(const NameSpacePath: string);
var
UnitPath, SrcPath: string;
BaseDir: String;
ANode: TAVLTreeNode;
UnitFileInfo: TUnitFileInfo;
NewItem: TUnitNameSpaceIdentifierListItem;
@ -1820,7 +1819,6 @@ begin
GatherUnitAndSrcPath(UnitPath,SrcPath);
CurSourceName:=GetSourceName;
//DebugLn('TIdentCompletionTool.GatherUnitnames CurSourceName="',CurSourceName,'" UnitPath="',UnitPath,'" SrcPath="',SrcPath,'"');
BaseDir:=ExtractFilePath(MainFilename);
FIDTTreeOfUnitFiles:=nil;
FIDTTreeOfNamespaces:=nil;
try
@ -1834,7 +1832,7 @@ begin
UnitExt:=PascalCompilerUnitExt[Scanner.PascalCompiler];
if Scanner.CompilerMode=cmMacPas then
UnitExt:=UnitExt+';p';
GatherUnitFiles(BaseDir,UnitPath,UnitExt,NameSpacePath,false,true,FIDTTreeOfUnitFiles, FIDTTreeOfNamespaces);
GatherUnitFiles(UnitPath,UnitExt,NameSpacePath,false,true,FIDTTreeOfUnitFiles, FIDTTreeOfNamespaces);
{$IFDEF VerboseICGatherUnitNames}
debugln(['TIdentCompletionTool.GatherUnitnames UnitPath ',FIDTTreeOfUnitFiles.Count]);
{$ENDIF}
@ -1842,7 +1840,7 @@ begin
SrcExt:=PascalCompilerSrcExt[Scanner.PascalCompiler];
if Scanner.CompilerMode=cmMacPas then
SrcExt:=SrcExt+';p';
GatherUnitFiles(BaseDir,SrcPath,SrcExt,NameSpacePath,false,true,FIDTTreeOfUnitFiles, FIDTTreeOfNamespaces);
GatherUnitFiles(SrcPath,SrcExt,NameSpacePath,false,true,FIDTTreeOfUnitFiles, FIDTTreeOfNamespaces);
{$IFDEF VerboseICGatherUnitNames}
debugln(['TIdentCompletionTool.GatherUnitnames Plus SrcPath ',FIDTTreeOfUnitFiles.Count]);
{$ENDIF}

View File

@ -124,8 +124,8 @@ begin
CurPath := GetNextDirectoryInSearchPath(ExpandedPath, p);
EndPos:=p+length(CurPath);
case ExtractFilename(CurPath) of
'*','**': CurPath:=ExtractFilePath(CurPath); // star directories
case ExtractFilename(ChompPathDelim(CurPath)) of
'*','**': CurPath:=ExtractFilePath(CHompPathDelim(CurPath)); // star directories
end;
// check special chars in path

View File

@ -763,6 +763,7 @@ begin
if Dir='' then break;
Cache:=CodeToolBoss.DirectoryCachePool.GetBaseCache(Dir);
if Cache=nil then continue;
Cache.UpdateListing;
if Cache is TCTStarDirectoryCache then
begin
StarCache:=TCTStarDirectoryCache(Cache);

View File

@ -233,6 +233,7 @@ begin
if TTransferMacroList.StrHasMacros(APath) then
Exit(TObject(1));
Result:=TObject(0);
APath:=ChompPathDelim(APath);
if (FEffectiveBaseDirectory<>'') and FilenameIsAbsolute(FEffectiveBaseDirectory) then
APath:=CreateAbsolutePath(APath, FEffectiveBaseDirectory);