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

View File

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

View File

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

View File

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

View File

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