mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 00:16:02 +02:00
MG: fixed codetools proc collection
git-svn-id: trunk@1957 -
This commit is contained in:
parent
6d4ac41744
commit
f4c9bc475a
@ -220,7 +220,7 @@ begin
|
|||||||
try
|
try
|
||||||
BuildSubTreeForClass(ClassNode);
|
BuildSubTreeForClass(ClassNode);
|
||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
writeln('[TEventsCodeTool.GetCompatiblePublishedMethods]');
|
writeln('[TEventsCodeTool.GetCompatiblePublishedMethods] D');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// 1. convert the TypeData to an expression type list
|
// 1. convert the TypeData to an expression type list
|
||||||
CheckDependsOnNodeCaches;
|
CheckDependsOnNodeCaches;
|
||||||
@ -241,6 +241,9 @@ begin
|
|||||||
Params.ContextNode:=ClassNode;
|
Params.ContextNode:=ClassNode;
|
||||||
Params.Flags:=[fdfCollect,fdfSearchInAncestors,fdfClassPublished];
|
Params.Flags:=[fdfCollect,fdfSearchInAncestors,fdfClassPublished];
|
||||||
Params.SetIdentifier(Self,nil,@CollectPublishedMethods);
|
Params.SetIdentifier(Self,nil,@CollectPublishedMethods);
|
||||||
|
{$IFDEF CTDEBUG}
|
||||||
|
writeln('[TEventsCodeTool.GetCompatiblePublishedMethods] E Searching ...');
|
||||||
|
{$ENDIF}
|
||||||
FindIdentifierInContext(Params);
|
FindIdentifierInContext(Params);
|
||||||
finally
|
finally
|
||||||
SearchedExprList.Free;
|
SearchedExprList.Free;
|
||||||
@ -675,9 +678,15 @@ var
|
|||||||
ParamCompatibility: TTypeCompatibility;
|
ParamCompatibility: TTypeCompatibility;
|
||||||
FirstParameterNode: TCodeTreeNode;
|
FirstParameterNode: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF CTDEBUG}
|
||||||
|
writeln('[TEventsCodeTool.CollectPublishedMethods] A ',
|
||||||
|
' Node=',FoundContext.Node.DescAsString,
|
||||||
|
' "',copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50),'"',
|
||||||
|
' Tool=',FoundContext.Tool.MainFilename);
|
||||||
|
{$ENDIF}
|
||||||
if (FoundContext.Node.Desc=ctnProcedure) then begin
|
if (FoundContext.Node.Desc=ctnProcedure) then begin
|
||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
writeln('[TEventsCodeTool.CollectPublishedMethods] ',
|
writeln('[TEventsCodeTool.CollectPublishedMethods] B ',
|
||||||
' Node=',FoundContext.Node.DescAsString,
|
' Node=',FoundContext.Node.DescAsString,
|
||||||
' "',copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50),'"',
|
' "',copy(FoundContext.Tool.Src,FoundContext.Node.StartPos,50),'"',
|
||||||
' Tool=',FoundContext.Tool.MainFilename);
|
' Tool=',FoundContext.Tool.MainFilename);
|
||||||
|
@ -58,6 +58,8 @@ interface
|
|||||||
{ $DEFINE ShowNodeCache}
|
{ $DEFINE ShowNodeCache}
|
||||||
{ $DEFINE ShowBaseTypeCache}
|
{ $DEFINE ShowBaseTypeCache}
|
||||||
{ $DEFINE ShowCacheDependencies}
|
{ $DEFINE ShowCacheDependencies}
|
||||||
|
{$DEFINE ShowCollect}
|
||||||
|
|
||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFDEF MEM_CHECK}
|
{$IFDEF MEM_CHECK}
|
||||||
@ -1192,6 +1194,17 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
FindIdentifierInContext:=NewResult;
|
FindIdentifierInContext:=NewResult;
|
||||||
|
{$IFDEF ShowCollect}
|
||||||
|
if fdfCollect in Params.Flags then begin
|
||||||
|
writeln('[TFindDeclarationTool.FindIdentifierInContext] COLLECT CheckResult Ident=',
|
||||||
|
'"',GetIdentifier(Params.Identifier),'"',
|
||||||
|
' File="',ExtractFilename(MainFilename)+'"',
|
||||||
|
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']',
|
||||||
|
' NewResult=',NewResult,
|
||||||
|
' CallOnIdentifierFound=',CallOnIdentifierFound
|
||||||
|
);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
if NewResult then begin
|
if NewResult then begin
|
||||||
// identifier found
|
// identifier found
|
||||||
if CallOnIdentifierFound then begin
|
if CallOnIdentifierFound then begin
|
||||||
@ -1480,8 +1493,19 @@ begin
|
|||||||
' File="',ExtractFilename(MainFilename)+'"',
|
' File="',ExtractFilename(MainFilename)+'"',
|
||||||
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
||||||
);
|
);
|
||||||
|
{$ELSE}
|
||||||
|
{$IFDEF ShowCollect}
|
||||||
|
if fdfCollect in Params.Flags then begin
|
||||||
|
writeln('[TFindDeclarationTool.FindIdentifierInContext] COLLECT Start Ident=',
|
||||||
|
'"',GetIdentifier(Params.Identifier),'"',
|
||||||
|
' Context="',ContextNode.DescAsString,'" "',copy(Src,ContextNode.StartPos,20),'"',
|
||||||
|
' File="',ExtractFilename(MainFilename)+'"',
|
||||||
|
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
||||||
|
);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
try
|
try
|
||||||
// search in the Tree of this tool
|
// search in the Tree of this tool
|
||||||
repeat
|
repeat
|
||||||
@ -1491,6 +1515,16 @@ begin
|
|||||||
' Context="',ContextNode.DescAsString,'" "',copy(Src,ContextNode.StartPos,20),'"',
|
' Context="',ContextNode.DescAsString,'" "',copy(Src,ContextNode.StartPos,20),'"',
|
||||||
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
||||||
);
|
);
|
||||||
|
{$ELSE}
|
||||||
|
{$IFDEF ShowCollect}
|
||||||
|
if fdfCollect in Params.Flags then begin
|
||||||
|
writeln('[TFindDeclarationTool.FindIdentifierInContext] COLLECT Loop Ident=',
|
||||||
|
'"',GetIdentifier(Params.Identifier),'"',
|
||||||
|
' Context="',ContextNode.DescAsString,'" "',copy(Src,ContextNode.StartPos,20),'"',
|
||||||
|
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
||||||
|
);
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// search identifier in current context
|
// search identifier in current context
|
||||||
LastContextNode:=ContextNode;
|
LastContextNode:=ContextNode;
|
||||||
@ -1525,7 +1559,7 @@ begin
|
|||||||
IdentifierFoundResult:=
|
IdentifierFoundResult:=
|
||||||
FindIdentifierInProcContext(ContextNode,Params);
|
FindIdentifierInProcContext(ContextNode,Params);
|
||||||
if IdentifierFoundResult in [ifrAbortSearch,ifrSuccess] then begin
|
if IdentifierFoundResult in [ifrAbortSearch,ifrSuccess] then begin
|
||||||
if CheckResult(IdentifierFoundResult=ifrSuccess,false) then
|
if CheckResult(IdentifierFoundResult=ifrSuccess,true) then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1948,7 +1982,8 @@ begin
|
|||||||
// -> proceed the search normally ...
|
// -> proceed the search normally ...
|
||||||
end else begin
|
end else begin
|
||||||
// proc is a proc declaration
|
// proc is a proc declaration
|
||||||
if CompareSrcIdentifiers(NameAtom.StartPos,Params.Identifier) then begin
|
if (fdfCollect in Params.Flags)
|
||||||
|
or CompareSrcIdentifiers(NameAtom.StartPos,Params.Identifier) then begin
|
||||||
// proc identifier found
|
// proc identifier found
|
||||||
{$IFDEF ShowTriedContexts}
|
{$IFDEF ShowTriedContexts}
|
||||||
writeln('[TFindDeclarationTool.FindIdentifierInProcContext] Proc-Identifier found="',GetIdentifier(Params.Identifier),'"');
|
writeln('[TFindDeclarationTool.FindIdentifierInProcContext] Proc-Identifier found="',GetIdentifier(Params.Identifier),'"');
|
||||||
@ -3947,7 +3982,7 @@ function TFindDeclarationTool.CheckSrcIdentifier(
|
|||||||
Params: TFindDeclarationParams;
|
Params: TFindDeclarationParams;
|
||||||
FoundContext: TFindContext): TIdentifierFoundResult;
|
FoundContext: TFindContext): TIdentifierFoundResult;
|
||||||
// this is a TOnIdentifierFound function
|
// this is a TOnIdentifierFound function
|
||||||
// if identifier found is a proc it searches for the best overloaded proc
|
// if identifier found is a proc then it searches for the best overloaded proc
|
||||||
var FirstParameterNode: TCodeTreeNode;
|
var FirstParameterNode: TCodeTreeNode;
|
||||||
ParamCompatibility: TTypeCompatibility;
|
ParamCompatibility: TTypeCompatibility;
|
||||||
OldInput: TFindDeclarationInput;
|
OldInput: TFindDeclarationInput;
|
||||||
|
@ -134,12 +134,15 @@ type
|
|||||||
Procedure OnFormActivated;
|
Procedure OnFormActivated;
|
||||||
public
|
public
|
||||||
ControlSelection : TControlSelection;
|
ControlSelection : TControlSelection;
|
||||||
constructor Create(Customform : TCustomform; AControlSelection: TControlSelection);
|
constructor Create(Customform : TCustomform;
|
||||||
|
AControlSelection: TControlSelection);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
function IsDesignMsg(Sender: TControl; var TheMessage: TLMessage): Boolean; override;
|
function IsDesignMsg(Sender: TControl;
|
||||||
|
var TheMessage: TLMessage): Boolean; override;
|
||||||
procedure Modified; override;
|
procedure Modified; override;
|
||||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
procedure Notification(AComponent: TComponent;
|
||||||
|
Operation: TOperation); override;
|
||||||
procedure PaintGrid; override;
|
procedure PaintGrid; override;
|
||||||
procedure ValidateRename(AComponent: TComponent;
|
procedure ValidateRename(AComponent: TComponent;
|
||||||
const CurName, NewName: string); override;
|
const CurName, NewName: string); override;
|
||||||
@ -147,6 +150,7 @@ type
|
|||||||
function NonVisualComponentLeftTop(AComponent: TComponent): TPoint;
|
function NonVisualComponentLeftTop(AComponent: TComponent): TPoint;
|
||||||
function NonVisualComponentAtPos(x,y: integer): TComponent;
|
function NonVisualComponentAtPos(x,y: integer): TComponent;
|
||||||
procedure DrawNonVisualComponents(DC: HDC);
|
procedure DrawNonVisualComponents(DC: HDC);
|
||||||
|
function GetDesignedComponent(AComponent: TComponent): TComponent;
|
||||||
|
|
||||||
property ShowGrid: boolean read GetShowGrid write SetShowGrid;
|
property ShowGrid: boolean read GetShowGrid write SetShowGrid;
|
||||||
property Form: TCustomForm read FCustomForm write FCustomForm;
|
property Form: TCustomForm read FCustomForm write FCustomForm;
|
||||||
@ -156,7 +160,8 @@ type
|
|||||||
property IsControl: Boolean read GetIsControl write SetIsControl;
|
property IsControl: Boolean read GetIsControl write SetIsControl;
|
||||||
property OnActivated: TNotifyEvent
|
property OnActivated: TNotifyEvent
|
||||||
read FOnActivated write FOnActivated;
|
read FOnActivated write FOnActivated;
|
||||||
property OnAddComponent: TOnAddComponent read FOnAddComponent write FOnAddComponent;
|
property OnAddComponent: TOnAddComponent
|
||||||
|
read FOnAddComponent write FOnAddComponent;
|
||||||
property OnComponentListChanged: TNotifyEvent
|
property OnComponentListChanged: TNotifyEvent
|
||||||
read FOnComponentListChanged write FOnComponentListChanged;
|
read FOnComponentListChanged write FOnComponentListChanged;
|
||||||
property OnGetSelectedComponentClass: TOnGetSelectedComponentClass
|
property OnGetSelectedComponentClass: TOnGetSelectedComponentClass
|
||||||
@ -168,7 +173,8 @@ type
|
|||||||
read FOnRemoveComponent write FOnRemoveComponent;
|
read FOnRemoveComponent write FOnRemoveComponent;
|
||||||
property OnRenameComponent: TOnRenameComponent
|
property OnRenameComponent: TOnRenameComponent
|
||||||
read FOnRenameComponent write FOnRenameComponent;
|
read FOnRenameComponent write FOnRenameComponent;
|
||||||
property OnSetDesigning: TOnSetDesigning read FOnSetDesigning write FOnSetDesigning;
|
property OnSetDesigning: TOnSetDesigning
|
||||||
|
read FOnSetDesigning write FOnSetDesigning;
|
||||||
property OnUnselectComponentClass: TNotifyEvent
|
property OnUnselectComponentClass: TNotifyEvent
|
||||||
read FOnUnselectComponentClass write FOnUnselectComponentClass;
|
read FOnUnselectComponentClass write FOnUnselectComponentClass;
|
||||||
property OnGetNonVisualCompIconCanvas: TOnGetNonVisualCompIconCanvas
|
property OnGetNonVisualCompIconCanvas: TOnGetNonVisualCompIconCanvas
|
||||||
@ -314,11 +320,13 @@ function TDesigner.PaintControl(Sender: TControl; TheMessage: TLMPaint):boolean;
|
|||||||
var OldDuringPaintControl: boolean;
|
var OldDuringPaintControl: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
|
//writeln('TDesigner.PaintControl A ',Sender.Name);
|
||||||
//writeln('*** LM_PAINT A ',Sender.Name,':',Sender.ClassName,' DC=',HexStr(Message.DC,8));
|
//writeln('*** LM_PAINT A ',Sender.Name,':',Sender.ClassName,' DC=',HexStr(Message.DC,8));
|
||||||
OldDuringPaintControl:=FDuringPaintControl;
|
OldDuringPaintControl:=FDuringPaintControl;
|
||||||
FDuringPaintControl:=true;
|
FDuringPaintControl:=true;
|
||||||
|
//writeln('TDesigner.PaintControl B ',Sender.Name);
|
||||||
Sender.Dispatch(TheMessage);
|
Sender.Dispatch(TheMessage);
|
||||||
|
//writeln('TDesigner.PaintControl C ',Sender.Name);
|
||||||
|
|
||||||
if TheMessage.DC<>0 then begin
|
if TheMessage.DC<>0 then begin
|
||||||
//writeln('*** LM_PAINT B ',Sender.Name,':',Sender.ClassName,' DC=',HexStr(Message.DC,8));
|
//writeln('*** LM_PAINT B ',Sender.Name,':',Sender.ClassName,' DC=',HexStr(Message.DC,8));
|
||||||
@ -332,7 +340,8 @@ begin
|
|||||||
if ControlSelection.RubberBandActive then
|
if ControlSelection.RubberBandActive then
|
||||||
ControlSelection.DrawRubberBand(TheMessage.DC);
|
ControlSelection.DrawRubberBand(TheMessage.DC);
|
||||||
end;
|
end;
|
||||||
|
//writeln('TDesigner.PaintControl D ',Sender.Name);
|
||||||
|
|
||||||
FDuringPaintControl:=OldDuringPaintControl;
|
FDuringPaintControl:=OldDuringPaintControl;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -373,10 +382,12 @@ var i,
|
|||||||
Begin
|
Begin
|
||||||
FHintTimer.Enabled := False;
|
FHintTimer.Enabled := False;
|
||||||
FHasSized:=false;
|
FHasSized:=false;
|
||||||
|
SetCaptureControl(nil);
|
||||||
if (getParentForm(Sender)=nil) then exit;
|
if (getParentForm(Sender)=nil) then exit;
|
||||||
|
|
||||||
if MouseDownComponent=nil then begin
|
if MouseDownComponent=nil then begin
|
||||||
MouseDownComponent:=Sender;
|
MouseDownComponent:=GetDesignedComponent(Sender);
|
||||||
|
if MouseDownComponent=nil then exit;
|
||||||
MouseDownSender:=Sender;
|
MouseDownSender:=Sender;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -486,8 +497,14 @@ var
|
|||||||
Begin
|
Begin
|
||||||
FHintTimer.Enabled := False;
|
FHintTimer.Enabled := False;
|
||||||
|
|
||||||
|
SetCaptureControl(nil);
|
||||||
SenderParentForm:=GetParentForm(Sender);
|
SenderParentForm:=GetParentForm(Sender);
|
||||||
if (MouseDownComponent=nil) or (SenderParentForm=nil) then exit;
|
if (MouseDownComponent=nil) or (SenderParentForm=nil)
|
||||||
|
or (SenderParentForm<>Form) then begin
|
||||||
|
MouseDownComponent:=nil;
|
||||||
|
MouseDownSender:=nil;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
ControlSelection.ActiveGrabber:=nil;
|
ControlSelection.ActiveGrabber:=nil;
|
||||||
RubberBandWasActive:=ControlSelection.RubberBandActive;
|
RubberBandWasActive:=ControlSelection.RubberBandActive;
|
||||||
@ -607,6 +624,7 @@ var
|
|||||||
SenderParentForm:TCustomForm;
|
SenderParentForm:TCustomForm;
|
||||||
OldMouseMovePos: TPoint;
|
OldMouseMovePos: TPoint;
|
||||||
begin
|
begin
|
||||||
|
SetCaptureControl(nil);
|
||||||
if FShowHints then begin
|
if FShowHints then begin
|
||||||
FHintTimer.Enabled := False;
|
FHintTimer.Enabled := False;
|
||||||
|
|
||||||
@ -619,7 +637,7 @@ begin
|
|||||||
|
|
||||||
if MouseDownComponent=nil then exit;
|
if MouseDownComponent=nil then exit;
|
||||||
SenderParentForm:=GetParentForm(Sender);
|
SenderParentForm:=GetParentForm(Sender);
|
||||||
if SenderParentForm=nil then exit;
|
if (SenderParentForm=nil) or (SenderParentForm<>Form) then exit;
|
||||||
|
|
||||||
OldMouseMovePos:=LastMouseMovePos;
|
OldMouseMovePos:=LastMouseMovePos;
|
||||||
LastMouseMovePos:=GetFormRelativeMousePosition(Form);
|
LastMouseMovePos:=GetFormRelativeMousePosition(Form);
|
||||||
@ -677,6 +695,7 @@ procedure TDesigner.MouseRightUpOnControl(Sender : TControl;
|
|||||||
TheMessage: TLMMouse);
|
TheMessage: TLMMouse);
|
||||||
begin
|
begin
|
||||||
FHintTimer.Enabled := False;
|
FHintTimer.Enabled := False;
|
||||||
|
SetCaptureControl(nil);
|
||||||
|
|
||||||
MouseUpPos:=GetFormRelativeMousePosition(Form);
|
MouseUpPos:=GetFormRelativeMousePosition(Form);
|
||||||
BuildPopupMenu;
|
BuildPopupMenu;
|
||||||
@ -967,6 +986,15 @@ begin
|
|||||||
RestoreDC(DC,SaveIndex);
|
RestoreDC(DC,SaveIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDesigner.GetDesignedComponent(AComponent: TComponent): TComponent;
|
||||||
|
begin
|
||||||
|
Result:=AComponent;
|
||||||
|
while (Result<>nil)
|
||||||
|
and (Result.Owner<>Form)
|
||||||
|
and (Result is TControl) do
|
||||||
|
Result:=TControl(Result).Parent;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDesigner.NonVisualComponentAtPos(x,y: integer): TComponent;
|
function TDesigner.NonVisualComponentAtPos(x,y: integer): TComponent;
|
||||||
var i: integer;
|
var i: integer;
|
||||||
LeftTop: TPoint;
|
LeftTop: TPoint;
|
||||||
|
Loading…
Reference in New Issue
Block a user