mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 02:59:06 +02:00
cody: find overloads: add nodes for classes and ancestors
git-svn-id: trunk@49959 -
This commit is contained in:
parent
65957ee8b5
commit
7625688d59
@ -885,7 +885,7 @@ type
|
|||||||
// ancestors
|
// ancestors
|
||||||
function FindClassAndAncestors(ClassNode: TCodeTreeNode;
|
function FindClassAndAncestors(ClassNode: TCodeTreeNode;
|
||||||
out ListOfPFindContext: TFPList; ExceptionOnNotFound: boolean
|
out ListOfPFindContext: TFPList; ExceptionOnNotFound: boolean
|
||||||
): boolean; // without interfaces
|
): boolean; // without interfaces, recursive
|
||||||
function FindContextClassAndAncestors(const CursorPos: TCodeXYPosition;
|
function FindContextClassAndAncestors(const CursorPos: TCodeXYPosition;
|
||||||
var ListOfPFindContext: TFPList): boolean; // without interfaces
|
var ListOfPFindContext: TFPList): boolean; // without interfaces
|
||||||
function FindAncestorOfClass(ClassNode: TCodeTreeNode;
|
function FindAncestorOfClass(ClassNode: TCodeTreeNode;
|
||||||
@ -897,7 +897,7 @@ type
|
|||||||
function FindAncestorsOfClass(ClassNode: TCodeTreeNode;
|
function FindAncestorsOfClass(ClassNode: TCodeTreeNode;
|
||||||
var ListOfPFindContext: TFPList;
|
var ListOfPFindContext: TFPList;
|
||||||
Params: TFindDeclarationParams; FindClassContext: boolean;
|
Params: TFindDeclarationParams; FindClassContext: boolean;
|
||||||
ExceptionOnNotFound: boolean = true): boolean; // with interfaces
|
ExceptionOnNotFound: boolean = true): boolean; // with interfaces, not recursive
|
||||||
|
|
||||||
function FindExtendedExprOfHelper(HelperNode: TCodeTreeNode): TExpressionType;
|
function FindExtendedExprOfHelper(HelperNode: TCodeTreeNode): TExpressionType;
|
||||||
|
|
||||||
|
@ -316,16 +316,54 @@ end;
|
|||||||
procedure TCodyFindOverloadsWindow.GatherProcsOfUnit(NodeGraph: TCodeGraph;
|
procedure TCodyFindOverloadsWindow.GatherProcsOfUnit(NodeGraph: TCodeGraph;
|
||||||
ProgNode: TCodeTreeNode; CurUnit: TCFOUnit);
|
ProgNode: TCodeTreeNode; CurUnit: TCFOUnit);
|
||||||
|
|
||||||
procedure AddAncestors(Tool: TFindDeclarationTool; ClassNode: TCodeTreeNode);
|
procedure AddAncestors(Tool: TFindDeclarationTool; ClassNode: TCodeTreeNode); forward;
|
||||||
begin
|
|
||||||
|
|
||||||
|
function AddClassNode(Tool: TFindDeclarationTool; ClassNode: TCodeTreeNode): TCFONode;
|
||||||
|
var
|
||||||
|
Edge: TCFOEdge;
|
||||||
|
begin
|
||||||
|
if ClassNode=nil then
|
||||||
|
RaiseCatchableException('');
|
||||||
|
Result:=TCFONode(NodeGraph.GetGraphNode(ClassNode,false));
|
||||||
|
if Result<>nil then exit;
|
||||||
|
debugln(['AddClassNode ',Tool.ExtractClassName(ClassNode,false)]);
|
||||||
|
Result:=TCFONode(NodeGraph.AddGraphNode(ClassNode));
|
||||||
|
Result.Tool:=Tool;
|
||||||
|
// create edge "reachable", so that all nodes are reachable
|
||||||
|
Edge:=TCFOEdge(NodeGraph.AddEdge(ClassNode,ProgNode));
|
||||||
|
Edge.Typ:=cfoetReachable;
|
||||||
|
AddAncestors(Tool,ClassNode);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddAncestors(Tool: TFindDeclarationTool; ClassNode: TCodeTreeNode);
|
||||||
|
var
|
||||||
|
ListOfPFindContext: TFPList;
|
||||||
|
Params: TFindDeclarationParams;
|
||||||
|
Context: PFindContext;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
debugln(['AddAncestors ',Tool.ExtractClassName(ClassNode,false)]);
|
||||||
|
ListOfPFindContext:=nil;
|
||||||
|
Params:=TFindDeclarationParams.Create(nil);
|
||||||
|
try
|
||||||
|
Tool.FindAncestorsOfClass(ClassNode,ListOfPFindContext,Params,true,false);
|
||||||
|
if ListOfPFindContext<>nil then begin
|
||||||
|
for i:=0 to ListOfPFindContext.Count-1 do begin
|
||||||
|
Context:=PFindContext(ListOfPFindContext[i]);
|
||||||
|
AddClassNode(Context^.Tool,Context^.Node);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Params.Free;
|
||||||
|
FreeListOfPFindContext(ListOfPFindContext);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Tool: TStandardCodeTool;
|
Tool: TStandardCodeTool;
|
||||||
ProcNode, ClassNode: TCodeTreeNode;
|
ProcNode, ClassNode: TCodeTreeNode;
|
||||||
CurProcName: String;
|
CurProcName: String;
|
||||||
GraphProcNode, GraphClassNode: TCFONode;
|
GraphProcNode: TCFONode;
|
||||||
Edge: TCFOEdge;
|
Edge: TCFOEdge;
|
||||||
begin
|
begin
|
||||||
if ugufLoadError in CurUnit.Flags then exit;
|
if ugufLoadError in CurUnit.Flags then exit;
|
||||||
@ -347,15 +385,10 @@ begin
|
|||||||
ClassNode:=ClassNode.Parent;
|
ClassNode:=ClassNode.Parent;
|
||||||
end;
|
end;
|
||||||
if ClassNode<>nil then begin
|
if ClassNode<>nil then begin
|
||||||
GraphClassNode:=TCFONode(NodeGraph.AddGraphNode(ClassNode));
|
AddClassNode(Tool,ClassNode);
|
||||||
GraphClassNode.Tool:=Tool;
|
|
||||||
// create edge "is method of"
|
// create edge "is method of"
|
||||||
Edge:=TCFOEdge(NodeGraph.AddEdge(ProcNode,ClassNode));
|
Edge:=TCFOEdge(NodeGraph.AddEdge(ProcNode,ClassNode));
|
||||||
Edge.Typ:=cfoetMethodOf;
|
Edge.Typ:=cfoetMethodOf;
|
||||||
// create edge "reachable", so that all nodes are reachable
|
|
||||||
Edge:=TCFOEdge(NodeGraph.AddEdge(ClassNode,ProgNode));
|
|
||||||
Edge.Typ:=cfoetReachable;
|
|
||||||
AddAncestors(Tool,ClassNode);
|
|
||||||
end else begin
|
end else begin
|
||||||
// not a method
|
// not a method
|
||||||
// create edge "reachable", so that all nodes are reachable
|
// create edge "reachable", so that all nodes are reachable
|
||||||
@ -384,7 +417,6 @@ var
|
|||||||
sl: TStringList;
|
sl: TStringList;
|
||||||
ClassNode: TCodeTreeNode;
|
ClassNode: TCodeTreeNode;
|
||||||
ListOfPFindContext: TFPList;
|
ListOfPFindContext: TFPList;
|
||||||
Params: TFindDeclarationParams;
|
|
||||||
i: Integer;
|
i: Integer;
|
||||||
aContext: PFindContext;
|
aContext: PFindContext;
|
||||||
begin
|
begin
|
||||||
@ -398,10 +430,8 @@ begin
|
|||||||
// method
|
// method
|
||||||
sl.Add('Only descendants of '+ProcTool.ExtractClassName(ClassNode,false));
|
sl.Add('Only descendants of '+ProcTool.ExtractClassName(ClassNode,false));
|
||||||
ListOfPFindContext:=nil;
|
ListOfPFindContext:=nil;
|
||||||
Params:=TFindDeclarationParams.Create(nil);
|
|
||||||
try
|
try
|
||||||
ProcTool.FindAncestorsOfClass(ClassNode,ListOfPFindContext,Params,
|
ProcTool.FindClassAndAncestors(ClassNode,ListOfPFindContext,false);
|
||||||
false,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
|
||||||
aContext:=PFindContext(ListOfPFindContext[i]);
|
aContext:=PFindContext(ListOfPFindContext[i]);
|
||||||
@ -409,7 +439,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Params.Free;
|
|
||||||
FreeListOfPFindContext(ListOfPFindContext);
|
FreeListOfPFindContext(ListOfPFindContext);
|
||||||
end;
|
end;
|
||||||
sl.Add('Only methods');
|
sl.Add('Only methods');
|
||||||
|
@ -68,10 +68,6 @@ msgstr "Papiertyp"
|
|||||||
msgid "Portrait"
|
msgid "Portrait"
|
||||||
msgstr "Hochformat"
|
msgstr "Hochformat"
|
||||||
|
|
||||||
#: printer4lazstrconst.p4lrsprinterproperties
|
|
||||||
msgid "Printer properties"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: printer4lazstrconst.p4lrsresolution
|
#: printer4lazstrconst.p4lrsresolution
|
||||||
msgid "Resolution"
|
msgid "Resolution"
|
||||||
msgstr "Auflösung"
|
msgstr "Auflösung"
|
||||||
|
@ -57,10 +57,6 @@ msgstr ""
|
|||||||
msgid "Portrait"
|
msgid "Portrait"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: printer4lazstrconst.p4lrsprinterproperties
|
|
||||||
msgid "Printer properties"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: printer4lazstrconst.p4lrsresolution
|
#: printer4lazstrconst.p4lrsresolution
|
||||||
msgid "Resolution"
|
msgid "Resolution"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -67,10 +67,6 @@ msgstr "Тип бумаги"
|
|||||||
msgid "Portrait"
|
msgid "Portrait"
|
||||||
msgstr "Книжная"
|
msgstr "Книжная"
|
||||||
|
|
||||||
#: printer4lazstrconst.p4lrsprinterproperties
|
|
||||||
msgid "Printer properties"
|
|
||||||
msgstr "Свойства принтера"
|
|
||||||
|
|
||||||
#: printer4lazstrconst.p4lrsresolution
|
#: printer4lazstrconst.p4lrsresolution
|
||||||
msgid "Resolution"
|
msgid "Resolution"
|
||||||
msgstr "Разрешение"
|
msgstr "Разрешение"
|
||||||
@ -86,3 +82,4 @@ msgstr "Обратная книжная"
|
|||||||
#: printer4lazstrconst.p4lrsstart
|
#: printer4lazstrconst.p4lrsstart
|
||||||
msgid "Start"
|
msgid "Start"
|
||||||
msgstr "Верхний"
|
msgstr "Верхний"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user