mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 05:40:24 +02:00
IDE, CodeTools: rescan FPC directory cache automatically. Issue #30475
git-svn-id: trunk@52809 -
This commit is contained in:
parent
6b358bef49
commit
f3ee10c357
@ -114,6 +114,7 @@ type
|
|||||||
FOnFindDefineProperty: TOnFindDefineProperty;
|
FOnFindDefineProperty: TOnFindDefineProperty;
|
||||||
FOnGetIndenterExamples: TOnGetFABExamples;
|
FOnGetIndenterExamples: TOnGetFABExamples;
|
||||||
FOnGetMethodName: TOnGetMethodname;
|
FOnGetMethodName: TOnGetMethodname;
|
||||||
|
FOnRescanFPCDirectoryCache: TNotifyEvent;
|
||||||
FOnScannerInit: TOnScannerInit;
|
FOnScannerInit: TOnScannerInit;
|
||||||
FOnSearchUsedUnit: TOnSearchUsedUnit;
|
FOnSearchUsedUnit: TOnSearchUsedUnit;
|
||||||
FResourceTool: TResourceCodeTool;
|
FResourceTool: TResourceCodeTool;
|
||||||
@ -129,6 +130,7 @@ type
|
|||||||
FWriteLockCount: integer;// Set/Unset counter
|
FWriteLockCount: integer;// Set/Unset counter
|
||||||
FWriteLockStep: integer; // current write lock ID
|
FWriteLockStep: integer; // current write lock ID
|
||||||
FHandlers: array[TCodeToolManagerHandler] of TMethodList;
|
FHandlers: array[TCodeToolManagerHandler] of TMethodList;
|
||||||
|
procedure DoOnRescanFPCDirectoryCache(Sender: TObject);
|
||||||
function GetBeautifier: TBeautifyCodeOptions; inline;
|
function GetBeautifier: TBeautifyCodeOptions; inline;
|
||||||
function DoOnScannerGetInitValues(Scanner: TLinkScanner; Code: Pointer;
|
function DoOnScannerGetInitValues(Scanner: TLinkScanner; Code: Pointer;
|
||||||
out AChangeStep: integer): TExpressionEvaluator;
|
out AChangeStep: integer): TExpressionEvaluator;
|
||||||
@ -238,6 +240,7 @@ type
|
|||||||
out ListOfCodeBuffer: TFPList): boolean;
|
out ListOfCodeBuffer: TFPList): boolean;
|
||||||
property OnSearchUsedUnit: TOnSearchUsedUnit
|
property OnSearchUsedUnit: TOnSearchUsedUnit
|
||||||
read FOnSearchUsedUnit write FOnSearchUsedUnit;
|
read FOnSearchUsedUnit write FOnSearchUsedUnit;
|
||||||
|
property OnRescanFPCDirectoryCache: TNotifyEvent read FOnRescanFPCDirectoryCache write FOnRescanFPCDirectoryCache;
|
||||||
|
|
||||||
// initializing single scanner
|
// initializing single scanner
|
||||||
property OnScannerInit: TOnScannerInit read FOnScannerInit write FOnScannerInit;
|
property OnScannerInit: TOnScannerInit read FOnScannerInit write FOnScannerInit;
|
||||||
@ -5654,6 +5657,12 @@ begin
|
|||||||
Result:=not OnCheckAbort();
|
Result:=not OnCheckAbort();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCodeToolManager.DoOnRescanFPCDirectoryCache(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if Assigned(FOnRescanFPCDirectoryCache) then
|
||||||
|
FOnRescanFPCDirectoryCache(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCodeToolManager.DoOnToolTreeChange(Tool: TCustomCodeTool;
|
procedure TCodeToolManager.DoOnToolTreeChange(Tool: TCustomCodeTool;
|
||||||
NodesDeleting: boolean);
|
NodesDeleting: boolean);
|
||||||
var
|
var
|
||||||
@ -5915,6 +5924,7 @@ begin
|
|||||||
TCodeTool(Result).OnFindUsedUnit:=@DoOnFindUsedUnit;
|
TCodeTool(Result).OnFindUsedUnit:=@DoOnFindUsedUnit;
|
||||||
TCodeTool(Result).OnGetSrcPathForCompiledUnit:=@DoOnGetSrcPathForCompiledUnit;
|
TCodeTool(Result).OnGetSrcPathForCompiledUnit:=@DoOnGetSrcPathForCompiledUnit;
|
||||||
TCodeTool(Result).OnGetMethodName:=@DoOnInternalGetMethodName;
|
TCodeTool(Result).OnGetMethodName:=@DoOnInternalGetMethodName;
|
||||||
|
TCodeTool(Result).OnRescanFPCDirectoryCache:=@DoOnRescanFPCDirectoryCache;
|
||||||
TCodeTool(Result).DirectoryCache:=
|
TCodeTool(Result).DirectoryCache:=
|
||||||
DirectoryCachePool.GetCache(ExtractFilePath(Code.Filename),
|
DirectoryCachePool.GetCache(ExtractFilePath(Code.Filename),
|
||||||
true,true);
|
true,true);
|
||||||
|
@ -681,6 +681,7 @@ type
|
|||||||
FOnGetSrcPathForCompiledUnit: TOnGetSrcPathForCompiledUnit;
|
FOnGetSrcPathForCompiledUnit: TOnGetSrcPathForCompiledUnit;
|
||||||
FOnGetUnitSourceSearchPath: TOnGetSearchPath;
|
FOnGetUnitSourceSearchPath: TOnGetSearchPath;
|
||||||
FFirstNodeCache: TCodeTreeNodeCache;
|
FFirstNodeCache: TCodeTreeNodeCache;
|
||||||
|
FOnRescanFPCDirectoryCache: TNotifyEvent;
|
||||||
FRootNodeCache: TCodeTreeNodeCache;
|
FRootNodeCache: TCodeTreeNodeCache;
|
||||||
FFirstBaseTypeCache: TBaseTypeCache;
|
FFirstBaseTypeCache: TBaseTypeCache;
|
||||||
FDependentCodeTools: TAVLTree;// the codetools, that depend on this codetool
|
FDependentCodeTools: TAVLTree;// the codetools, that depend on this codetool
|
||||||
@ -718,7 +719,7 @@ type
|
|||||||
function FindIdentifierInAncestors(ClassNode: TCodeTreeNode;
|
function FindIdentifierInAncestors(ClassNode: TCodeTreeNode;
|
||||||
Params: TFindDeclarationParams): boolean;
|
Params: TFindDeclarationParams): boolean;
|
||||||
function FindIdentifierInUsesSection(UsesNode: TCodeTreeNode;
|
function FindIdentifierInUsesSection(UsesNode: TCodeTreeNode;
|
||||||
Params: TFindDeclarationParams): boolean; // ToDo: dotted
|
Params: TFindDeclarationParams; FindMissingFPCUnits: Boolean): boolean; // ToDo: dotted
|
||||||
function FindIdentifierInHiddenUsedUnits(
|
function FindIdentifierInHiddenUsedUnits(
|
||||||
Params: TFindDeclarationParams): boolean;
|
Params: TFindDeclarationParams): boolean;
|
||||||
function FindIdentifierInUsedUnit(const AnUnitName: string;
|
function FindIdentifierInUsedUnit(const AnUnitName: string;
|
||||||
@ -1016,6 +1017,19 @@ type
|
|||||||
property AdjustTopLineDueToComment: boolean
|
property AdjustTopLineDueToComment: boolean
|
||||||
read FAdjustTopLineDueToComment write FAdjustTopLineDueToComment;
|
read FAdjustTopLineDueToComment write FAdjustTopLineDueToComment;
|
||||||
property DirectoryCache: TCTDirectoryCache read FDirectoryCache write FDirectoryCache;
|
property DirectoryCache: TCTDirectoryCache read FDirectoryCache write FDirectoryCache;
|
||||||
|
|
||||||
|
property OnRescanFPCDirectoryCache: TNotifyEvent read FOnRescanFPCDirectoryCache write FOnRescanFPCDirectoryCache;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TFindIdentifierInUsesSection_FindMissingFPCUnit = class
|
||||||
|
private
|
||||||
|
FFileName: string;
|
||||||
|
FFound: Boolean;
|
||||||
|
public
|
||||||
|
constructor Create(AFileName: string);
|
||||||
|
procedure Iterate(const AFilename: string);
|
||||||
|
|
||||||
|
property Found: Boolean read FFound;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ExprTypeToString(const ExprType: TExpressionType): string;
|
function ExprTypeToString(const ExprType: TExpressionType): string;
|
||||||
@ -1447,6 +1461,22 @@ begin
|
|||||||
ListOfPFindContext:=nil;
|
ListOfPFindContext:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TFindIdentifierInUsesSection_FindMissingFPCUnit }
|
||||||
|
|
||||||
|
constructor TFindIdentifierInUsesSection_FindMissingFPCUnit.Create(
|
||||||
|
AFileName: string);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
|
||||||
|
FFileName := AFileName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFindIdentifierInUsesSection_FindMissingFPCUnit.Iterate(
|
||||||
|
const AFilename: string);
|
||||||
|
begin
|
||||||
|
FFound := FFound or SameFileName(FFileName, ExtractFileNameOnly(AFilename));
|
||||||
|
end;
|
||||||
|
|
||||||
{ TTypeAliasOrderList }
|
{ TTypeAliasOrderList }
|
||||||
|
|
||||||
constructor TTypeAliasOrderList.Create(const AliasNames: array of string);
|
constructor TTypeAliasOrderList.Create(const AliasNames: array of string);
|
||||||
@ -2401,7 +2431,7 @@ begin
|
|||||||
try
|
try
|
||||||
Params.Flags:=[fdfExceptionOnNotFound];
|
Params.Flags:=[fdfExceptionOnNotFound];
|
||||||
Params.SetIdentifier(Self,PChar(Pointer(Identifier)),nil);
|
Params.SetIdentifier(Self,PChar(Pointer(Identifier)),nil);
|
||||||
if FindIdentifierInUsesSection(UsesNode,Params) then begin
|
if FindIdentifierInUsesSection(UsesNode,Params,True) then begin
|
||||||
if Params.NewNode=nil then exit;
|
if Params.NewNode=nil then exit;
|
||||||
Result:=Params.NewCodeTool.JumpToNode(Params.NewNode,NewPos,
|
Result:=Params.NewCodeTool.JumpToNode(Params.NewNode,NewPos,
|
||||||
NewTopLine,false);
|
NewTopLine,false);
|
||||||
@ -4480,7 +4510,7 @@ begin
|
|||||||
|
|
||||||
ctnUsesSection:
|
ctnUsesSection:
|
||||||
begin
|
begin
|
||||||
if FindIdentifierInUsesSection(ContextNode,Params)
|
if FindIdentifierInUsesSection(ContextNode,Params,True)
|
||||||
and CheckResult(true,false) then
|
and CheckResult(true,false) then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -7457,7 +7487,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.FindIdentifierInUsesSection(
|
function TFindDeclarationTool.FindIdentifierInUsesSection(
|
||||||
UsesNode: TCodeTreeNode; Params: TFindDeclarationParams): boolean;
|
UsesNode: TCodeTreeNode; Params: TFindDeclarationParams;
|
||||||
|
FindMissingFPCUnits: Boolean): boolean;
|
||||||
{ this function is internally used by FindIdentifierInContext
|
{ this function is internally used by FindIdentifierInContext
|
||||||
|
|
||||||
search backwards through the uses section
|
search backwards through the uses section
|
||||||
@ -7483,6 +7514,7 @@ var
|
|||||||
var
|
var
|
||||||
AnUnitName: string;
|
AnUnitName: string;
|
||||||
InFilename: string;
|
InFilename: string;
|
||||||
|
FindMissing: TFindIdentifierInUsesSection_FindMissingFPCUnit;
|
||||||
begin
|
begin
|
||||||
{$IFDEF CheckNodeTool}CheckNodeTool(UsesNode);{$ENDIF}
|
{$IFDEF CheckNodeTool}CheckNodeTool(UsesNode);{$ENDIF}
|
||||||
{$IFDEF ShowTriedParentContexts}
|
{$IFDEF ShowTriedParentContexts}
|
||||||
@ -7543,7 +7575,23 @@ begin
|
|||||||
|
|
||||||
if (not Result) and (MissingUnit<>nil) then begin
|
if (not Result) and (MissingUnit<>nil) then begin
|
||||||
// identifier not found and there is a missing unit
|
// identifier not found and there is a missing unit
|
||||||
RaiseUnitNotFound;
|
if FindMissingFPCUnits and Assigned(FOnRescanFPCDirectoryCache) then
|
||||||
|
begin
|
||||||
|
FindMissing := TFindIdentifierInUsesSection_FindMissingFPCUnit.Create(AnUnitName);
|
||||||
|
try
|
||||||
|
DirectoryCache.IterateFPCUnitsInSet(@FindMissing.Iterate);
|
||||||
|
|
||||||
|
if FindMissing.Found then
|
||||||
|
begin
|
||||||
|
FOnRescanFPCDirectoryCache(Self);
|
||||||
|
Result := FindIdentifierInUsesSection(UsesNode, Params, False);
|
||||||
|
end else
|
||||||
|
RaiseUnitNotFound;
|
||||||
|
finally
|
||||||
|
FindMissing.Free;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
RaiseUnitNotFound;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -76,6 +76,7 @@ type
|
|||||||
fTargetOS: string;
|
fTargetOS: string;
|
||||||
fTargetCPU: string;
|
fTargetCPU: string;
|
||||||
fLCLWidgetType: string;
|
fLCLWidgetType: string;
|
||||||
|
procedure DoOnRescanFPCDirectoryCache(Sender: TObject);
|
||||||
procedure OnMacroSubstitution(TheMacro: TTransferMacro;
|
procedure OnMacroSubstitution(TheMacro: TTransferMacro;
|
||||||
const MacroName: string; var s: string;
|
const MacroName: string; var s: string;
|
||||||
const {%H-}Data: PtrInt; var Handled, {%H-}Abort: boolean;
|
const {%H-}Data: PtrInt; var Handled, {%H-}Abort: boolean;
|
||||||
@ -335,6 +336,8 @@ begin
|
|||||||
GetBuildMacroValues:=@OnGetBuildMacroValues;
|
GetBuildMacroValues:=@OnGetBuildMacroValues;
|
||||||
OnAppendCustomOption:=@AppendMatrixCustomOption;
|
OnAppendCustomOption:=@AppendMatrixCustomOption;
|
||||||
OnGetOutputDirectoryOverride:=@GetMatrixOutputDirectoryOverride;
|
OnGetOutputDirectoryOverride:=@GetMatrixOutputDirectoryOverride;
|
||||||
|
|
||||||
|
CodeToolBoss.OnRescanFPCDirectoryCache:=@DoOnRescanFPCDirectoryCache;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TBuildManager.Destroy;
|
destructor TBuildManager.Destroy;
|
||||||
@ -351,6 +354,9 @@ begin
|
|||||||
FreeAndNil(InputHistories);
|
FreeAndNil(InputHistories);
|
||||||
FreeAndNil(DefaultCfgVars);
|
FreeAndNil(DefaultCfgVars);
|
||||||
|
|
||||||
|
if CompareMethods(TMethod(CodeToolBoss.OnRescanFPCDirectoryCache), TMethod(@DoOnRescanFPCDirectoryCache)) then
|
||||||
|
CodeToolBoss.OnRescanFPCDirectoryCache:=nil;
|
||||||
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
MainBuildBoss:=nil;
|
MainBuildBoss:=nil;
|
||||||
end;
|
end;
|
||||||
@ -1333,6 +1339,21 @@ begin
|
|||||||
Result:=mrNo;
|
Result:=mrNo;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TBuildManager.DoOnRescanFPCDirectoryCache(Sender: TObject);
|
||||||
|
var
|
||||||
|
Files: TStringList;
|
||||||
|
FPCSrcDir: string;
|
||||||
|
begin
|
||||||
|
FPCSrcDir := EnvironmentOptions.GetParsedFPCSourceDirectory;
|
||||||
|
Files := GatherFilesInFPCSources(FPCSrcDir, nil);
|
||||||
|
if Files<>nil then
|
||||||
|
try
|
||||||
|
ApplyFPCSrcFiles(FPCSrcDir, Files);
|
||||||
|
finally
|
||||||
|
Files.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TBuildManager.CheckAmbiguousSources(const AFilename: string;
|
function TBuildManager.CheckAmbiguousSources(const AFilename: string;
|
||||||
Compiling: boolean): TModalResult;
|
Compiling: boolean): TModalResult;
|
||||||
|
|
||||||
|
@ -72,6 +72,8 @@ type
|
|||||||
procedure Scan(Directory: string);
|
procedure Scan(Directory: string);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure ApplyFPCSrcFiles(FPCSrcDir: string; var Files: TStringList);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure ApplyFPCSrcFiles(FPCSrcDir: string; var Files: TStringList);
|
procedure ApplyFPCSrcFiles(FPCSrcDir: string; var Files: TStringList);
|
||||||
|
Loading…
Reference in New Issue
Block a user