mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-24 16:39:50 +02:00
cody: find overloads: filter for abstract methods
git-svn-id: trunk@49961 -
This commit is contained in:
parent
754104aaa7
commit
b0eac4a317
@ -108,7 +108,7 @@ type
|
|||||||
procedure AddStartAndTargetUnits;
|
procedure AddStartAndTargetUnits;
|
||||||
procedure GatherProcsOfAllUnits;
|
procedure GatherProcsOfAllUnits;
|
||||||
procedure GatherProcsOfUnit(NodeGraph: TCodeGraph; ProgNode: TCodeTreeNode;
|
procedure GatherProcsOfUnit(NodeGraph: TCodeGraph; ProgNode: TCodeTreeNode;
|
||||||
CurUnit: TCFOUnit);
|
CurUnit: TCFOUnit; ExcludeAbstractProcs: boolean);
|
||||||
procedure FreeUsesGraph;
|
procedure FreeUsesGraph;
|
||||||
function GetDefaultCaption: string;
|
function GetDefaultCaption: string;
|
||||||
procedure FillFilterControls(ProcTool: TFindDeclarationTool;
|
procedure FillFilterControls(ProcTool: TFindDeclarationTool;
|
||||||
@ -289,12 +289,14 @@ var
|
|||||||
CurUnit: TCFOUnit;
|
CurUnit: TCFOUnit;
|
||||||
NodeGraph: TCodeGraph;
|
NodeGraph: TCodeGraph;
|
||||||
ProgNode: TCodeTreeNode;
|
ProgNode: TCodeTreeNode;
|
||||||
|
ExcludeAbstractProcs: Boolean;
|
||||||
begin
|
begin
|
||||||
if FUsesGraph=nil then begin
|
|
||||||
Exclude(FFlags,cfofGatherProcs);
|
Exclude(FFlags,cfofGatherProcs);
|
||||||
|
if FUsesGraph=nil then
|
||||||
exit;
|
exit;
|
||||||
end;
|
|
||||||
debugln(['TCodyFindOverloadsWindow.GatherProcsOfAllUnits START']);
|
debugln(['TCodyFindOverloadsWindow.GatherProcsOfAllUnits START']);
|
||||||
|
|
||||||
|
ExcludeAbstractProcs:=HideAbstractCheckBox.Checked;
|
||||||
ProgNode:=TCodeTreeNode.Create;
|
ProgNode:=TCodeTreeNode.Create;
|
||||||
NodeGraph:=TCodeGraph.Create(TCFONode,TCFOEdge);
|
NodeGraph:=TCodeGraph.Create(TCFONode,TCFOEdge);
|
||||||
try
|
try
|
||||||
@ -303,7 +305,7 @@ begin
|
|||||||
FileNode:=FUsesGraph.FilesTree.FindLowest;
|
FileNode:=FUsesGraph.FilesTree.FindLowest;
|
||||||
while FileNode<>nil do begin
|
while FileNode<>nil do begin
|
||||||
CurUnit:=TCFOUnit(FileNode.Data);
|
CurUnit:=TCFOUnit(FileNode.Data);
|
||||||
GatherProcsOfUnit(NodeGraph,ProgNode,CurUnit);
|
GatherProcsOfUnit(NodeGraph,ProgNode,CurUnit,ExcludeAbstractProcs);
|
||||||
FileNode:=FUsesGraph.FilesTree.FindSuccessor(FileNode);
|
FileNode:=FUsesGraph.FilesTree.FindSuccessor(FileNode);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
@ -314,7 +316,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCodyFindOverloadsWindow.GatherProcsOfUnit(NodeGraph: TCodeGraph;
|
procedure TCodyFindOverloadsWindow.GatherProcsOfUnit(NodeGraph: TCodeGraph;
|
||||||
ProgNode: TCodeTreeNode; CurUnit: TCFOUnit);
|
ProgNode: TCodeTreeNode; CurUnit: TCFOUnit; ExcludeAbstractProcs: boolean);
|
||||||
|
|
||||||
procedure AddAncestors(Tool: TFindDeclarationTool; ClassNode: TCodeTreeNode); forward;
|
procedure AddAncestors(Tool: TFindDeclarationTool; ClassNode: TCodeTreeNode); forward;
|
||||||
|
|
||||||
@ -339,8 +341,9 @@ procedure TCodyFindOverloadsWindow.GatherProcsOfUnit(NodeGraph: TCodeGraph;
|
|||||||
var
|
var
|
||||||
ListOfPFindContext: TFPList;
|
ListOfPFindContext: TFPList;
|
||||||
Params: TFindDeclarationParams;
|
Params: TFindDeclarationParams;
|
||||||
Context: PFindContext;
|
Ancestor: PFindContext;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
Edge: TCFOEdge;
|
||||||
begin
|
begin
|
||||||
debugln(['AddAncestors ',Tool.ExtractClassName(ClassNode,false)]);
|
debugln(['AddAncestors ',Tool.ExtractClassName(ClassNode,false)]);
|
||||||
ListOfPFindContext:=nil;
|
ListOfPFindContext:=nil;
|
||||||
@ -349,8 +352,11 @@ procedure TCodyFindOverloadsWindow.GatherProcsOfUnit(NodeGraph: TCodeGraph;
|
|||||||
Tool.FindAncestorsOfClass(ClassNode,ListOfPFindContext,Params,true,false);
|
Tool.FindAncestorsOfClass(ClassNode,ListOfPFindContext,Params,true,false);
|
||||||
if ListOfPFindContext<>nil then begin
|
if ListOfPFindContext<>nil then begin
|
||||||
for i:=0 to ListOfPFindContext.Count-1 do begin
|
for i:=0 to ListOfPFindContext.Count-1 do begin
|
||||||
Context:=PFindContext(ListOfPFindContext[i]);
|
Ancestor:=PFindContext(ListOfPFindContext[i]);
|
||||||
AddClassNode(Context^.Tool,Context^.Node);
|
AddClassNode(Ancestor^.Tool,Ancestor^.Node);
|
||||||
|
// create edge "descendant of"
|
||||||
|
Edge:=TCFOEdge(NodeGraph.AddEdge(ClassNode,Ancestor^.Node));
|
||||||
|
Edge.Typ:=cfoetDescendantOf;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
@ -359,32 +365,40 @@ procedure TCodyFindOverloadsWindow.GatherProcsOfUnit(NodeGraph: TCodeGraph;
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure AddProcNode(Tool: TFindDeclarationTool; ProcNode: TCodeTreeNode);
|
||||||
var
|
var
|
||||||
Tool: TStandardCodeTool;
|
|
||||||
ProcNode, ClassNode: TCodeTreeNode;
|
|
||||||
CurProcName: String;
|
CurProcName: String;
|
||||||
GraphProcNode: TCFONode;
|
GraphProcNode: TCFONode;
|
||||||
|
ClassNode: TCodeTreeNode;
|
||||||
Edge: TCFOEdge;
|
Edge: TCFOEdge;
|
||||||
begin
|
begin
|
||||||
if ugufLoadError in CurUnit.Flags then exit;
|
// check name
|
||||||
if not (ugufReached in CurUnit.Flags) then exit; // this unit was not reached
|
|
||||||
if ugufIsIncludeFile in CurUnit.Flags then exit;
|
|
||||||
Tool:=CurUnit.Tool;
|
|
||||||
ProcNode:=Tool.Tree.Root;
|
|
||||||
while ProcNode<>nil do begin
|
|
||||||
if ProcNode.Desc in [ctnImplementation,ctnBeginBlock] then break;
|
|
||||||
if ProcNode.Desc=ctnProcedure then begin
|
|
||||||
CurProcName:=Tool.ExtractProcName(ProcNode,[phpWithoutClassName]);
|
CurProcName:=Tool.ExtractProcName(ProcNode,[phpWithoutClassName]);
|
||||||
if CompareIdentifiers(PChar(CurProcName),PChar(FTargetName))=0 then begin
|
if CompareIdentifiers(PChar(CurProcName),PChar(FTargetName))<>0 then exit;
|
||||||
|
|
||||||
debugln(['TCodyFindOverloadsWindow.GatherProcsOfUnit ',Tool.CleanPosToStr(ProcNode.StartPos,true)]);
|
debugln(['TCodyFindOverloadsWindow.GatherProcsOfUnit ',Tool.CleanPosToStr(ProcNode.StartPos,true)]);
|
||||||
GraphProcNode:=TCFONode(NodeGraph.AddGraphNode(ProcNode));
|
|
||||||
GraphProcNode.Tool:=Tool;
|
// check if method
|
||||||
ClassNode:=ProcNode.Parent;
|
ClassNode:=ProcNode.Parent;
|
||||||
while ClassNode<>nil do begin
|
while ClassNode<>nil do begin
|
||||||
if ClassNode.Desc in AllClasses then break;
|
if ClassNode.Desc in AllClasses then break;
|
||||||
ClassNode:=ClassNode.Parent;
|
ClassNode:=ClassNode.Parent;
|
||||||
end;
|
end;
|
||||||
if ClassNode<>nil then begin
|
if ClassNode<>nil then begin
|
||||||
|
if ExcludeAbstractProcs then begin
|
||||||
|
if ClassNode.Desc in AllClassInterfaces then exit;
|
||||||
|
if Tool.ProcNodeHasSpecifier(ProcNode,psABSTRACT) then exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// ToDo: check param compatibility
|
||||||
|
|
||||||
|
// add node
|
||||||
|
GraphProcNode:=TCFONode(NodeGraph.AddGraphNode(ProcNode));
|
||||||
|
GraphProcNode.Tool:=Tool;
|
||||||
|
|
||||||
|
// add edges
|
||||||
|
if ClassNode<>nil then begin
|
||||||
|
// create nodes for class and ancestors
|
||||||
AddClassNode(Tool,ClassNode);
|
AddClassNode(Tool,ClassNode);
|
||||||
// create edge "is method of"
|
// create edge "is method of"
|
||||||
Edge:=TCFOEdge(NodeGraph.AddEdge(ProcNode,ClassNode));
|
Edge:=TCFOEdge(NodeGraph.AddEdge(ProcNode,ClassNode));
|
||||||
@ -396,7 +410,20 @@ begin
|
|||||||
Edge.Typ:=cfoetReachable;
|
Edge.Typ:=cfoetReachable;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
var
|
||||||
|
Tool: TStandardCodeTool;
|
||||||
|
ProcNode: TCodeTreeNode;
|
||||||
|
begin
|
||||||
|
if ugufLoadError in CurUnit.Flags then exit;
|
||||||
|
if not (ugufReached in CurUnit.Flags) then exit; // this unit was not reached
|
||||||
|
if ugufIsIncludeFile in CurUnit.Flags then exit;
|
||||||
|
Tool:=CurUnit.Tool;
|
||||||
|
ProcNode:=Tool.Tree.Root;
|
||||||
|
while ProcNode<>nil do begin
|
||||||
|
if ProcNode.Desc in [ctnImplementation,ctnBeginBlock] then break;
|
||||||
|
if ProcNode.Desc=ctnProcedure then
|
||||||
|
AddProcNode(Tool,ProcNode);
|
||||||
ProcNode:=ProcNode.Next;
|
ProcNode:=ProcNode.Next;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user