From 7625688d59f33eaf4eb75c75a0a2749e50877f83 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 6 Oct 2015 17:38:06 +0000 Subject: [PATCH] cody: find overloads: add nodes for classes and ancestors git-svn-id: trunk@49959 - --- components/codetools/finddeclarationtool.pas | 4 +- .../codetools/ide/codyfindoverloads.pas | 57 ++++++++++++++----- .../languages/printer4lazstrconst.de.po | 4 -- .../printers/languages/printer4lazstrconst.po | 4 -- .../languages/printer4lazstrconst.ru.po | 5 +- 5 files changed, 46 insertions(+), 28 deletions(-) diff --git a/components/codetools/finddeclarationtool.pas b/components/codetools/finddeclarationtool.pas index 568ade82d9..4b6f40a371 100644 --- a/components/codetools/finddeclarationtool.pas +++ b/components/codetools/finddeclarationtool.pas @@ -885,7 +885,7 @@ type // ancestors function FindClassAndAncestors(ClassNode: TCodeTreeNode; out ListOfPFindContext: TFPList; ExceptionOnNotFound: boolean - ): boolean; // without interfaces + ): boolean; // without interfaces, recursive function FindContextClassAndAncestors(const CursorPos: TCodeXYPosition; var ListOfPFindContext: TFPList): boolean; // without interfaces function FindAncestorOfClass(ClassNode: TCodeTreeNode; @@ -897,7 +897,7 @@ type function FindAncestorsOfClass(ClassNode: TCodeTreeNode; var ListOfPFindContext: TFPList; Params: TFindDeclarationParams; FindClassContext: boolean; - ExceptionOnNotFound: boolean = true): boolean; // with interfaces + ExceptionOnNotFound: boolean = true): boolean; // with interfaces, not recursive function FindExtendedExprOfHelper(HelperNode: TCodeTreeNode): TExpressionType; diff --git a/components/codetools/ide/codyfindoverloads.pas b/components/codetools/ide/codyfindoverloads.pas index 26447ce5f2..700d02cbb4 100644 --- a/components/codetools/ide/codyfindoverloads.pas +++ b/components/codetools/ide/codyfindoverloads.pas @@ -316,16 +316,54 @@ end; procedure TCodyFindOverloadsWindow.GatherProcsOfUnit(NodeGraph: TCodeGraph; ProgNode: TCodeTreeNode; CurUnit: TCFOUnit); - procedure AddAncestors(Tool: TFindDeclarationTool; ClassNode: TCodeTreeNode); - begin + procedure AddAncestors(Tool: TFindDeclarationTool; ClassNode: TCodeTreeNode); forward; + 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; var Tool: TStandardCodeTool; ProcNode, ClassNode: TCodeTreeNode; CurProcName: String; - GraphProcNode, GraphClassNode: TCFONode; + GraphProcNode: TCFONode; Edge: TCFOEdge; begin if ugufLoadError in CurUnit.Flags then exit; @@ -347,15 +385,10 @@ begin ClassNode:=ClassNode.Parent; end; if ClassNode<>nil then begin - GraphClassNode:=TCFONode(NodeGraph.AddGraphNode(ClassNode)); - GraphClassNode.Tool:=Tool; + AddClassNode(Tool,ClassNode); // create edge "is method of" Edge:=TCFOEdge(NodeGraph.AddEdge(ProcNode,ClassNode)); 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 // not a method // create edge "reachable", so that all nodes are reachable @@ -384,7 +417,6 @@ var sl: TStringList; ClassNode: TCodeTreeNode; ListOfPFindContext: TFPList; - Params: TFindDeclarationParams; i: Integer; aContext: PFindContext; begin @@ -398,10 +430,8 @@ begin // method sl.Add('Only descendants of '+ProcTool.ExtractClassName(ClassNode,false)); ListOfPFindContext:=nil; - Params:=TFindDeclarationParams.Create(nil); try - ProcTool.FindAncestorsOfClass(ClassNode,ListOfPFindContext,Params, - false,false); + ProcTool.FindClassAndAncestors(ClassNode,ListOfPFindContext,false); if ListOfPFindContext<>nil then begin for i:=0 to ListOfPFindContext.Count-1 do begin aContext:=PFindContext(ListOfPFindContext[i]); @@ -409,7 +439,6 @@ begin end; end; finally - Params.Free; FreeListOfPFindContext(ListOfPFindContext); end; sl.Add('Only methods'); diff --git a/components/printers/languages/printer4lazstrconst.de.po b/components/printers/languages/printer4lazstrconst.de.po index 473066520d..8edc40600d 100644 --- a/components/printers/languages/printer4lazstrconst.de.po +++ b/components/printers/languages/printer4lazstrconst.de.po @@ -68,10 +68,6 @@ msgstr "Papiertyp" msgid "Portrait" msgstr "Hochformat" -#: printer4lazstrconst.p4lrsprinterproperties -msgid "Printer properties" -msgstr "" - #: printer4lazstrconst.p4lrsresolution msgid "Resolution" msgstr "Auflösung" diff --git a/components/printers/languages/printer4lazstrconst.po b/components/printers/languages/printer4lazstrconst.po index 6dd933dbab..cd5f51b386 100644 --- a/components/printers/languages/printer4lazstrconst.po +++ b/components/printers/languages/printer4lazstrconst.po @@ -57,10 +57,6 @@ msgstr "" msgid "Portrait" msgstr "" -#: printer4lazstrconst.p4lrsprinterproperties -msgid "Printer properties" -msgstr "" - #: printer4lazstrconst.p4lrsresolution msgid "Resolution" msgstr "" diff --git a/components/printers/languages/printer4lazstrconst.ru.po b/components/printers/languages/printer4lazstrconst.ru.po index 437311c042..4ba96aac15 100644 --- a/components/printers/languages/printer4lazstrconst.ru.po +++ b/components/printers/languages/printer4lazstrconst.ru.po @@ -67,10 +67,6 @@ msgstr "Тип бумаги" msgid "Portrait" msgstr "Книжная" -#: printer4lazstrconst.p4lrsprinterproperties -msgid "Printer properties" -msgstr "Свойства принтера" - #: printer4lazstrconst.p4lrsresolution msgid "Resolution" msgstr "Разрешение" @@ -86,3 +82,4 @@ msgstr "Обратная книжная" #: printer4lazstrconst.p4lrsstart msgid "Start" msgstr "Верхний" +