mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:39:23 +02:00
codetools: started unitsets
git-svn-id: trunk@26656 -
This commit is contained in:
parent
1004c7bb6c
commit
7728cf1e4e
@ -156,6 +156,8 @@ type
|
|||||||
function DirectoryCachePoolGetString(const ADirectory: string;
|
function DirectoryCachePoolGetString(const ADirectory: string;
|
||||||
const AStringType: TCTDirCacheString): string;
|
const AStringType: TCTDirCacheString): string;
|
||||||
function DirectoryCachePoolFindVirtualFile(const Filename: string): string;
|
function DirectoryCachePoolFindVirtualFile(const Filename: string): string;
|
||||||
|
function DirectoryCachePoolGetUnitFromSet(const UnitSet, AnUnitName: string
|
||||||
|
): string;
|
||||||
public
|
public
|
||||||
DefinePool: TDefinePool; // definition templates (rules)
|
DefinePool: TDefinePool; // definition templates (rules)
|
||||||
DefineTree: TDefineTree; // cache for defines (e.g. initial compiler values)
|
DefineTree: TDefineTree; // cache for defines (e.g. initial compiler values)
|
||||||
@ -163,6 +165,7 @@ type
|
|||||||
SourceChangeCache: TSourceChangeCache; // cache for write accesses
|
SourceChangeCache: TSourceChangeCache; // cache for write accesses
|
||||||
GlobalValues: TExpressionEvaluator;
|
GlobalValues: TExpressionEvaluator;
|
||||||
DirectoryCachePool: TCTDirectoryCachePool;
|
DirectoryCachePool: TCTDirectoryCachePool;
|
||||||
|
FPCDefinesCache: TFPCDefinesCache;
|
||||||
IdentifierList: TIdentifierList;
|
IdentifierList: TIdentifierList;
|
||||||
IdentifierHistory: TIdentifierHistoryList;
|
IdentifierHistory: TIdentifierHistoryList;
|
||||||
Positions: TCodeXYPositions;
|
Positions: TCodeXYPositions;
|
||||||
@ -292,6 +295,9 @@ type
|
|||||||
function FindUnitInUnitLinks(const Directory, AUnitName: string): string;
|
function FindUnitInUnitLinks(const Directory, AUnitName: string): string;
|
||||||
function GetUnitLinksForDirectory(const Directory: string;
|
function GetUnitLinksForDirectory(const Directory: string;
|
||||||
UseCache: boolean = false): string;
|
UseCache: boolean = false): string;
|
||||||
|
function FindUnitInUnitSet(const Directory, AUnitName: string): string;
|
||||||
|
function GetUnitSetForDirectory(const Directory: string;
|
||||||
|
UseCache: boolean = false): string;
|
||||||
function GetFPCUnitPathForDirectory(const Directory: string;
|
function GetFPCUnitPathForDirectory(const Directory: string;
|
||||||
UseCache: boolean = false): string;// unit paths reported by FPC
|
UseCache: boolean = false): string;// unit paths reported by FPC
|
||||||
procedure GetFPCVersionForDirectory(const Directory: string;
|
procedure GetFPCVersionForDirectory(const Directory: string;
|
||||||
@ -828,7 +834,9 @@ begin
|
|||||||
DirectoryCachePool:=TCTDirectoryCachePool.Create;
|
DirectoryCachePool:=TCTDirectoryCachePool.Create;
|
||||||
DirectoryCachePool.OnGetString:=@DirectoryCachePoolGetString;
|
DirectoryCachePool.OnGetString:=@DirectoryCachePoolGetString;
|
||||||
DirectoryCachePool.OnFindVirtualFile:=@DirectoryCachePoolFindVirtualFile;
|
DirectoryCachePool.OnFindVirtualFile:=@DirectoryCachePoolFindVirtualFile;
|
||||||
|
DirectoryCachePool.OnGetUnitFromSet:=@DirectoryCachePoolGetUnitFromSet;
|
||||||
DefineTree.DirectoryCachePool:=DirectoryCachePool;
|
DefineTree.DirectoryCachePool:=DirectoryCachePool;
|
||||||
|
FPCDefinesCache:=TFPCDefinesCache.Create(nil);
|
||||||
FAddInheritedCodeToOverrideMethod:=true;
|
FAddInheritedCodeToOverrideMethod:=true;
|
||||||
FAdjustTopLineDueToComment:=true;
|
FAdjustTopLineDueToComment:=true;
|
||||||
FCatchExceptions:=true;
|
FCatchExceptions:=true;
|
||||||
@ -882,6 +890,7 @@ begin
|
|||||||
DefaultConfigCodeCache:=nil;
|
DefaultConfigCodeCache:=nil;
|
||||||
FreeAndNil(SourceCache);
|
FreeAndNil(SourceCache);
|
||||||
FreeAndNil(DirectoryCachePool);
|
FreeAndNil(DirectoryCachePool);
|
||||||
|
FreeAndNil(FPCDefinesCache);
|
||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
DebugLn('[TCodeToolManager.Destroy] F');
|
DebugLn('[TCodeToolManager.Destroy] F');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1433,6 +1442,27 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCodeToolManager.FindUnitInUnitSet(const Directory, AUnitName: string
|
||||||
|
): string;
|
||||||
|
begin
|
||||||
|
Result:=DirectoryCachePool.FindUnitInUnitSet(Directory,AUnitName);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCodeToolManager.GetUnitSetForDirectory(const Directory: string;
|
||||||
|
UseCache: boolean): string;
|
||||||
|
var
|
||||||
|
Evaluator: TExpressionEvaluator;
|
||||||
|
begin
|
||||||
|
if UseCache then begin
|
||||||
|
Result:=DirectoryCachePool.GetString(Directory,ctdcsUnitSet,true)
|
||||||
|
end else begin
|
||||||
|
Result:='';
|
||||||
|
Evaluator:=DefineTree.GetDefinesForDirectory(Directory,true);
|
||||||
|
if Evaluator=nil then exit;
|
||||||
|
Result:=Evaluator[UnitSetMacroName];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCodeToolManager.GetFPCUnitPathForDirectory(const Directory: string;
|
function TCodeToolManager.GetFPCUnitPathForDirectory(const Directory: string;
|
||||||
UseCache: boolean): string;
|
UseCache: boolean): string;
|
||||||
var
|
var
|
||||||
@ -5212,6 +5242,7 @@ begin
|
|||||||
ctdcsIncludePath: Result:=GetIncludePathForDirectory(ADirectory,false);
|
ctdcsIncludePath: Result:=GetIncludePathForDirectory(ADirectory,false);
|
||||||
ctdcsCompleteSrcPath: Result:=GetCompleteSrcPathForDirectory(ADirectory,false);
|
ctdcsCompleteSrcPath: Result:=GetCompleteSrcPathForDirectory(ADirectory,false);
|
||||||
ctdcsUnitLinks: Result:=GetUnitLinksForDirectory(ADirectory,false);
|
ctdcsUnitLinks: Result:=GetUnitLinksForDirectory(ADirectory,false);
|
||||||
|
ctdcsUnitSet: Result:=GetUnitSetForDirectory(ADirectory,false);
|
||||||
ctdcsFPCUnitPath: Result:=GetFPCUnitPathForDirectory(ADirectory,false);
|
ctdcsFPCUnitPath: Result:=GetFPCUnitPathForDirectory(ADirectory,false);
|
||||||
else RaiseCatchableException('');
|
else RaiseCatchableException('');
|
||||||
end;
|
end;
|
||||||
@ -5230,6 +5261,18 @@ begin
|
|||||||
Result:=Code.Filename;
|
Result:=Code.Filename;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCodeToolManager.DirectoryCachePoolGetUnitFromSet(const UnitSet,
|
||||||
|
AnUnitName: string): string;
|
||||||
|
var
|
||||||
|
Changed: boolean;
|
||||||
|
UnitSetCache: TFPCUnitSetCache;
|
||||||
|
Tree: TStringToStringTree;
|
||||||
|
begin
|
||||||
|
UnitSetCache:=FPCDefinesCache.FindUnitToSrcCache(UnitSet,Changed,true);
|
||||||
|
Tree:=UnitSetCache.GetUnitToSourceTree(false);
|
||||||
|
Result:=Tree[AnUnitName];
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCodeToolManager.OnToolSetWriteLock(Lock: boolean);
|
procedure TCodeToolManager.OnToolSetWriteLock(Lock: boolean);
|
||||||
begin
|
begin
|
||||||
if Lock then ActivateWriteLock else DeactivateWriteLock;
|
if Lock then ActivateWriteLock else DeactivateWriteLock;
|
||||||
|
@ -79,6 +79,7 @@ const
|
|||||||
DCUSrcPathMacroName = ExternalMacroStart+'DCUSrcPath';
|
DCUSrcPathMacroName = ExternalMacroStart+'DCUSrcPath';
|
||||||
CompiledSrcPathMacroName = ExternalMacroStart+'CompiledSrcPath';
|
CompiledSrcPathMacroName = ExternalMacroStart+'CompiledSrcPath';
|
||||||
UnitLinksMacroName = ExternalMacroStart+'UnitLinks';
|
UnitLinksMacroName = ExternalMacroStart+'UnitLinks';
|
||||||
|
UnitSetMacroName = ExternalMacroStart+'UnitSet';
|
||||||
FPCUnitPathMacroName = ExternalMacroStart+'FPCUnitPath';
|
FPCUnitPathMacroName = ExternalMacroStart+'FPCUnitPath';
|
||||||
TargetOSMacroName = ExternalMacroStart+'TargetOS';
|
TargetOSMacroName = ExternalMacroStart+'TargetOS';
|
||||||
TargetCPUMacroName = ExternalMacroStart+'TargetCPU';
|
TargetCPUMacroName = ExternalMacroStart+'TargetCPU';
|
||||||
@ -92,6 +93,7 @@ const
|
|||||||
DCUSrcPathMacro = '$('+DCUSrcPathMacroName+')';
|
DCUSrcPathMacro = '$('+DCUSrcPathMacroName+')';
|
||||||
CompiledSrcPathMacro = '$('+CompiledSrcPathMacroName+')';
|
CompiledSrcPathMacro = '$('+CompiledSrcPathMacroName+')';
|
||||||
UnitLinksMacro = '$('+UnitLinksMacroName+')';
|
UnitLinksMacro = '$('+UnitLinksMacroName+')';
|
||||||
|
UnitSetMacro = '$('+UnitSetMacroName+')';
|
||||||
FPCUnitPathMacro = '$('+FPCUnitPathMacroName+')';
|
FPCUnitPathMacro = '$('+FPCUnitPathMacroName+')';
|
||||||
TargetOSMacro = '$('+TargetOSMacroName+')';
|
TargetOSMacro = '$('+TargetOSMacroName+')';
|
||||||
TargetCPUMacro = '$('+TargetCPUMacroName+')';
|
TargetCPUMacro = '$('+TargetCPUMacroName+')';
|
||||||
@ -772,11 +774,11 @@ type
|
|||||||
);
|
);
|
||||||
TFPCUnitToSrcCacheFlags = set of TFPCUnitToSrcCacheFlag;
|
TFPCUnitToSrcCacheFlags = set of TFPCUnitToSrcCacheFlag;
|
||||||
|
|
||||||
{ TFPCUnitToSrcCache
|
{ TFPCUnitSetCache
|
||||||
Unit name to FPC source file.
|
Unit name to FPC source file.
|
||||||
Specific to one compiler, targetos, targetcpu and FPC source directory. }
|
Specific to one compiler, targetos, targetcpu and FPC source directory. }
|
||||||
|
|
||||||
TFPCUnitToSrcCache = class(TComponent)
|
TFPCUnitSetCache = class(TComponent)
|
||||||
private
|
private
|
||||||
FCaches: TFPCDefinesCache;
|
FCaches: TFPCDefinesCache;
|
||||||
FChangeStamp: integer;
|
FChangeStamp: integer;
|
||||||
@ -821,6 +823,7 @@ type
|
|||||||
function GetSourceDuplicates(AutoUpdate: boolean): TStringToStringTree; // lower case unit to semicolon separated list of files
|
function GetSourceDuplicates(AutoUpdate: boolean): TStringToStringTree; // lower case unit to semicolon separated list of files
|
||||||
property ChangeStamp: integer read FChangeStamp;
|
property ChangeStamp: integer read FChangeStamp;
|
||||||
procedure IncreaseChangeStamp;
|
procedure IncreaseChangeStamp;
|
||||||
|
function GetUnitSetID: string;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFPCDefinesCache }
|
{ TFPCDefinesCache }
|
||||||
@ -832,7 +835,7 @@ type
|
|||||||
FSourceCaches: TFPCSourceCaches;
|
FSourceCaches: TFPCSourceCaches;
|
||||||
FSourceCachesSaveStamp: integer;
|
FSourceCachesSaveStamp: integer;
|
||||||
FTestFilename: string;
|
FTestFilename: string;
|
||||||
fUnitToSrcCaches: TFPList; // list of TFPCUnitToSrcCache
|
fUnitToSrcCaches: TFPList; // list of TFPCUnitSetCache
|
||||||
procedure SetConfigCaches(const AValue: TFPCTargetConfigCaches);
|
procedure SetConfigCaches(const AValue: TFPCTargetConfigCaches);
|
||||||
procedure SetSourceCaches(const AValue: TFPCSourceCaches);
|
procedure SetSourceCaches(const AValue: TFPCSourceCaches);
|
||||||
procedure ClearUnitToSrcCaches;
|
procedure ClearUnitToSrcCaches;
|
||||||
@ -847,11 +850,17 @@ type
|
|||||||
function NeedsSave: boolean;
|
function NeedsSave: boolean;
|
||||||
property SourceCaches: TFPCSourceCaches read FSourceCaches write SetSourceCaches;
|
property SourceCaches: TFPCSourceCaches read FSourceCaches write SetSourceCaches;
|
||||||
property ConfigCaches: TFPCTargetConfigCaches read FConfigCaches write SetConfigCaches;
|
property ConfigCaches: TFPCTargetConfigCaches read FConfigCaches write SetConfigCaches;
|
||||||
function FindUnitToSrcCache(const CompilerFilename, TargetOS, TargetCPU,
|
|
||||||
FPCSrcDir: string; CreateIfNotExists: boolean
|
|
||||||
): TFPCUnitToSrcCache;
|
|
||||||
|
|
||||||
property TestFilename: string read FTestFilename write FTestFilename; // an empty file to test the compiler, will be auto created
|
property TestFilename: string read FTestFilename write FTestFilename; // an empty file to test the compiler, will be auto created
|
||||||
|
function FindUnitToSrcCache(const CompilerFilename, TargetOS, TargetCPU,
|
||||||
|
Options, FPCSrcDir: string;
|
||||||
|
CreateIfNotExists: boolean): TFPCUnitSetCache;
|
||||||
|
function FindUnitToSrcCache(const UnitSetID: string; out Changed: boolean;
|
||||||
|
CreateIfNotExists: boolean): TFPCUnitSetCache;
|
||||||
|
function GetUnitSetID(CompilerFilename, TargetOS, TargetCPU, Options,
|
||||||
|
FPCSrcDir: string; ChangeStamp: integer): string;
|
||||||
|
procedure ParseUnitSetID(ID: string; out CompilerFilename,
|
||||||
|
TargetOS, TargetCPU, Options, FPCSrcDir: string;
|
||||||
|
out ChangeStamp: integer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function DefineActionNameToAction(const s: string): TDefineAction;
|
function DefineActionNameToAction(const s: string): TDefineAction;
|
||||||
@ -899,7 +908,9 @@ function GatherUnitsInFPCSources(Files: TStringList;
|
|||||||
Duplicates: TStringToStringTree = nil; // lower case unit to semicolon separated list of files
|
Duplicates: TStringToStringTree = nil; // lower case unit to semicolon separated list of files
|
||||||
Rules: TFPCSourceRules = nil): TStringToStringTree;
|
Rules: TFPCSourceRules = nil): TStringToStringTree;
|
||||||
function CreateFPCTemplate(Config: TFPCTargetConfigCache;
|
function CreateFPCTemplate(Config: TFPCTargetConfigCache;
|
||||||
Owner: TObject): TDefineTemplate;
|
Owner: TObject): TDefineTemplate; overload;
|
||||||
|
function CreateFPCTemplate(Config: TFPCUnitSetCache;
|
||||||
|
Owner: TObject): TDefineTemplate; overload;
|
||||||
procedure CheckPPUSources(PPUFiles, // lowercase unitname to filename
|
procedure CheckPPUSources(PPUFiles, // lowercase unitname to filename
|
||||||
UnitToSource, // lowercase unitname to file name
|
UnitToSource, // lowercase unitname to file name
|
||||||
UnitToDuplicates: TStringToStringTree; // lowercase unitname to semicolon separated list of files
|
UnitToDuplicates: TStringToStringTree; // lowercase unitname to semicolon separated list of files
|
||||||
@ -1671,6 +1682,14 @@ begin
|
|||||||
Result.SetDefineOwner(Owner,true);
|
Result.SetDefineOwner(Owner,true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CreateFPCTemplate(Config: TFPCUnitSetCache; Owner: TObject
|
||||||
|
): TDefineTemplate; overload;
|
||||||
|
begin
|
||||||
|
Result:=CreateFPCTemplate(Config.GetConfigCache(false),Owner);
|
||||||
|
Result.AddChild(TDefineTemplate.Create('UnitSet','UnitSet identifier',
|
||||||
|
UnitSetMacroName,Config.GetUnitSetID,da_DefineRecurse));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure CheckPPUSources(PPUFiles, UnitToSource,
|
procedure CheckPPUSources(PPUFiles, UnitToSource,
|
||||||
UnitToDuplicates: TStringToStringTree;
|
UnitToDuplicates: TStringToStringTree;
|
||||||
var Duplicates, Missing: TStringToStringTree);
|
var Duplicates, Missing: TStringToStringTree);
|
||||||
@ -7643,25 +7662,117 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPCDefinesCache.FindUnitToSrcCache(const CompilerFilename, TargetOS,
|
function TFPCDefinesCache.FindUnitToSrcCache(const CompilerFilename, TargetOS,
|
||||||
TargetCPU, FPCSrcDir: string; CreateIfNotExists: boolean
|
TargetCPU, Options, FPCSrcDir: string; CreateIfNotExists: boolean
|
||||||
): TFPCUnitToSrcCache;
|
): TFPCUnitSetCache;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
for i:=0 to fUnitToSrcCaches.Count-1 do begin
|
for i:=0 to fUnitToSrcCaches.Count-1 do begin
|
||||||
Result:=TFPCUnitToSrcCache(fUnitToSrcCaches[i]);
|
Result:=TFPCUnitSetCache(fUnitToSrcCaches[i]);
|
||||||
if (CompareFilenames(Result.CompilerFilename,CompilerFilename)=0)
|
if (CompareFilenames(Result.CompilerFilename,CompilerFilename)=0)
|
||||||
and (SysUtils.CompareText(Result.TargetOS,TargetOS)=0)
|
and (SysUtils.CompareText(Result.TargetOS,TargetOS)=0)
|
||||||
and (SysUtils.CompareText(Result.TargetCPU,TargetCPU)=0)
|
and (SysUtils.CompareText(Result.TargetCPU,TargetCPU)=0)
|
||||||
and (CompareFilenames(Result.FPCSourceDirectory,FPCSrcDir)=0) then
|
and (CompareFilenames(Result.FPCSourceDirectory,FPCSrcDir)=0)
|
||||||
|
and (Result.CompilerOptions=Options)
|
||||||
|
then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
Result:=nil;
|
if CreateIfNotExists then begin
|
||||||
|
Result:=TFPCUnitSetCache.Create(nil);
|
||||||
|
Result.CompilerFilename:=CompilerFilename;
|
||||||
|
Result.CompilerOptions:=Options;
|
||||||
|
Result.TargetOS:=TargetOS;
|
||||||
|
Result.TargetCPU:=TargetCPU;
|
||||||
|
Result.FPCSourceDirectory:=FPCSrcDir;
|
||||||
|
fUnitToSrcCaches.Add(Result);
|
||||||
|
end else
|
||||||
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFPCUnitToSrcCache }
|
function TFPCDefinesCache.FindUnitToSrcCache(const UnitSetID: string; out
|
||||||
|
Changed: boolean; CreateIfNotExists: boolean): TFPCUnitSetCache;
|
||||||
|
var
|
||||||
|
CompilerFilename, TargetOS, TargetCPU, Options, FPCSrcDir: string;
|
||||||
|
ChangeStamp: integer;
|
||||||
|
begin
|
||||||
|
ParseUnitSetID(UnitSetID,CompilerFilename, TargetOS, TargetCPU,
|
||||||
|
Options, FPCSrcDir, ChangeStamp);
|
||||||
|
Result:=FindUnitToSrcCache(CompilerFilename, TargetOS, TargetCPU,
|
||||||
|
Options, FPCSrcDir,CreateIfNotExists);
|
||||||
|
Changed:=ChangeStamp<>Result.ChangeStamp;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.SetCompilerFilename(const AValue: string);
|
function TFPCDefinesCache.GetUnitSetID(CompilerFilename, TargetOS, TargetCPU,
|
||||||
|
Options, FPCSrcDir: string; ChangeStamp: integer): string;
|
||||||
|
begin
|
||||||
|
if CompilerFilename='' then CompilerFilename:=GetDefaultCompilerFilename;
|
||||||
|
if TargetOS='' then TargetOS:=GetCompiledTargetOS;
|
||||||
|
if TargetCPU='' then TargetCPU:=GetCompiledTargetCPU;
|
||||||
|
Result:='CompilerFilename='+CompilerFilename+LineEnding
|
||||||
|
+'TargetOS='+TargetOS+LineEnding
|
||||||
|
+'TargetCPU='+TargetCPU+LineEnding
|
||||||
|
+'Options='+Options+LineEnding
|
||||||
|
+'FPCSrcDir='+FPCSrcDir+LineEnding
|
||||||
|
+'Stamp='+IntToStr(ChangeStamp);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPCDefinesCache.ParseUnitSetID(ID: string; out CompilerFilename,
|
||||||
|
TargetOS, TargetCPU, Options, FPCSrcDir: string; out ChangeStamp: integer);
|
||||||
|
var
|
||||||
|
NameStartPos: PChar;
|
||||||
|
ValueStartPos: PChar;
|
||||||
|
ValueEndPos: PChar;
|
||||||
|
Value: String;
|
||||||
|
begin
|
||||||
|
CompilerFilename:='';
|
||||||
|
TargetCPU:='';
|
||||||
|
TargetOS:='';
|
||||||
|
Options:='';
|
||||||
|
FPCSrcDir:='';
|
||||||
|
ChangeStamp:=0;
|
||||||
|
if ID='' then exit;
|
||||||
|
// read the lines with name=value
|
||||||
|
NameStartPos:=PChar(ID);
|
||||||
|
while NameStartPos^<>#0 do begin
|
||||||
|
while (NameStartPos^ in [#10,#13]) do inc(NameStartPos);
|
||||||
|
ValueStartPos:=NameStartPos;
|
||||||
|
while not (ValueStartPos^ in ['=',#10,#13,#0]) do inc(ValueStartPos);
|
||||||
|
if ValueStartPos<>'=' then exit;
|
||||||
|
inc(ValueStartPos);
|
||||||
|
ValueEndPos:=ValueStartPos;
|
||||||
|
while not (ValueEndPos^ in [#10,#13,#0]) do inc(ValueEndPos);
|
||||||
|
Value:=copy(ID,ValueStartPos-PChar(ID),ValueEndPos-ValueStartPos);;
|
||||||
|
case NameStartPos^ of
|
||||||
|
'c','C':
|
||||||
|
if ComparePCharCaseInsensitive(NameStartPos,PChar('CompilerFilename'))=0
|
||||||
|
then
|
||||||
|
CompilerFilename:=Value
|
||||||
|
else if ComparePCharCaseInsensitive(NameStartPos,PChar('Stamp'))=0
|
||||||
|
then
|
||||||
|
ChangeStamp:=StrToIntDef(Value,0);
|
||||||
|
'f','F':
|
||||||
|
if ComparePCharCaseInsensitive(NameStartPos,PChar('FPCSrcDir'))=0
|
||||||
|
then
|
||||||
|
FPCSrcDir:=Value;
|
||||||
|
'o','O':
|
||||||
|
if ComparePCharCaseInsensitive(NameStartPos,PChar('Options'))=0
|
||||||
|
then
|
||||||
|
Options:=Value;
|
||||||
|
't','T':
|
||||||
|
if ComparePCharCaseInsensitive(NameStartPos,PChar('TargetOS'))=0
|
||||||
|
then
|
||||||
|
TargetOS:=Value
|
||||||
|
else if ComparePCharCaseInsensitive(NameStartPos,PChar('TargetCPU'))=0
|
||||||
|
then
|
||||||
|
TargetCPU:=Value;
|
||||||
|
end;
|
||||||
|
NameStartPos:=ValueEndPos;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TFPCUnitSetCache }
|
||||||
|
|
||||||
|
procedure TFPCUnitSetCache.SetCompilerFilename(const AValue: string);
|
||||||
var
|
var
|
||||||
NewFilename: String;
|
NewFilename: String;
|
||||||
begin
|
begin
|
||||||
@ -7671,14 +7782,14 @@ begin
|
|||||||
ClearConfigCache;
|
ClearConfigCache;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.SetCompilerOptions(const AValue: string);
|
procedure TFPCUnitSetCache.SetCompilerOptions(const AValue: string);
|
||||||
begin
|
begin
|
||||||
if FCompilerOptions=AValue then exit;
|
if FCompilerOptions=AValue then exit;
|
||||||
FCompilerOptions:=AValue;
|
FCompilerOptions:=AValue;
|
||||||
ClearConfigCache;
|
ClearConfigCache;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.SetFPCSourceDirectory(const AValue: string);
|
procedure TFPCUnitSetCache.SetFPCSourceDirectory(const AValue: string);
|
||||||
var
|
var
|
||||||
NewValue: String;
|
NewValue: String;
|
||||||
begin
|
begin
|
||||||
@ -7688,35 +7799,35 @@ begin
|
|||||||
ClearSourceCache;
|
ClearSourceCache;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.SetTargetCPU(const AValue: string);
|
procedure TFPCUnitSetCache.SetTargetCPU(const AValue: string);
|
||||||
begin
|
begin
|
||||||
if FTargetCPU=AValue then exit;
|
if FTargetCPU=AValue then exit;
|
||||||
FTargetCPU:=AValue;
|
FTargetCPU:=AValue;
|
||||||
ClearConfigCache;
|
ClearConfigCache;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.SetTargetOS(const AValue: string);
|
procedure TFPCUnitSetCache.SetTargetOS(const AValue: string);
|
||||||
begin
|
begin
|
||||||
if FTargetOS=AValue then exit;
|
if FTargetOS=AValue then exit;
|
||||||
FTargetOS:=AValue;
|
FTargetOS:=AValue;
|
||||||
ClearConfigCache;
|
ClearConfigCache;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.ClearConfigCache;
|
procedure TFPCUnitSetCache.ClearConfigCache;
|
||||||
begin
|
begin
|
||||||
FConfigCache:=nil;
|
FConfigCache:=nil;
|
||||||
FreeAndNil(fSourceRules);
|
FreeAndNil(fSourceRules);
|
||||||
fFlags:=fFlags+[fuscfUnitTreeNeedsUpdate,fuscfSrcRulesNeedUpdate];
|
fFlags:=fFlags+[fuscfUnitTreeNeedsUpdate,fuscfSrcRulesNeedUpdate];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.ClearSourceCache;
|
procedure TFPCUnitSetCache.ClearSourceCache;
|
||||||
begin
|
begin
|
||||||
fSourceCache:=nil;
|
fSourceCache:=nil;
|
||||||
Include(fFlags,fuscfUnitTreeNeedsUpdate);
|
Include(fFlags,fuscfUnitTreeNeedsUpdate);
|
||||||
FreeAndNil(fSrcDuplicates);
|
FreeAndNil(fSrcDuplicates);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.Notification(AComponent: TComponent;
|
procedure TFPCUnitSetCache.Notification(AComponent: TComponent;
|
||||||
Operation: TOperation);
|
Operation: TOperation);
|
||||||
begin
|
begin
|
||||||
inherited Notification(AComponent, Operation);
|
inherited Notification(AComponent, Operation);
|
||||||
@ -7728,7 +7839,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TFPCUnitToSrcCache.Create(TheOwner: TComponent);
|
constructor TFPCUnitSetCache.Create(TheOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
FCaches:=TheOwner as TFPCDefinesCache;
|
FCaches:=TheOwner as TFPCDefinesCache;
|
||||||
@ -7738,7 +7849,7 @@ begin
|
|||||||
fFlags:=[fuscfUnitTreeNeedsUpdate,fuscfSrcRulesNeedUpdate];
|
fFlags:=[fuscfUnitTreeNeedsUpdate,fuscfSrcRulesNeedUpdate];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TFPCUnitToSrcCache.Destroy;
|
destructor TFPCUnitSetCache.Destroy;
|
||||||
begin
|
begin
|
||||||
FreeAndNil(fSourceRules);
|
FreeAndNil(fSourceRules);
|
||||||
FreeAndNil(fUnitToSourceTree);
|
FreeAndNil(fUnitToSourceTree);
|
||||||
@ -7746,12 +7857,12 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.Clear;
|
procedure TFPCUnitSetCache.Clear;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPCUnitToSrcCache.GetConfigCache(AutoUpdate: boolean
|
function TFPCUnitSetCache.GetConfigCache(AutoUpdate: boolean
|
||||||
): TFPCTargetConfigCache;
|
): TFPCTargetConfigCache;
|
||||||
begin
|
begin
|
||||||
if CompilerFilename='' then
|
if CompilerFilename='' then
|
||||||
@ -7768,7 +7879,7 @@ begin
|
|||||||
Result:=FConfigCache;
|
Result:=FConfigCache;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPCUnitToSrcCache.GetSourceCache(AutoUpdate: boolean
|
function TFPCUnitSetCache.GetSourceCache(AutoUpdate: boolean
|
||||||
): TFPCSourceCache;
|
): TFPCSourceCache;
|
||||||
begin
|
begin
|
||||||
if FPCSourceDirectory='' then
|
if FPCSourceDirectory='' then
|
||||||
@ -7782,7 +7893,7 @@ begin
|
|||||||
Result:=fSourceCache;
|
Result:=fSourceCache;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPCUnitToSrcCache.GetSourceRules(AutoUpdate: boolean
|
function TFPCUnitSetCache.GetSourceRules(AutoUpdate: boolean
|
||||||
): TFPCSourceRules;
|
): TFPCSourceRules;
|
||||||
var
|
var
|
||||||
Cfg: TFPCTargetConfigCache;
|
Cfg: TFPCTargetConfigCache;
|
||||||
@ -7803,7 +7914,7 @@ begin
|
|||||||
Result:=fSourceRules;
|
Result:=fSourceRules;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPCUnitToSrcCache.GetUnitToSourceTree(AutoUpdate: boolean
|
function TFPCUnitSetCache.GetUnitToSourceTree(AutoUpdate: boolean
|
||||||
): TStringToStringTree;
|
): TStringToStringTree;
|
||||||
var
|
var
|
||||||
Src: TFPCSourceCache;
|
Src: TFPCSourceCache;
|
||||||
@ -7842,14 +7953,14 @@ begin
|
|||||||
Result:=fUnitToSourceTree;
|
Result:=fUnitToSourceTree;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPCUnitToSrcCache.GetSourceDuplicates(AutoUpdate: boolean
|
function TFPCUnitSetCache.GetSourceDuplicates(AutoUpdate: boolean
|
||||||
): TStringToStringTree;
|
): TStringToStringTree;
|
||||||
begin
|
begin
|
||||||
GetUnitToSourceTree(AutoUpdate);
|
GetUnitToSourceTree(AutoUpdate);
|
||||||
Result:=fSrcDuplicates;
|
Result:=fSrcDuplicates;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPCUnitToSrcCache.IncreaseChangeStamp;
|
procedure TFPCUnitSetCache.IncreaseChangeStamp;
|
||||||
begin
|
begin
|
||||||
if FChangeStamp<High(FChangeStamp) then
|
if FChangeStamp<High(FChangeStamp) then
|
||||||
inc(FChangeStamp)
|
inc(FChangeStamp)
|
||||||
@ -7857,6 +7968,12 @@ begin
|
|||||||
FChangeStamp:=Low(FChangeStamp);
|
FChangeStamp:=Low(FChangeStamp);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFPCUnitSetCache.GetUnitSetID: string;
|
||||||
|
begin
|
||||||
|
Result:=Caches.GetUnitSetID(CompilerFilename,CompilerOptions,
|
||||||
|
TargetOS,TargetCPU,FPCSourceDirectory,ChangeStamp);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
InitDefaultFPCSourceRules;
|
InitDefaultFPCSourceRules;
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ type
|
|||||||
ctdcsIncludePath,
|
ctdcsIncludePath,
|
||||||
ctdcsCompleteSrcPath, // including unit path, src path and compiled src paths
|
ctdcsCompleteSrcPath, // including unit path, src path and compiled src paths
|
||||||
ctdcsUnitLinks,
|
ctdcsUnitLinks,
|
||||||
|
ctdcsUnitSet,
|
||||||
ctdcsFPCUnitPath // unit paths reported by FPC
|
ctdcsFPCUnitPath // unit paths reported by FPC
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -82,6 +83,16 @@ const
|
|||||||
ctdusUnitFileCaseInsensitive];
|
ctdusUnitFileCaseInsensitive];
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
{ TUnitNameLink }
|
||||||
|
|
||||||
|
TUnitNameLink = class
|
||||||
|
public
|
||||||
|
Unit_Name: string;
|
||||||
|
Filename: string;
|
||||||
|
function CalcMemSize: PtrUInt;
|
||||||
|
end;
|
||||||
|
|
||||||
TCTDirCacheUnitSrcRecord = record
|
TCTDirCacheUnitSrcRecord = record
|
||||||
Files: TStringToStringTree;
|
Files: TStringToStringTree;
|
||||||
ConfigTimeStamp: Cardinal;
|
ConfigTimeStamp: Cardinal;
|
||||||
@ -134,6 +145,7 @@ type
|
|||||||
procedure Reference;
|
procedure Reference;
|
||||||
procedure Release;
|
procedure Release;
|
||||||
function FindUnitLink(const AUnitName: string): string;
|
function FindUnitLink(const AUnitName: string): string;
|
||||||
|
function FindUnitInUnitSet(const AUnitName: string): string;
|
||||||
function FindFile(const ShortFilename: string;
|
function FindFile(const ShortFilename: string;
|
||||||
const FileCase: TCTSearchFileCase): string;
|
const FileCase: TCTSearchFileCase): string;
|
||||||
function FindUnitSource(const AUnitName: string; AnyCase: boolean): string;
|
function FindUnitSource(const AUnitName: string; AnyCase: boolean): string;
|
||||||
@ -157,6 +169,7 @@ type
|
|||||||
const AStringType: TCTDirCacheString
|
const AStringType: TCTDirCacheString
|
||||||
): string of object;
|
): string of object;
|
||||||
TCTDirCacheFindVirtualFile = function(const Filename: string): string of object;
|
TCTDirCacheFindVirtualFile = function(const Filename: string): string of object;
|
||||||
|
TCTGetUnitFromSet = function(const UnitSet, AnUnitName: string): string of object;
|
||||||
|
|
||||||
TCTDirectoryCachePool = class
|
TCTDirectoryCachePool = class
|
||||||
private
|
private
|
||||||
@ -165,6 +178,7 @@ type
|
|||||||
FDirectories: TAVLTree;// tree of TCTDirectoryCache
|
FDirectories: TAVLTree;// tree of TCTDirectoryCache
|
||||||
FOnFindVirtualFile: TCTDirCacheFindVirtualFile;
|
FOnFindVirtualFile: TCTDirCacheFindVirtualFile;
|
||||||
FOnGetString: TCTDirCacheGetString;
|
FOnGetString: TCTDirCacheGetString;
|
||||||
|
FOnGetUnitFromSet: TCTGetUnitFromSet;
|
||||||
procedure DoRemove(ACache: TCTDirectoryCache);
|
procedure DoRemove(ACache: TCTDirectoryCache);
|
||||||
procedure OnFileStateCacheChangeTimeStamp(Sender: TObject);
|
procedure OnFileStateCacheChangeTimeStamp(Sender: TObject);
|
||||||
public
|
public
|
||||||
@ -179,6 +193,7 @@ type
|
|||||||
procedure IncreaseFileTimeStamp;
|
procedure IncreaseFileTimeStamp;
|
||||||
procedure IncreaseConfigTimeStamp;
|
procedure IncreaseConfigTimeStamp;
|
||||||
function FindUnitInUnitLinks(const Directory, AUnitName: string): string;
|
function FindUnitInUnitLinks(const Directory, AUnitName: string): string;
|
||||||
|
function FindUnitInUnitSet(const Directory, AUnitName: string): string;
|
||||||
function FindDiskFilename(const Filename: string): string;
|
function FindDiskFilename(const Filename: string): string;
|
||||||
function FindUnitInDirectory(const Directory, AUnitName: string;
|
function FindUnitInDirectory(const Directory, AUnitName: string;
|
||||||
AnyCase: boolean = false): string;
|
AnyCase: boolean = false): string;
|
||||||
@ -195,6 +210,8 @@ type
|
|||||||
property OnGetString: TCTDirCacheGetString read FOnGetString write FOnGetString;
|
property OnGetString: TCTDirCacheGetString read FOnGetString write FOnGetString;
|
||||||
property OnFindVirtualFile: TCTDirCacheFindVirtualFile read FOnFindVirtualFile
|
property OnFindVirtualFile: TCTDirCacheFindVirtualFile read FOnFindVirtualFile
|
||||||
write FOnFindVirtualFile;
|
write FOnFindVirtualFile;
|
||||||
|
property OnGetUnitFromSet: TCTGetUnitFromSet read FOnGetUnitFromSet
|
||||||
|
write FOnGetUnitFromSet;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareCTDirectoryCaches(Data1, Data2: Pointer): integer;
|
function CompareCTDirectoryCaches(Data1, Data2: Pointer): integer;
|
||||||
@ -204,21 +221,11 @@ function ComparePCharFirstCaseInsThenCase(Data1, Data2: Pointer): integer;
|
|||||||
function ComparePCharCaseInsensitive(Data1, Data2: Pointer): integer;
|
function ComparePCharCaseInsensitive(Data1, Data2: Pointer): integer;
|
||||||
function ComparePCharCaseSensitive(Data1, Data2: Pointer): integer;
|
function ComparePCharCaseSensitive(Data1, Data2: Pointer): integer;
|
||||||
|
|
||||||
type
|
// unit links
|
||||||
|
|
||||||
{ TUnitNameLink }
|
|
||||||
|
|
||||||
TUnitNameLink = class
|
|
||||||
public
|
|
||||||
Unit_Name: string;
|
|
||||||
Filename: string;
|
|
||||||
function CalcMemSize: PtrUInt;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function SearchUnitInUnitLinks(const UnitLinks, TheUnitName: string;
|
function SearchUnitInUnitLinks(const UnitLinks, TheUnitName: string;
|
||||||
var UnitLinkStart, UnitLinkEnd: integer; out Filename: string): boolean;
|
var UnitLinkStart, UnitLinkEnd: integer; out Filename: string): boolean;
|
||||||
function CreateUnitLinksTree(const UnitLinks: string): TAVLTree;
|
function CreateUnitLinksTree(const UnitLinks: string): TAVLTree; // tree of TUnitNameLink
|
||||||
function CompareUnitLinkNodes(NodeData1, NodeData2: pointer): integer;
|
function CompareUnitLinkNodes(NodeData1, NodeData2: Pointer): integer;
|
||||||
function CompareUnitNameWithUnitLinkNode(AUnitName: Pointer;
|
function CompareUnitNameWithUnitLinkNode(AUnitName: Pointer;
|
||||||
NodeData: pointer): integer;
|
NodeData: pointer): integer;
|
||||||
|
|
||||||
@ -708,6 +715,14 @@ begin
|
|||||||
Result:='';
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCTDirectoryCache.FindUnitInUnitSet(const AUnitName: string): string;
|
||||||
|
var
|
||||||
|
UnitSet: string;
|
||||||
|
begin
|
||||||
|
UnitSet:=Strings[ctdcsUnitSet];
|
||||||
|
Result:=Pool.OnGetUnitFromSet(UnitSet,AUnitName);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCTDirectoryCache.FindFile(const ShortFilename: string;
|
function TCTDirectoryCache.FindFile(const ShortFilename: string;
|
||||||
const FileCase: TCTSearchFileCase): string;
|
const FileCase: TCTSearchFileCase): string;
|
||||||
|
|
||||||
@ -1203,6 +1218,23 @@ begin
|
|||||||
Result:=Cache.FindUnitLink(AUnitName);
|
Result:=Cache.FindUnitLink(AUnitName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCTDirectoryCachePool.FindUnitInUnitSet(const Directory,
|
||||||
|
AUnitName: string): string;
|
||||||
|
|
||||||
|
procedure RaiseDirNotAbsolute;
|
||||||
|
begin
|
||||||
|
raise Exception.Create('TCTDirectoryCachePool.FindUnitInUnitSet not absolute Directory="'+Directory+'"');
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Cache: TCTDirectoryCache;
|
||||||
|
begin
|
||||||
|
if (Directory<>'') and not FilenameIsAbsolute(Directory) then
|
||||||
|
RaiseDirNotAbsolute;
|
||||||
|
Cache:=GetCache(Directory,true,false);
|
||||||
|
Result:=Cache.FindUnitInUnitSet(AUnitName);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCTDirectoryCachePool.FindDiskFilename(const Filename: string
|
function TCTDirectoryCachePool.FindDiskFilename(const Filename: string
|
||||||
): string;
|
): string;
|
||||||
var
|
var
|
||||||
|
@ -790,7 +790,8 @@ type
|
|||||||
AnUnitInFilename: string): string;
|
AnUnitInFilename: string): string;
|
||||||
procedure GatherUnitAndSrcPath(var UnitPath, CompleteSrcPath: string);
|
procedure GatherUnitAndSrcPath(var UnitPath, CompleteSrcPath: string);
|
||||||
function SearchUnitInUnitLinks(const TheUnitName: string): string;
|
function SearchUnitInUnitLinks(const TheUnitName: string): string;
|
||||||
|
function SearchUnitInUnitSet(const TheUnitName: string): string;
|
||||||
|
|
||||||
function FindSmartHint(const CursorPos: TCodeXYPosition): string;
|
function FindSmartHint(const CursorPos: TCodeXYPosition): string;
|
||||||
|
|
||||||
function BaseTypeOfNodeHasSubIdents(ANode: TCodeTreeNode): boolean;
|
function BaseTypeOfNodeHasSubIdents(ANode: TCodeTreeNode): boolean;
|
||||||
@ -2103,6 +2104,14 @@ begin
|
|||||||
Result:=DirectoryCache.FindUnitLink(TheUnitName);
|
Result:=DirectoryCache.FindUnitLink(TheUnitName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFindDeclarationTool.SearchUnitInUnitSet(const TheUnitName: string
|
||||||
|
): string;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
if not CheckDirectoryCache then exit;
|
||||||
|
Result:=DirectoryCache.FindUnitInUnitSet(TheUnitName);
|
||||||
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.FindSmartHint(const CursorPos: TCodeXYPosition
|
function TFindDeclarationTool.FindSmartHint(const CursorPos: TCodeXYPosition
|
||||||
): string;
|
): string;
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user