mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 12:20:28 +02:00
* Added ability to create class chart
git-svn-id: trunk@23194 -
This commit is contained in:
parent
2c26d53f9b
commit
bc60ea4713
@ -201,6 +201,8 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TPasExternalClassType = Class(TPasClassType);
|
||||||
|
TPasExternalModule = Class(TPasModule);
|
||||||
|
|
||||||
{ Link entry tree
|
{ Link entry tree
|
||||||
TFPDocEngine stores the root of the entry tree in its property
|
TFPDocEngine stores the root of the entry tree in its property
|
||||||
@ -738,7 +740,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if not CreateNew then
|
if not CreateNew then
|
||||||
exit;
|
exit;
|
||||||
Module := TPasModule.Create(s, HPackage);
|
Module := TPasExternalModule.Create(s, HPackage);
|
||||||
Module.InterfaceSection := TInterfaceSection.Create('', Module);
|
Module.InterfaceSection := TInterfaceSection.Create('', Module);
|
||||||
HPackage.Modules.Add(Module);
|
HPackage.Modules.Add(Module);
|
||||||
end;
|
end;
|
||||||
@ -799,7 +801,7 @@ var
|
|||||||
begin
|
begin
|
||||||
s:= ResolvePackageModule(AName,HPackage,Module,True);
|
s:= ResolvePackageModule(AName,HPackage,Module,True);
|
||||||
// Create node for class
|
// Create node for class
|
||||||
Result := TPasClassType.Create(s, Module.InterfaceSection);
|
Result := TPasExternalClassType.Create(s, Module.InterfaceSection);
|
||||||
Result.ObjKind := okClass;
|
Result.ObjKind := okClass;
|
||||||
Module.InterfaceSection.Declarations.Add(Result);
|
Module.InterfaceSection.Declarations.Add(Result);
|
||||||
Module.InterfaceSection.Classes.Add(Result);
|
Module.InterfaceSection.Classes.Add(Result);
|
||||||
|
@ -2395,7 +2395,7 @@ procedure THTMLWriter.CreateClassHierarchyPage(AList : TStringList; AddUnit : Bo
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
AppendText(CurOutputNode,P.Name);
|
AppendText(CurOutputNode,EN);
|
||||||
LL:=TStringList.Create;
|
LL:=TStringList.Create;
|
||||||
try
|
try
|
||||||
N:=E.FirstChild;
|
N:=E.FirstChild;
|
||||||
@ -2480,7 +2480,8 @@ begin
|
|||||||
For I:=0 to Package.Modules.Count-1 do
|
For I:=0 to Package.Modules.Count-1 do
|
||||||
begin
|
begin
|
||||||
M:=TPasModule(Package.Modules[i]);
|
M:=TPasModule(Package.Modules[i]);
|
||||||
Self.AddElementsFromList(L,M.InterfaceSection.Classes,True)
|
if Not (M is TPasExternalModule) then
|
||||||
|
Self.AddElementsFromList(L,M.InterfaceSection.Classes,True)
|
||||||
end;
|
end;
|
||||||
AppendMenuBar(ClassHierarchySubIndex);
|
AppendMenuBar(ClassHierarchySubIndex);
|
||||||
S:=Package.Name;
|
S:=Package.Name;
|
||||||
|
@ -18,7 +18,7 @@ Type
|
|||||||
Protected
|
Protected
|
||||||
function LookForElement(PE: TDomElement; AElement: TPasElement): TDomNode;
|
function LookForElement(PE: TDomElement; AElement: TPasElement): TDomNode;
|
||||||
function NodeMatch(N: TDomNode; AElement: TPasElement): Boolean;
|
function NodeMatch(N: TDomNode; AElement: TPasElement): Boolean;
|
||||||
Function AddToClassTree(AElement : TPasElement; Var ACount : Integer) : TDomElement;
|
Function AddToClassTree(AElement : TPasElement; ACount : Integer) : TDomElement;
|
||||||
Public
|
Public
|
||||||
Constructor Create(APackage : TPasPackage; AObjectKind : TPasObjKind = okClass);
|
Constructor Create(APackage : TPasPackage; AObjectKind : TPasObjKind = okClass);
|
||||||
Destructor Destroy; override;
|
Destructor Destroy; override;
|
||||||
@ -74,14 +74,18 @@ end;
|
|||||||
Function TClassTreeBuilder.NodeMatch(N : TDomNode; AElement : TPasElement) : Boolean;
|
Function TClassTreeBuilder.NodeMatch(N : TDomNode; AElement : TPasElement) : Boolean;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
S : String;
|
PN,S : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=(N.NodeType=ELEMENT_NODE);
|
Result:=(N.NodeType=ELEMENT_NODE);
|
||||||
if Result then
|
if Result then
|
||||||
begin
|
begin
|
||||||
S:=N.NodeName;
|
S:=N.NodeName;
|
||||||
S:=FPackage.Name+'.'+TDomElement(N)['unit']+'.'+S;
|
IF Assigned(Aelement.GetModule) then
|
||||||
|
PN:=Aelement.GetModule.PackageName
|
||||||
|
else
|
||||||
|
PN:=FPackage.Name;
|
||||||
|
S:='#'+PN+'.'+TDomElement(N)['unit']+S;
|
||||||
Result:= (CompareText(S,AElement.PathName)=0)
|
Result:= (CompareText(S,AElement.PathName)=0)
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -96,20 +100,21 @@ begin
|
|||||||
While (Result<>Nil) and Not NodeMatch(Result,AElement) do
|
While (Result<>Nil) and Not NodeMatch(Result,AElement) do
|
||||||
Result:=Result.NextSibling;
|
Result:=Result.NextSibling;
|
||||||
If (Result=Nil) then
|
If (Result=Nil) then
|
||||||
begin
|
if Assigned(PE) then
|
||||||
N:=PE.FirstChild;
|
|
||||||
While (Result=Nil) and (N<>Nil) do
|
|
||||||
begin
|
begin
|
||||||
if (N.NodeType=ELEMENT_NODE) then
|
N:=PE.FirstChild;
|
||||||
|
While (Result=Nil) and (N<>Nil) do
|
||||||
begin
|
begin
|
||||||
Result:=LookForElement(N as TDomElement,AElement);
|
if (N.NodeType=ELEMENT_NODE) then
|
||||||
|
begin
|
||||||
|
Result:=LookForElement(N as TDomElement,AElement);
|
||||||
|
end;
|
||||||
|
N:=N.NextSibling;
|
||||||
end;
|
end;
|
||||||
N:=N.NextSibling;
|
|
||||||
end;
|
end;
|
||||||
end
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TClassTreeBuilder.AddToClassTree(AElement : TPasElement; Var ACount : Integer) : TDomElement;
|
Function TClassTreeBuilder.AddToClassTree(AElement : TPasElement; ACount : Integer) : TDomElement;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
PC : TPasClassType;
|
PC : TPasClassType;
|
||||||
@ -123,14 +128,21 @@ begin
|
|||||||
Result:=FTreeStart
|
Result:=FTreeStart
|
||||||
else If (AElement is TPasClassType) then
|
else If (AElement is TPasClassType) then
|
||||||
begin
|
begin
|
||||||
Writeln('Doing ',AElement.Name);
|
|
||||||
if (AElement=FParentObject) then
|
if (AElement=FParentObject) then
|
||||||
Result:=FTreeStart
|
Result:=FTreeStart
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
PC:=AElement as TPasClassType;
|
PC:=AElement as TPasClassType;
|
||||||
PE:=AddToClassTree(PC.AncestorType,ACount);
|
PE:=AddToClassTree(PC.AncestorType,ACount+1);
|
||||||
N:=LookForElement(PE,AElement);
|
if PE=Nil then
|
||||||
|
begin
|
||||||
|
Write('Name ',PC.Name,' parent ');
|
||||||
|
if Assigned(PC.AncestorType) then
|
||||||
|
Write('(Name: ',PC.AncestorType.Name,' Type:',PC.ANcestorType.ClassName,')');
|
||||||
|
PE:=FClassTree.CreateElement(PC.AncestorType.Name);
|
||||||
|
FTreeStart.AppendChild(PE);
|
||||||
|
end;
|
||||||
|
N:=LookForElement(PE,PC);
|
||||||
If (N<>Nil) then
|
If (N<>Nil) then
|
||||||
Result:=N as TDomElement
|
Result:=N as TDomElement
|
||||||
else
|
else
|
||||||
@ -143,13 +155,6 @@ begin
|
|||||||
if Assigned(M) then
|
if Assigned(M) then
|
||||||
Result['unit']:=M.Name;
|
Result['unit']:=M.Name;
|
||||||
end;
|
end;
|
||||||
if (PE=FTreeStart) then
|
|
||||||
begin
|
|
||||||
Writeln('Adding to tree start :',AELement.Name);
|
|
||||||
Writeln('Have ancestor : ',PC.AncestorType<>Nil);
|
|
||||||
if (PC.AncestorType<>Nil) then
|
|
||||||
Writeln(PC.AncestorType.ClassName, ' : '+PC.AncestorType.Name);
|
|
||||||
end;
|
|
||||||
PE.AppendChild(Result);
|
PE.AppendChild(Result);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user