forked from dontenwill/DUDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
duds.export.units.Gephi.pas
49 lines (39 loc) · 1.27 KB
/
duds.export.units.Gephi.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
unit duds.export.units.Gephi;
interface
uses
System.Classes, System.SysUtils,
duds.common.Interfaces,
duds.common.Strings,
duds.common.Classes,
duds.analyzer.model;
procedure ExportToGephi(Model: TDudsModel; ExportUnitsNotInPath: Boolean; const Filename: String);
implementation
procedure ExportToGephi(Model: TDudsModel; ExportUnitsNotInPath: Boolean; const Filename: String);
var
Lines: TStringList;
CurrentLine: String;
UsedUnitInfo: IUsedUnitInfo;
DelphiFile, UsedDelphiFile: TDelphiFile;
begin
Lines := TStringList.Create;
try
for DelphiFile in Model.ParsedDelphiFiles.Values do
begin
if DelphiFile.InSearchPath or ExportUnitsNotInPath then
begin
// Add current unit name
CurrentLine := Trim(DelphiFile.UnitInfo.DelphiUnitName);
// Add references to all used units
for UsedUnitInfo in DelphiFile.UnitInfo.UsedUnits do
if Model.ParsedDelphiFiles.TryGetValue(UpperCase(UsedUnitInfo.DelphiUnitName), UsedDelphiFile) then
if UsedDelphiFile.InSearchPath or ExportUnitsNotInPath then
AddToken(CurrentLine, Trim(UsedUnitInfo.DelphiUnitName), ';');
Lines.Add(CurrentLine);
end;
end;
Lines.SaveToFile(Filename);
finally
FreeAndNil(Lines);
end;
end;
end.