├── .gitignore ├── DelphiClass.pas ├── DelphiProject.pas ├── DelphiUnit.pas ├── DelphiUsesGraph.uaf ├── GexfExport.pas ├── JSONExport.pas ├── LICENSE ├── LexicalAnalyser.pas ├── Main.dfm ├── Main.pas ├── ProjectSettings.pas ├── README.md ├── Tests ├── LexicalAnalyserTests.pas ├── Tests.dpr └── Tests.dproj ├── UsesGraph.dpr ├── UsesGraph.dproj ├── UsesGraphFamily.groupproj ├── UsesGraphFamily.~dsk └── UsesGraphFamily_prjgroup.tvsconfig /.gitignore: -------------------------------------------------------------------------------- 1 | Tests/Win32 2 | Win32/Debug 3 | Tests/__history 4 | __history 5 | Tests/Tests.dproj.local 6 | *.res 7 | *.local 8 | *.stat 9 | *.identcache 10 | *.dsk 11 | __recovery 12 | -------------------------------------------------------------------------------- /DelphiClass.pas: -------------------------------------------------------------------------------- 1 | unit DelphiClass; 2 | 3 | interface 4 | 5 | uses 6 | System.Generics.Defaults, 7 | System.Generics.Collections, 8 | Classes; 9 | 10 | type 11 | TDelphiClassStatType = ( 12 | dcName, 13 | dcPrivateRoutines, 14 | dcProtectedRoutines, 15 | dcPublicRoutines, 16 | dcPublishedRoutines, 17 | dcProperties, 18 | dcFileName, 19 | dcUnitsReferencing 20 | ); 21 | 22 | TDelphiVisibility = (dvPrivate, dvProtected, dvPublic, dvPublished); 23 | 24 | TDelphiClass = class 25 | private 26 | fName : String; 27 | fFileName : String; 28 | fPrivateRoutines : TStringList; 29 | fProtectedRoutines: TStringList; 30 | fPublicRoutines : TStringList; 31 | fPublishedRoutines: TStringList; 32 | fProperties : TStringList; 33 | fUnitsReferencing : TStringList; (* TDelphiUnit *) 34 | public 35 | constructor Create(Name: String; FileName: String); 36 | destructor Destroy; override; 37 | 38 | procedure GetStatDetails(StatType: TDelphiClassStatType; Strings: TStrings); 39 | 40 | function TotalRoutines: Integer; 41 | 42 | property Name : String read fName; 43 | property FileName : String read fFileName; 44 | property PrivateRoutines : TStringList read fPrivateRoutines; 45 | property ProtectedRoutines : TStringList read fProtectedRoutines; 46 | property PublicRoutines : TStringList read fPublicRoutines; 47 | property PublishedRoutines : TStringList read fPublishedRoutines; 48 | property Properties : TStringList read fProperties; 49 | property UnitsReferencing : TStringList read fUnitsReferencing; 50 | end; 51 | 52 | TDelphiClassComparer = class(TComparer) 53 | private 54 | fSortCol: TDelphiClassStatType; 55 | fAscending: Boolean; 56 | public 57 | constructor Create(SortCol: TDelphiClassStatType; Ascending: Boolean); 58 | function Compare(const Left, Right: TDelphiClass): Integer; override; 59 | end; 60 | 61 | const 62 | cDelphiVisibility: array[TDelphiVisibility] of string = ('private', 'protected', 'public', 'published'); 63 | 64 | implementation 65 | 66 | uses 67 | SysUtils; 68 | 69 | { TDelphiClass } 70 | 71 | constructor TDelphiClass.Create(Name: String; FileName: String); 72 | begin 73 | fName:=Name; 74 | fFileName:=FileName; 75 | fPrivateRoutines :=TStringList.Create; 76 | fProtectedRoutines:=TStringList.Create; 77 | fPublicRoutines :=TStringList.Create; 78 | fPublishedRoutines:=TStringList.Create; 79 | fProperties:=TStringList.Create; 80 | fUnitsReferencing:=TStringList.Create; 81 | end; 82 | 83 | destructor TDelphiClass.Destroy; 84 | begin 85 | FreeAndNil(fPrivateRoutines); 86 | FreeAndNil(fProtectedRoutines); 87 | FreeAndNil(fPublicRoutines); 88 | FreeAndNil(fPublishedRoutines); 89 | FreeAndNil(fProperties); 90 | FreeAndNil(fUnitsReferencing); 91 | inherited; 92 | end; 93 | 94 | procedure TDelphiClass.GetStatDetails(StatType: TDelphiClassStatType; Strings: TStrings); 95 | begin 96 | Strings.Clear; 97 | case StatType of 98 | dcName : Strings.AddObject(Name, Self); 99 | dcFileName : Strings.AddObject(FileName, Self); 100 | dcPrivateRoutines : Strings.Assign(fPrivateRoutines); 101 | dcProtectedRoutines : Strings.Assign(fProtectedRoutines); 102 | dcPublicRoutines : Strings.Assign(fPublicRoutines); 103 | dcPublishedRoutines : Strings.Assign(fPublishedRoutines); 104 | dcProperties : Strings.Assign(fProperties); 105 | dcUnitsReferencing : Strings.Assign(fUnitsReferencing); 106 | else 107 | raise Exception.Create('TDelphiClass.GetStatDetails: unknown stat type'); 108 | end 109 | end; 110 | 111 | function TDelphiClass.TotalRoutines: Integer; 112 | begin 113 | Result:=fPrivateRoutines.Count + fProtectedRoutines.Count + fPublicRoutines.Count + fPublishedRoutines.Count 114 | end; 115 | 116 | { TDelphiClassComparer } 117 | 118 | function TDelphiClassComparer.Compare(const Left, Right: TDelphiClass): Integer; 119 | 120 | function CompareIntegers(I1: Integer; I2: Integer): Integer; 121 | begin 122 | if fAscending then 123 | Result:= I1 - I2 124 | else 125 | Result:= I2 - I1 126 | end; 127 | 128 | function CompareStrings(S1: String; S2: String): Integer; 129 | begin 130 | if fAscending then 131 | Result:= CompareStr(S1, S2) 132 | else 133 | Result:= CompareStr(S2, S1) 134 | end; 135 | 136 | function CompareBooleans(B1: Boolean; B2: Boolean): Integer; 137 | begin 138 | if fAscending then 139 | Result:= ord(B1) - Ord(B2) 140 | else 141 | Result:= ord(B2) - Ord(B1) 142 | end; 143 | 144 | begin 145 | case fSortCol of 146 | dcName : Result := CompareStrings(Left.Name, Right.Name); 147 | dcFileName : Result := CompareStrings(Left.FileName, Right.FileName); 148 | dcPrivateRoutines : Result := CompareIntegers(Left.PrivateRoutines.Count, Right.PrivateRoutines.Count); 149 | dcProtectedRoutines: Result := CompareIntegers(Left.ProtectedRoutines.Count, Right.ProtectedRoutines.Count); 150 | dcPublicRoutines : Result := CompareIntegers(Left.PublicRoutines.Count, Right.PublicRoutines.Count); 151 | dcPublishedRoutines: Result := CompareIntegers(Left.PublishedRoutines.Count, Right.PublishedRoutines.Count); 152 | dcProperties : Result := CompareIntegers(Left.Properties.Count, Right.Properties.Count); 153 | dcUnitsReferencing : Result := CompareIntegers(Left.UnitsReferencing.Count, Right.UnitsReferencing.Count); 154 | else 155 | raise Exception.Create('TDelphiClassComparer.Compare: unknown comparison type'); 156 | end 157 | end; 158 | 159 | 160 | constructor TDelphiClassComparer.Create(SortCol: TDelphiClassStatType; 161 | Ascending: Boolean); 162 | begin 163 | fSortCol:=SortCol; 164 | fAscending:=Ascending; 165 | end; 166 | 167 | end. 168 | -------------------------------------------------------------------------------- /DelphiProject.pas: -------------------------------------------------------------------------------- 1 | unit DelphiProject; 2 | 3 | interface 4 | 5 | uses 6 | System.Types, 7 | System.Generics.Collections, 8 | Classes, 9 | DelphiUnit, 10 | LexicalAnalyser, 11 | ProjectSettings, 12 | DelphiClass; 13 | 14 | type 15 | 16 | TDelphiProject = class 17 | private 18 | fLogProc : TInfoProc; 19 | fProgressProc: TProgressProc; 20 | fSettings : TProjectSettings; 21 | fFileNames : TDictionary; // map unit name to Filename 22 | fIgnoredFiles: TDictionary; 23 | fUnits : TDictionary; (* owns units *) 24 | fMainUnit : TDelphiUnit; (* user ref *) 25 | 26 | procedure CollectFileNames(Path: String); 27 | 28 | procedure Log(S: String; Level: TLogLevel = llInfo); 29 | 30 | procedure Progress(Current: Integer; Total: Integer); 31 | 32 | procedure ParseUnit(U: TDelphiUnit; FileName: String; Depth: Integer); 33 | 34 | procedure ParsedUsedUnits(ReferringUnit: TDelphiUnit; Depth: Integer); 35 | 36 | procedure GetUnitsContainingClass(ClassName: String; Units: TStrings (* name -> Unit *)); 37 | public 38 | constructor Create; 39 | destructor Destroy; override; 40 | 41 | procedure Parse(FileName: String; LogProc: TInfoProc); 42 | procedure UnParse(Strings: TStrings); 43 | 44 | procedure AnalyseClassReferences; 45 | 46 | procedure LoadFromFile(FileName: String); 47 | procedure SaveToFile(FileName: String); 48 | 49 | procedure GetUnitsSorted(SortCol: TDelphiUnitStatType; Ascending: boolean; IncludeExternalUnits: Boolean; Units: TList); 50 | procedure GetClassesSorted(SortCol: TDelphiClassStatType; Ascending: boolean; Classes: TList); 51 | 52 | 53 | procedure GetIgnoredFiles(Strings: TStrings); 54 | 55 | property LogProc : TInfoProc read fLogProc; 56 | property ProgressProc: TProgressProc read fProgressProc write fProgressProc; 57 | property Units : TDictionary read fUnits; 58 | property MainUnit : TDelphiUnit read FMainUnit write fMainUnit; 59 | property Settings : TProjectSettings read fSettings; 60 | end; 61 | 62 | implementation 63 | 64 | uses 65 | System.Generics.Defaults, 66 | System.IOUtils, 67 | SysUtils; 68 | 69 | { TDelphiProject } 70 | 71 | procedure TDelphiProject.AnalyseClassReferences; 72 | var 73 | U: TDelphiUnit; 74 | C: TDelphiClass; 75 | I: Integer; 76 | Total: Integer; 77 | begin 78 | Log('Analysing Class Refs...'); 79 | Total:=fUnits.Count; 80 | I:=0; 81 | for U in fUnits.Values do 82 | begin 83 | for C in U.InterfaceClasses do 84 | GetUnitsContainingClass(C.Name, C.UnitsReferencing); 85 | Inc(I); 86 | Progress(I, Total); 87 | end; 88 | Log('Analysed Class Refs'); 89 | end; 90 | 91 | procedure TDelphiProject.CollectFileNames(Path: String); 92 | var 93 | FileNames : TStringDynArray; 94 | FileName : String; 95 | UnitName : String; 96 | begin 97 | if DirectoryExists(Path) then 98 | begin 99 | FileNames:=TDirectory.GetFiles(Path, '*.pas', TSearchOption.soAllDirectories); 100 | for FileName in FileNames do 101 | begin 102 | UnitName:=ExtractFileName(FileName); 103 | UnitName:=StringReplace(UnitName, '.pas', '', [rfReplaceAll, rfIgnoreCase]); 104 | if not fFileNames.ContainsKey(UnitName) then 105 | fFileNames.Add(UnitName, FileName) 106 | else 107 | Log('Duplicate unit name found: "' + UnitName + '"', llWarning); 108 | end; 109 | end 110 | else 111 | Log('Could not find folder "' + Path + '"') 112 | 113 | end; 114 | 115 | constructor TDelphiProject.Create; 116 | begin 117 | fSettings:=TProjectSettings.Create; 118 | // all dictionaries are case insensitive 119 | fFileNames:=TDictionary.Create(TIStringComparer.Ordinal); 120 | fIgnoredFiles:=TDictionary.Create(TIStringComparer.Ordinal); 121 | fUnits:=TDictionary.Create(TIStringComparer.Ordinal); 122 | fMainUnit:=nil; 123 | end; 124 | 125 | destructor TDelphiProject.Destroy; 126 | begin 127 | FreeAndNil(fUnits); 128 | FreeAndNil(fFileNames); 129 | FreeAndNil(fIgnoredFiles); 130 | FreeAndNil(fSettings); 131 | end; 132 | 133 | function UnitsCompare(List: TStringList; Index1, Index2: Integer): Integer; 134 | begin 135 | Result := StrToIntDef(List[Index2], 0) - StrToIntDef(List[Index1], 0) 136 | end; 137 | 138 | 139 | 140 | procedure TDelphiProject.GetClassesSorted(SortCol: TDelphiClassStatType; Ascending: boolean; Classes: TList); 141 | var 142 | U: TDelphiUnit; 143 | C: TDelphiClass; 144 | Comparer: TDelphiClassComparer; 145 | begin 146 | Classes.Clear; 147 | for U in fUnits.Values do 148 | if U.Parsed then 149 | begin 150 | for C in U.InterfaceClasses do 151 | Classes.Add(C); 152 | end; 153 | 154 | Comparer:=TDelphiClassComparer.Create(SortCol, Ascending); 155 | try 156 | Classes.Sort(Comparer); 157 | finally 158 | FreeAndNil(Comparer); 159 | end; 160 | end; 161 | 162 | procedure TDelphiProject.GetIgnoredFiles(Strings: TStrings); 163 | var 164 | SL: TStringList; 165 | S: String; 166 | begin 167 | Strings.BeginUpdate; 168 | try 169 | SL:=TStringList.Create; 170 | try 171 | for S in fIgnoredFiles.Keys do 172 | SL.Add(S); 173 | SL.Sort; 174 | Strings.Assign(SL); 175 | finally 176 | FreeAndNil(SL); 177 | end; 178 | finally 179 | Strings.EndUpdate 180 | end; 181 | end; 182 | 183 | procedure TDelphiProject.GetUnitsContainingClass(ClassName: String; 184 | Units: TStrings); 185 | var 186 | U: TDelphiUnit; 187 | begin 188 | Log('Checking uses of class ' + ClassName); 189 | Units.Clear; 190 | for U in fUnits.Values do 191 | if U.Parsed and U.ContainsClass(ClassName) then 192 | Units.AddObject(U.Name, U); 193 | end; 194 | 195 | procedure TDelphiProject.GetUnitsSorted(SortCol: TDelphiUnitStatType; Ascending: boolean; IncludeExternalUnits: Boolean; Units: TList); 196 | var 197 | U: TDelphiUnit; 198 | Comparer: TDelphiUnitComparer; 199 | begin 200 | Units.Clear; 201 | for U in fUnits.Values do 202 | if U.Parsed or IncludeExternalUnits then 203 | Units.Add(U); 204 | 205 | Comparer:=TDelphiUnitComparer.Create(SortCol, Ascending); 206 | try 207 | Units.Sort(Comparer); 208 | finally 209 | FreeAndNil(Comparer); 210 | end; 211 | end; 212 | 213 | procedure TDelphiProject.LoadFromFile(FileName: String); 214 | begin 215 | fFileNames.Clear; 216 | fUnits.Clear; 217 | fSettings.LoadFromFile(FileName); 218 | end; 219 | 220 | procedure TDelphiProject.Log(S: String; Level: TLogLevel); 221 | begin 222 | if Assigned(fLogProc) then 223 | fLogProc(S, Level); 224 | end; 225 | 226 | procedure TDelphiProject.Parse(FileName: String; LogProc: TInfoProc); 227 | var 228 | Dir: String; 229 | //IgnoredFile: String; 230 | begin 231 | fLogProc:=LogProc; 232 | fUnits.Clear; 233 | fFileNames.Clear; 234 | fIgnoredFiles.Clear; 235 | fMainUnit:=TDelphiUnit.Create; 236 | 237 | if not TFile.Exists(FileName) then 238 | begin 239 | Log('Could not find project file "' + FileName + '"'); 240 | Exit; 241 | end; 242 | 243 | // look in the home folder if not other search dirs 244 | if fSettings.SearchDirs.Count = 0 then 245 | CollectFileNames(ExtractFilePath(fSettings.RootFileName)) 246 | else 247 | for Dir in fSettings.SearchDirs do 248 | CollectFileNames(TPath.Combine(ExtractFilePath(fSettings.RootFileName), Dir)); 249 | ParseUnit(fMainUnit, FileName, 1); 250 | end; 251 | 252 | procedure TDelphiProject.ParsedUsedUnits(ReferringUnit: TDelphiUnit; Depth: Integer); 253 | 254 | procedure ParseRefs(UsesList: TObjectList; FromInterface: Boolean); 255 | var 256 | U : TDelphiUnit; 257 | FileName: String; 258 | begin 259 | for U in UsesList do 260 | begin 261 | if not fFileNames.ContainsKey(U.Name) then 262 | begin 263 | if not fIgnoredFiles.ContainsKey(U.Name) then 264 | fIgnoredFiles.Add(U.Name, U.Name); 265 | end 266 | else 267 | begin 268 | FileName:=fFileNames.Items[U.Name]; 269 | ParseUnit(U, FileName, Depth); 270 | end; 271 | if FromInterface and not U.RefsFromInterfaces.Contains(ReferringUnit) then 272 | U.RefsFromInterfaces.Add(ReferringUnit) 273 | else if not U.RefsFromImplementations.Contains(ReferringUnit) then 274 | U.RefsFromImplementations.Add(ReferringUnit) 275 | end; 276 | end; 277 | 278 | begin 279 | ParseRefs(ReferringUnit.InterfaceUses, True); 280 | ParseRefs(ReferringUnit.ImplementationUses, False); 281 | end; 282 | 283 | procedure TDelphiProject.ParseUnit(U: TDelphiUnit; FileName: String; Depth: Integer); 284 | 285 | var 286 | Lex: TLexicalAnalyser; 287 | 288 | function GetQualifiedName: String; 289 | begin 290 | Result:=Lex.CurrentSym; 291 | Lex.GetSym; 292 | while Lex.OptionalSym('.') do 293 | begin 294 | Result:=Result + '.' + Lex.CurrentSym; 295 | Lex.GetSym; 296 | end; 297 | end; 298 | 299 | procedure ParseUsesClause(UseList: TObjectList); 300 | 301 | function GetOrCreateUnit(Name: String): TDelphiUnit; 302 | begin 303 | if not fUnits.TryGetValue(Name, Result) then 304 | begin 305 | Result:=TDelphiUnit.Create; 306 | Result.Name := Name; 307 | fUnits.Add(Name, Result); 308 | end; 309 | end; 310 | 311 | var 312 | Name: String; 313 | begin 314 | Name:=GetQualifiedName; 315 | UseList.Add(GetOrCreateUnit(Name)); 316 | while Lex.OptionalSym(',') do 317 | begin 318 | Name:=GetQualifiedName; 319 | UseList.Add(GetOrCreateUnit(Name)); 320 | end; 321 | end; 322 | 323 | procedure AddRoutine(CurrentClass: TDelphiClass; Visibility: TDelphiVisibility; Name: String); 324 | begin 325 | case Visibility of 326 | dvPrivate: CurrentClass.PrivateRoutines.Add(Name); 327 | dvProtected: CurrentClass.ProtectedRoutines.Add(Name); 328 | dvPublic: CurrentClass.PublicRoutines.Add(Name); 329 | dvPublished: CurrentClass.PublishedRoutines.Add(Name); 330 | else 331 | // skip 332 | end; 333 | end; 334 | 335 | procedure ParseClass; 336 | 337 | procedure ParseSuperTypes; 338 | begin 339 | if Lex.OptionalSym('(') then 340 | while not Lex.OptionalSym(')') do 341 | Lex.GetSym; 342 | end; 343 | 344 | var 345 | ClassName : String; 346 | CurrentClass: TDelphiClass; 347 | Visibility : TDelphiVisibility; 348 | begin 349 | ClassName:=Lex.PreviousSym(1); 350 | Lex.GetSym; 351 | if not Lex.OptionalSym(';') // skip forward declares 352 | and not Lex.OptionalSym('function') // skip class methods 353 | and not Lex.OptionalSym('procedure') // skip class methods 354 | then 355 | begin 356 | CurrentClass:=TDelphiClass.Create(ClassName, FileName); 357 | U.InterfaceClasses.Add(CurrentClass); 358 | Visibility:=dvPublished; 359 | 360 | ParseSuperTypes; 361 | 362 | if Lex.OptionalSym(';') then // special case for TTrivial = class(TSuper); 363 | Exit; 364 | 365 | while not Lex.OptionalSym('end') do 366 | begin 367 | if Lex.SymbolIs('private') then 368 | Visibility:=dvPrivate 369 | else if Lex.SymbolIs('protected') then 370 | Visibility:=dvProtected 371 | else if Lex.SymbolIs('public') then 372 | Visibility:=dvPublic 373 | else if Lex.SymbolIs('published') then 374 | Visibility:=dvPublished; 375 | 376 | if Lex.OptionalSym('procedure') and not Lex.OptionalSym('(') then 377 | AddRoutine(CurrentClass, Visibility, 'procedure ' + GetQualifiedName) 378 | else if Lex.OptionalSym('function') and not Lex.OptionalSym('(') then 379 | AddRoutine(CurrentClass, Visibility, 'function ' + GetQualifiedName) 380 | else if Lex.OptionalSym('property') then 381 | CurrentClass.Properties.Add('property ' + GetQualifiedName) 382 | else 383 | Lex.GetSym; 384 | end 385 | end 386 | end; 387 | 388 | begin 389 | if U.Parsed then 390 | Exit; 391 | 392 | Lex:=TLexicalAnalyser.CreateFromFile(FileName); 393 | try 394 | Lex.RequiredSym('unit'); 395 | U.Name:=GetQualifiedName; 396 | U.FileName:=Filename; 397 | U.Depth:=Depth; 398 | U.SourceText:=Lex.Text; 399 | //Log('>> Parsing ' + FileName); 400 | if not fUnits.ContainsKey(U.Name) then 401 | begin 402 | fUnits.Add(U.Name, U); 403 | end; 404 | Lex.LogProc:=fLogProc; 405 | Lex.Logging:=True; 406 | Lex.SkipTo('interface'); 407 | if Lex.OptionalSym('uses') then 408 | ParseUsesClause(U.InterfaceUses); 409 | 410 | //Lex.SkipTo('implementation'); 411 | while not Lex.OptionalSym('implementation') do 412 | begin 413 | if Lex.SymbolIs('class') then 414 | ParseClass; 415 | 416 | if Lex.OptionalSym('procedure') and not Lex.OptionalSym('(') then 417 | U.InterfaceRoutines.Add('procedure ' + GetQualifiedName) 418 | else if Lex.OptionalSym('function') and not Lex.OptionalSym('(') then 419 | U.InterfaceRoutines.Add('function ' + GetQualifiedName) 420 | else 421 | Lex.GetSym; 422 | end; 423 | 424 | if Lex.OptionalSym('uses') then 425 | ParseUsesClause(U.ImplementationUses); 426 | 427 | Lex.SkipToEof; 428 | U.LineCount:=Lex.LineNo; 429 | U.Parsed:=True; 430 | 431 | //Log('<< Parsing ' + FileName); 432 | finally 433 | FreeAndNil(Lex); 434 | end; 435 | ParsedUsedUnits(U, Depth+1) 436 | end; 437 | 438 | procedure TDelphiProject.Progress(Current, Total: Integer); 439 | begin 440 | if Assigned(fProgressProc) then 441 | fProgressProc(Current, Total) 442 | end; 443 | 444 | procedure TDelphiProject.SaveToFile(FileName: String); 445 | begin 446 | fSettings.SaveToFile(FileName); 447 | end; 448 | 449 | procedure TDelphiProject.UnParse(Strings: TStrings); 450 | var 451 | U: TDelphiUnit; 452 | begin 453 | for U in fUnits.Values do 454 | U.Unparse(Strings); 455 | end; 456 | 457 | end. 458 | -------------------------------------------------------------------------------- /DelphiUnit.pas: -------------------------------------------------------------------------------- 1 | unit DelphiUnit; 2 | 3 | interface 4 | 5 | uses 6 | System.Generics.Defaults, 7 | System.Generics.Collections, 8 | System.Classes, 9 | DelphiClass; 10 | 11 | type 12 | 13 | TDelphiUnitStatType = ( 14 | duName, 15 | duFileName, 16 | duIntfUses, 17 | duImplUses, 18 | duIntfRefs, 19 | duImplRefs, 20 | duLineCount, 21 | duWeighting, 22 | duDepth, 23 | duDepthDiff, 24 | duClasses, 25 | duRoutines, 26 | duIntfDependency, 27 | duImplDependency, 28 | duCyclic 29 | ); 30 | 31 | TDelphiUnitFilter = (dufInterfacesOnly, dufAll); 32 | 33 | TLazyBool = (lbNotCalculated, lbNo, lbYes); 34 | 35 | 36 | TDelphiUnit = class 37 | private 38 | fName : String; 39 | fFileName : String; 40 | fSourceText : String; 41 | fDepth : Integer; 42 | fParsed : Boolean; 43 | fLineCount : Integer; 44 | fMaxDependency : Integer; // the cumulative dependency depth of units I use 45 | fMaxInterfaceDependency : Integer; 46 | fContainsCycles : TLazyBool; 47 | fInterfaceUses : TObjectList; 48 | fInterfaceRoutines : TStringList; 49 | fInterfaceClasses : TObjectList; 50 | fImplementationUses : TObjectList; 51 | 52 | fRefsFromInterfaces : TObjectList; // other units referring to me form their Interface 53 | fRefsFromImplementations: TObjectList; // other units referring to me form their Implementation 54 | 55 | class procedure GetDeepestDependencyPath(UnitToProcess: TDelphiUnit; Strings: TStrings); 56 | class procedure GetDependencyTree( 57 | UnitToProcess: TDelphiUnit; 58 | Strings: TStrings; 59 | Filter: TDelphiUnitFilter; 60 | Level: Integer; 61 | MaxDepth: Integer 62 | ); 63 | class function UnitContainsCycles(UnitToProcess: TDelphiUnit): Boolean; 64 | function GetMaxDependency: Integer; 65 | function GetContainsCycles: Boolean; 66 | function GetMaxInterfaceDependency: Integer; 67 | public 68 | constructor Create; 69 | destructor Destroy; override; 70 | 71 | class function DeepestDependentUnit(UnitToProcess: TDelphiUnit): TDelphiUnit; static; 72 | 73 | procedure Clear; 74 | 75 | procedure GetStatDetails(StatType: TDelphiUnitStatType; Strings: TStrings); 76 | 77 | procedure Unparse(Strings: TStrings); 78 | 79 | function ContainsClass(ClassName: String): Boolean; 80 | 81 | function Weighting: Integer; 82 | 83 | function DepthDifferential: Integer; 84 | 85 | property Name : String read fName write fName; 86 | property FileName : String read fFileName write fFileName; 87 | property SourceText : String read fSourceText write fSourceText; 88 | property Depth : Integer read fDepth write fDepth; 89 | property LineCount : Integer read fLineCount write fLineCount; 90 | property Parsed : Boolean read fParsed write fParsed; 91 | property ContainsCycles : Boolean read GetContainsCycles; 92 | property MaxDependency : Integer read GetMaxDependency; 93 | property MaxInterfaceDependency : Integer read GetMaxInterfaceDependency; 94 | property InterfaceUses : TObjectList read fInterfaceUses; 95 | property InterfaceClasses : TObjectList read fInterfaceClasses; 96 | property InterfaceRoutines : TStringList read fInterfaceRoutines; 97 | property ImplementationUses : TObjectList read fImplementationUses; 98 | property RefsFromInterfaces : TObjectList read fRefsFromInterfaces ; 99 | property RefsFromImplementations: TObjectList read fRefsFromImplementations; 100 | end; 101 | 102 | TDelphiUnitComparer = class(TComparer) 103 | private 104 | fSortCol: TDelphiUnitStatType; 105 | fAscending: Boolean; 106 | public 107 | constructor Create(SortCol: TDelphiUnitStatType; Ascending: Boolean); 108 | function Compare(const Left, Right: TDelphiUnit): Integer; override; 109 | end; 110 | 111 | 112 | implementation 113 | 114 | uses 115 | System.Math, 116 | SysUtils, 117 | StrUtils; 118 | 119 | { TDelphiUnit } 120 | 121 | procedure TDelphiUnit.Clear; 122 | begin 123 | fName:=''; 124 | fFileName:=''; 125 | fDepth:=0; 126 | fParsed:=False; 127 | fLineCount:=0; 128 | fMaxInterfaceDependency:=-1; 129 | fMaxDependency:=-1; 130 | fContainsCycles:=lbNotCalculated; 131 | fInterfaceUses.Clear; 132 | fInterfaceClasses.Clear; 133 | fInterfaceRoutines.Clear; 134 | fImplementationUses.Clear; 135 | fRefsFromInterfaces.Clear; 136 | fRefsFromImplementations.Clear; 137 | end; 138 | 139 | function TDelphiUnit.ContainsClass(ClassName: String): Boolean; 140 | begin 141 | // very crude a present - ignores all structure, comments etc 142 | Result:=ContainsText(fSourceText, ClassName); 143 | end; 144 | 145 | constructor TDelphiUnit.Create; 146 | begin 147 | fName:=''; 148 | fFileName:=''; 149 | fDepth:=0; 150 | fParsed:=False; 151 | fLineCount:=0; 152 | fMaxInterfaceDependency:=-1; 153 | fMaxDependency:=-1; 154 | fContainsCycles := lbNotCalculated; 155 | fInterfaceUses := TObjectList.Create(False); 156 | fInterfaceClasses := TObjectList.Create(True); 157 | fInterfaceRoutines := TStringList.Create; 158 | fImplementationUses := TObjectList.Create(False); 159 | fRefsFromInterfaces := TObjectList.Create(False); 160 | fRefsFromImplementations := TObjectList.Create(False); 161 | end; 162 | 163 | function TDelphiUnit.DepthDifferential: Integer; 164 | var 165 | U: TDelphiUnit; 166 | begin 167 | Result:=0; 168 | for U in fInterfaceUses do 169 | if U.Depth < fDepth then 170 | Result:=Min(Result, U.Depth - fDepth); 171 | for U in fImplementationUses do 172 | if U.Depth < fDepth then 173 | Result:=Min(Result, U.Depth - fDepth); 174 | end; 175 | 176 | destructor TDelphiUnit.Destroy; 177 | begin 178 | FreeAndNil(fInterfaceUses); 179 | FreeAndNil(fInterfaceClasses); 180 | FreeAndNil(fInterfaceRoutines); 181 | FreeAndNil(fImplementationUses); 182 | FreeAndNil(fRefsFromInterfaces); 183 | FreeAndNil(fRefsFromImplementations); 184 | end; 185 | 186 | function TDelphiUnit.GetMaxDependency: Integer; 187 | var 188 | U: TDelphiUnit; 189 | begin 190 | if fMaxDependency = -1 then 191 | begin 192 | if fParsed then 193 | begin 194 | fMaxDependency:=0; 195 | for U in fInterfaceUses do 196 | begin 197 | if U.MaxDependency <> -1 then 198 | fMaxDependency:=Max(fMaxDependency, U.MaxDependency+1); 199 | end; 200 | for U in fImplementationUses do 201 | begin 202 | if U.MaxDependency <> -1 then 203 | fMaxDependency:=Max(fMaxDependency, U.MaxDependency+1); 204 | end; 205 | end; 206 | end; 207 | Result:=fMaxDependency; 208 | end; 209 | 210 | function TDelphiUnit.GetMaxInterfaceDependency: Integer; 211 | var 212 | U: TDelphiUnit; 213 | begin 214 | if fMaxInterfaceDependency = -1 then 215 | begin 216 | if fParsed then 217 | begin 218 | fMaxInterfaceDependency:=0; 219 | for U in fInterfaceUses do 220 | begin 221 | if U.MaxInterfaceDependency <> -1 then 222 | fMaxInterfaceDependency:=Max(fMaxInterfaceDependency, U.MaxInterfaceDependency+1); 223 | end; 224 | end; 225 | end; 226 | Result:=fMaxInterfaceDependency; 227 | end; 228 | 229 | class function TDelphiUnit.DeepestDependentUnit(UnitToProcess: TDelphiUnit): TDelphiUnit; 230 | var 231 | U: TDelphiUnit; 232 | MaxFound: Integer; 233 | begin 234 | Result:=nil; 235 | MaxFound:=-1; 236 | for U in UnitToProcess.InterfaceUses do 237 | if U.MaxDependency > MaxFound then 238 | begin 239 | MaxFound:=U.MaxDependency; 240 | Result:=U; 241 | end; 242 | for U in UnitToProcess.ImplementationUses do 243 | if U.MaxDependency > MaxFound then 244 | begin 245 | MaxFound:=U.MaxDependency; 246 | Result:=U; 247 | end; 248 | end; 249 | 250 | function TDelphiUnit.GetContainsCycles: Boolean; 251 | begin 252 | if fContainsCycles = lbNotCalculated then 253 | if UnitContainsCycles(Self) then 254 | fContainsCycles:=lbYes 255 | else 256 | fContainsCycles:=lbNo; 257 | 258 | Result:= fContainsCycles = lbYes; 259 | end; 260 | 261 | class procedure TDelphiUnit.GetDeepestDependencyPath(UnitToProcess: TDelphiUnit; Strings: TStrings); 262 | 263 | var 264 | TallestChild: TDelphiUnit; 265 | begin 266 | TallestChild := DeepestDependentUnit(UnitToProcess); 267 | 268 | if TallestChild = nil then 269 | Exit; 270 | 271 | if TallestChild.MaxDependency > UnitToProcess.MaxDependency then 272 | Strings.AddObject('Cycle found: ' + TallestChild.Name + ', dependency = ' + IntToStr(TallestChild.MaxDependency), TallestChild) 273 | else 274 | begin 275 | Strings.AddObject(TallestChild.Name + ', dependency = ' + IntToStr(TallestChild.MaxDependency), TallestChild); 276 | GetDeepestDependencyPath(TallestChild, Strings); 277 | end; 278 | end; 279 | 280 | class procedure TDelphiUnit.GetDependencyTree( 281 | UnitToProcess: TDelphiUnit; 282 | Strings: TStrings; 283 | Filter: TDelphiUnitFilter; 284 | Level: Integer; 285 | MaxDepth: Integer 286 | ); 287 | const 288 | cIndent = 8; 289 | 290 | var 291 | UnitsAlreadyAdded: TObjectList; 292 | 293 | procedure ProcessUnit(UnitToProcess: TDelphiUnit; Level: Integer); 294 | 295 | procedure ProcessUsedUnits(Indent: String; L: TObjectList); 296 | var 297 | U: TDelphiUnit; 298 | begin 299 | for U in UnitToProcess.InterfaceUses do 300 | if not U.Parsed then 301 | // skip 302 | else if U.MaxDependency >= UnitToProcess.MaxDependency then 303 | Strings.AddObject(Indent + 'Cycle found: ' + U.Name, U) 304 | else 305 | ProcessUnit(U, Level+1); 306 | end; 307 | 308 | var 309 | BaseIndent: String; 310 | Indent: String; 311 | Caption: String; 312 | begin 313 | if UnitsAlreadyAdded.IndexOf(UnitToProcess) <> -1 then 314 | Exit; 315 | 316 | UnitsAlreadyAdded.Add(UnitToProcess); 317 | 318 | if Level >= MaxDepth then 319 | Exit; 320 | 321 | BaseIndent:=StringOfChar(' ', Level*cIndent); 322 | Indent:=BaseIndent + StringOfChar(' ', cIndent div 2); 323 | if Filter = dufInterfacesOnly then 324 | Caption := UnitToProcess.Name + '(' + IntToStr(UnitToProcess.MaxInterfaceDependency) + ')' 325 | else 326 | Caption := UnitToProcess.Name + '(' + IntToStr(UnitToProcess.MaxDependency) + ')'; 327 | 328 | Strings.AddObject(BaseIndent + Caption, UnitToProcess); 329 | 330 | Strings.AddObject(Indent + 'Interface', nil); 331 | ProcessUsedUnits(Indent, UnitToProcess.InterfaceUses); 332 | 333 | if (Filter = dufAll) then 334 | begin 335 | Strings.AddObject(Indent + 'Implementation', nil); 336 | ProcessUsedUnits(Indent, UnitToProcess.ImplementationUses); 337 | end; 338 | end; 339 | 340 | begin 341 | UnitsAlreadyAdded:=TObjectList.Create(False); 342 | try 343 | ProcessUnit(UnitToProcess, Level); 344 | finally 345 | FreeAndNil(UnitsAlreadyAdded); 346 | end 347 | end; 348 | 349 | class function TDelphiUnit.UnitContainsCycles(UnitToProcess: TDelphiUnit): Boolean; 350 | 351 | var 352 | U: TDelphiUnit; 353 | begin 354 | Result:=False; 355 | for U in UnitToProcess.InterfaceUses do 356 | if not U.Parsed then 357 | // skip 358 | else if U.MaxDependency >= UnitToProcess.MaxDependency then 359 | Exit(True) 360 | else 361 | if UnitContainsCycles(U) then 362 | Exit(True); 363 | 364 | for U in UnitToProcess.ImplementationUses do 365 | if not U.Parsed then 366 | // skip 367 | else if U.MaxDependency >= UnitToProcess.MaxDependency then 368 | Exit(True) 369 | else 370 | if UnitContainsCycles(U) then 371 | Exit(True); 372 | end; 373 | 374 | procedure TDelphiUnit.GetStatDetails(StatType: TDelphiUnitStatType; Strings: TStrings); 375 | var 376 | U: TDelphiUnit; 377 | C: TDelphiClass; 378 | begin 379 | Strings.Clear; 380 | case StatType of 381 | duName : Strings.AddObject(Name, Self); 382 | duFileName : Strings.AddObject(FileName, Self); 383 | duIntfUses : for U in InterfaceUses do 384 | Strings.AddObject(U.Name + ', dependency = ' + IntToStr(U.MaxDependency), U); 385 | duImplUses : for U in ImplementationUses do 386 | Strings.AddObject(U.Name + ', dependency = ' + IntToStr(U.MaxDependency), U); 387 | duIntfRefs : for U in RefsFromInterfaces do 388 | Strings.AddObject(U.Name, U); 389 | duImplRefs : for U in RefsFromImplementations do 390 | Strings.AddObject(U.Name, U); 391 | duLineCount : Strings.AddObject(IntToStr(LineCount), Self); 392 | duWeighting : Strings.AddObject(IntToStr(Weighting), Self); 393 | duDepth : Strings.AddObject(IntToStr(Depth), Self); 394 | duDepthDiff : Strings.AddObject(IntToStr(DepthDifferential), Self); 395 | duClasses : for C in fInterfaceClasses do 396 | Strings.AddObject(C.Name + ': ' + IntToStr(C.TotalRoutines) + ' routines, ' + IntToStr(C.Properties.Count) + ' properties', C); 397 | duRoutines : Strings.Assign(InterfaceRoutines); 398 | duIntfDependency: GetDependencyTree(Self, Strings, dufInterfacesOnly, 0, 10); 399 | duImplDependency: GetDependencyTree(Self, Strings, dufAll, 0, 10); 400 | duCyclic : Strings.Add(BoolToStr(ContainsCycles, True)); 401 | else 402 | raise Exception.Create('TDelphiUnitComparer.Compare: unknown comparison type'); 403 | end 404 | end; 405 | 406 | procedure TDelphiUnit.Unparse(Strings: TStrings); 407 | 408 | function UsesList(L: TObjectList): String; 409 | var 410 | U: TDelphiUnit; 411 | begin 412 | Result:=''; 413 | for U in L do 414 | Result:=Result + U.Name + ' '; 415 | end; 416 | 417 | begin 418 | if (fInterfaceUses.Count + fImplementationUses.Count > 0) then 419 | begin 420 | Strings.Add('Unit ' + fName); 421 | Strings.Add(' Interface'); 422 | Strings.Add(' ' + UsesList(fInterfaceUses)); 423 | Strings.Add(' Implementation'); 424 | Strings.Add(' ' + UsesList(fImplementationUses)); 425 | Strings.Add(' Referred to from Interfaces: '); 426 | Strings.Add(' ' + UsesList(fRefsFromInterfaces)); 427 | Strings.Add(' Referred to from Implementations: '); 428 | Strings.Add(' ' + UsesList(fRefsFromImplementations)); 429 | end; 430 | end; 431 | 432 | function TDelphiUnit.Weighting: Integer; 433 | begin 434 | // experimental, but an idea of implementation complexity 435 | Result:=fImplementationUses.Count * fRefsFromImplementations.Count; 436 | end; 437 | 438 | function TDelphiUnitComparer.Compare(const Left, Right: TDelphiUnit): Integer; 439 | 440 | function CompareIntegers(I1: Integer; I2: Integer): Integer; 441 | begin 442 | if fAscending then 443 | Result:= I1 - I2 444 | else 445 | Result:= I2 - I1 446 | end; 447 | 448 | function CompareStrings(S1: String; S2: String): Integer; 449 | begin 450 | if fAscending then 451 | Result:= CompareStr(S1, S2) 452 | else 453 | Result:= CompareStr(S2, S1) 454 | end; 455 | 456 | function CompareBooleans(B1: Boolean; B2: Boolean): Integer; 457 | begin 458 | if fAscending then 459 | Result:= ord(B1) - Ord(B2) 460 | else 461 | Result:= ord(B2) - Ord(B1) 462 | end; 463 | 464 | begin 465 | case fSortCol of 466 | duName : Result := CompareStrings(Left.Name, Right.Name); 467 | duFileName : Result := CompareStrings(Left.FileName, Right.FileName); 468 | duIntfUses : Result := CompareIntegers(Left.InterfaceUses.Count, Right.InterfaceUses.Count); 469 | duImplUses : Result := CompareIntegers(Left.ImplementationUses.Count, Right.ImplementationUses.Count); 470 | duIntfRefs : Result := CompareIntegers(Left.RefsFromInterfaces.Count, Right.RefsFromInterfaces.Count); 471 | duImplRefs : Result := CompareIntegers(Left.RefsFromImplementations.Count, Right.RefsFromImplementations.Count); 472 | duLineCount : Result := CompareIntegers(Left.LineCount, Right.LineCount); 473 | duWeighting : Result := CompareIntegers(Left.Weighting, Right.Weighting); 474 | duDepth : Result := CompareIntegers(Left.Depth, Right.Depth); 475 | duDepthDiff : Result := CompareIntegers(Left.DepthDifferential, Right.DepthDifferential); 476 | duClasses : Result := CompareIntegers(Left.InterfaceClasses.Count, Right.InterfaceClasses.Count); 477 | duRoutines : Result := CompareIntegers(Left.InterfaceRoutines.Count, Right.InterfaceRoutines.Count); 478 | duIntfDependency: Result := CompareIntegers(Left.MaxInterfaceDependency, Right.MaxInterfaceDependency); 479 | duImplDependency: Result := CompareIntegers(Left.MaxDependency, Right.MaxDependency); 480 | duCyclic : Result := CompareBooleans(Left.ContainsCycles, Right.ContainsCycles); 481 | else 482 | raise Exception.Create('TDelphiUnitComparer.Compare: unknown comparison type'); 483 | end 484 | end; 485 | 486 | 487 | constructor TDelphiUnitComparer.Create(SortCol: TDelphiUnitStatType; Ascending: Boolean); 488 | begin 489 | fSortCol:=SortCol; 490 | fAscending:=Ascending; 491 | end; 492 | 493 | end. 494 | -------------------------------------------------------------------------------- /DelphiUsesGraph.uaf: -------------------------------------------------------------------------------- 1 | {"RootFileName":"C:\\RPS\\DelphiUsesGraph2\\Main.pas","SearchDirs":["C:\\RPS\\DelphiUsesGraph2"]} -------------------------------------------------------------------------------- /GexfExport.pas: -------------------------------------------------------------------------------- 1 | unit GexfExport; 2 | 3 | interface 4 | 5 | uses 6 | System.Classes, 7 | DelphiProject, 8 | DelphiUnit; 9 | 10 | type 11 | 12 | TGexfExportOption = (gexfExportIntfUses, gexfExportImplUses); 13 | 14 | TGexfExportOptions = set of TGexfExportOption; 15 | 16 | TGexfExport = class 17 | private 18 | 19 | public 20 | constructor Create; 21 | destructor Destroy; override; 22 | 23 | procedure ExportProjectToFile(Project: TDelphiProject; FileName: String; Options: TGexfExportOptions); 24 | procedure ExportProjectToStrings(Project: TDelphiProject; Strings: TStrings; Options: TGexfExportOptions); 25 | end; 26 | 27 | implementation 28 | 29 | uses 30 | System.SysUtils; 31 | 32 | 33 | constructor TGexfExport.Create; 34 | begin 35 | 36 | end; 37 | 38 | destructor TGexfExport.Destroy; 39 | begin 40 | inherited; 41 | end; 42 | 43 | procedure TGexfExport.ExportProjectToFile(Project: TDelphiProject; FileName: String; Options: TGexfExportOptions); 44 | var 45 | Strings: TStringList; 46 | begin 47 | Strings:=TStringList.Create; 48 | try 49 | ExportProjectToStrings(Project, Strings, Options); 50 | Strings.SaveToFile(FileName); 51 | finally 52 | FreeAndNil(Strings); 53 | end; 54 | end; 55 | 56 | 57 | procedure ExportGraphToStrings(Project: TDelphiProject; Strings: TStrings; Options: TGexfExportOptions); 58 | 59 | procedure ExportIntfUses(U: TDelphiUnit; var EdgeId: Integer); 60 | var 61 | RefUnit: TDelphiUnit; 62 | begin 63 | for RefUnit in U.InterfaceUses do 64 | if RefUnit.Parsed then 65 | begin 66 | Strings.Add(' '); 67 | Inc(EdgeId); 68 | end; 69 | end; 70 | 71 | procedure ExportImplUses(U: TDelphiUnit; var EdgeId: Integer); 72 | var 73 | RefUnit: TDelphiUnit; 74 | begin 75 | for RefUnit in U.ImplementationUses do 76 | if RefUnit.Parsed then 77 | begin 78 | Strings.Add(' '); 79 | Inc(EdgeId); 80 | end; 81 | end; 82 | 83 | var 84 | U : TDelphiUnit; 85 | EdgeId : Integer; 86 | begin 87 | Strings.Add(' '); 88 | Strings.Add(' '); 89 | for U in Project.Units.Values do 90 | if U.Parsed then 91 | Strings.Add(' '); 92 | Strings.Add(' '); 93 | 94 | EdgeId:=0; 95 | Strings.Add(' '); 96 | for U in Project.Units.Values do 97 | if U.Parsed then 98 | begin 99 | if gexfExportIntfUses in Options then 100 | ExportIntfUses(U, EdgeId); 101 | 102 | if gexfExportImplUses in Options then 103 | ExportImplUses(U, EdgeId); 104 | end; 105 | Strings.Add(' '); 106 | Strings.Add(' '); 107 | end; 108 | 109 | procedure TGexfExport.ExportProjectToStrings(Project: TDelphiProject; Strings: TStrings; Options: TGexfExportOptions); 110 | begin 111 | Strings.BeginUpdate; 112 | try 113 | Strings.Clear; 114 | Strings.Add(''); 115 | Strings.Add(''); 116 | Strings.Add(' '); 117 | Strings.Add(' UsesGraph'); 118 | Strings.Add(' A delphi Project'); 119 | ExportGraphToStrings(Project, Strings, Options); 120 | Strings.Add(' '); 121 | Strings.Add(''); 122 | finally 123 | Strings.EndUpdate; 124 | end; 125 | end; 126 | 127 | end. 128 | -------------------------------------------------------------------------------- /JSONExport.pas: -------------------------------------------------------------------------------- 1 | unit JSONExport; 2 | 3 | interface 4 | 5 | uses 6 | System.Classes, 7 | DelphiProject, 8 | DelphiUnit; 9 | 10 | type 11 | 12 | TJSONExportOption = (JSONExportIntfUses, JSONExportImplUses); 13 | 14 | TJSONExportOptions = set of TJSONExportOption; 15 | 16 | TJSONExport = class 17 | private 18 | 19 | public 20 | constructor Create; 21 | destructor Destroy; override; 22 | 23 | procedure ExportProjectToFile(Project: TDelphiProject; FileName: String; Options: TJSONExportOptions); 24 | procedure ExportProjectToStrings(Project: TDelphiProject; Strings: TStrings; Options: TJSONExportOptions); 25 | end; 26 | 27 | implementation 28 | 29 | uses 30 | System.SysUtils, 31 | JsonDataObjects; 32 | 33 | const 34 | cGraphId = 'F7F603A5-15E4-4B7B-9155-6B311F93344E'; 35 | cNodeType = '28324482-311B-4B60-8915-ED3F0D289195'; 36 | cIntfEdgeType = 'E087D745-F82B-4994-9876-BBE79C6BEBA8'; 37 | cImplEdgeType = 'A955057F-B3A2-4217-A47A-FD96A5463369'; 38 | 39 | constructor TJSONExport.Create; 40 | begin 41 | 42 | end; 43 | 44 | destructor TJSONExport.Destroy; 45 | begin 46 | inherited; 47 | end; 48 | 49 | procedure TJSONExport.ExportProjectToFile(Project: TDelphiProject; FileName: String; Options: TJSONExportOptions); 50 | var 51 | Strings: TStringList; 52 | begin 53 | Strings:=TStringList.Create; 54 | try 55 | ExportProjectToStrings(Project, Strings, Options); 56 | Strings.SaveToFile(FileName); 57 | finally 58 | FreeAndNil(Strings); 59 | end; 60 | end; 61 | 62 | 63 | procedure ExportGraphToStrings(Project: TDelphiProject; Strings: TStrings; Options: TJSONExportOptions); 64 | 65 | procedure ExportIntfUses(JSON: TJSONArray; U: TDelphiUnit; var EdgeId: Integer); 66 | var 67 | RefUnit: TDelphiUnit; 68 | Edge: TJSONObject; 69 | begin 70 | for RefUnit in U.InterfaceUses do 71 | if RefUnit.Parsed then 72 | begin 73 | Edge:=TJSONObject.Create; 74 | Edge.S['id' ]:= IntToStr(EdgeId); 75 | Edge.S['from' ]:= IntToStr(Integer(U)); 76 | Edge.S['to' ]:= IntToStr(Integer(RefUnit)); 77 | Edge.I['directed' ]:= 1; 78 | Edge.S['name' ]:= 'Intf Ref'; 79 | Edge.S['type_id'] := cIntfEdgeType; 80 | Edge.O['properties'] := TJSONObject.Create; 81 | Edge.O['reference'] := nil; 82 | JSON.Add(Edge); 83 | Inc(EdgeId); 84 | end; 85 | end; 86 | 87 | procedure ExportImplUses(JSON: TJSONArray; U: TDelphiUnit; var EdgeId: Integer); 88 | var 89 | RefUnit: TDelphiUnit; 90 | Edge: TJSONObject; 91 | begin 92 | for RefUnit in U.ImplementationUses do 93 | if RefUnit.Parsed then 94 | begin 95 | Edge:=TJSONObject.Create; 96 | Edge.S['id' ]:= IntToStr(EdgeId); 97 | Edge.S['from' ]:= IntToStr(Integer(U)); 98 | Edge.S['to' ]:= IntToStr(Integer(RefUnit)); 99 | Edge.I['directed' ]:= 1; 100 | Edge.S['name' ]:= 'Impl Ref'; 101 | Edge.S['type_id'] := cImplEdgeType; 102 | Edge.O['properties'] := TJSONObject.Create; 103 | Edge.O['reference'] := nil; 104 | JSON.Add(Edge); 105 | Inc(EdgeId); 106 | end; 107 | end; 108 | 109 | function ExportNodeTypes: TJSONArray; 110 | var 111 | NodeType: TJSONObject; 112 | begin 113 | Result :=TJSONArray.Create; 114 | NodeType :=TJSONObject.Create; 115 | NodeType.S['id'] := cNodeType; 116 | NodeType.S['name'] := 'Delphi Unit'; 117 | NodeType.A['properties'] := TJSONArray.Create; 118 | Result.Add(NodeType); 119 | end; 120 | 121 | function ExportEdgeTypes: TJSONArray; 122 | var 123 | IntfEdgeType: TJSONObject; 124 | ImplEdgeType: TJSONObject; 125 | begin 126 | Result :=TJSONArray.Create; 127 | 128 | IntfEdgeType :=TJSONObject.Create; 129 | IntfEdgeType.S['id'] := cIntfEdgeType; 130 | IntfEdgeType.S['name'] := 'Intf Ref'; 131 | IntfEdgeType.A['properties'] := TJSONArray.Create; 132 | Result.Add(IntfEdgeType); 133 | 134 | ImplEdgeType :=TJSONObject.Create; 135 | ImplEdgeType.S['id'] := cImplEdgeType; 136 | ImplEdgeType.S['name'] := 'Impl Ref'; 137 | ImplEdgeType.A['properties'] := TJSONArray.Create; 138 | Result.Add(ImplEdgeType); 139 | end; 140 | 141 | function ExportNodes: TJSONArray; 142 | 143 | function ExportNode(U: TDelphiUnit): TJSONObject; 144 | begin 145 | Result:=TJSONObject.Create; 146 | Result.S['id' ] := IntToStr(Integer(U)); 147 | Result.S['type'] := 'Unit'; 148 | Result.S['type_id'] := cNodeType; 149 | Result.S['name'] := U.Name; 150 | Result.A['properties'] := TJSONArray.Create; 151 | Result.O['reference'] := nil; 152 | end; 153 | 154 | var 155 | U : TDelphiUnit; 156 | begin 157 | Result :=TJSONArray.Create; 158 | for U in Project.Units.Values do 159 | if U.Parsed then 160 | Result.Add(ExportNode(U)); 161 | end; 162 | 163 | function ExportEdges: TJSONArray; 164 | 165 | var 166 | U : TDelphiUnit; 167 | EdgeId : Integer; 168 | begin 169 | Result :=TJSONArray.Create; 170 | EdgeId:=0; 171 | for U in Project.Units.Values do 172 | if U.Parsed then 173 | begin 174 | if JSONExportIntfUses in Options then 175 | ExportIntfUses(Result, U, EdgeId); 176 | 177 | if JSONExportImplUses in Options then 178 | ExportImplUses(Result, U, EdgeId); 179 | end; 180 | end; 181 | 182 | var 183 | JSON : TJSONObject; 184 | Graph : TJSONObject; 185 | begin 186 | JSON := TJSONObject.Create; 187 | try 188 | 189 | Graph :=TJSONObject.Create; 190 | Graph.S['id'] := cGraphId; 191 | Graph.S['name'] := 'Unit Relations for ' + Project.MainUnit.Name; 192 | Graph.I['status'] := 0; 193 | Graph.A['nodeTypes'] := ExportNodeTypes; 194 | Graph.A['nodes' ] := ExportNodes; 195 | Graph.A['edgeTypes'] := ExportEdgeTypes; 196 | Graph.A['edges' ] := ExportEdges; 197 | 198 | JSON.O ['graph' ] := Graph; 199 | JSON.SaveToLines( Strings ); 200 | finally 201 | FreeAndNil(JSON); 202 | end 203 | end; 204 | 205 | procedure TJSONExport.ExportProjectToStrings(Project: TDelphiProject; Strings: TStrings; Options: TJSONExportOptions); 206 | begin 207 | Strings.BeginUpdate; 208 | try 209 | Strings.Clear; 210 | ExportGraphToStrings(Project, Strings, Options); 211 | finally 212 | Strings.EndUpdate; 213 | end; 214 | end; 215 | 216 | end. 217 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /LexicalAnalyser.pas: -------------------------------------------------------------------------------- 1 | unit LexicalAnalyser; 2 | 3 | interface 4 | 5 | type 6 | 7 | TLogLevel = (llInfo, llWarning, llError); 8 | 9 | TInfoProc = procedure (S: String; Level: TLogLevel = llInfo) of object; 10 | TProgressProc = procedure (Current: Integer; Total: Integer) of object; 11 | 12 | TLexicalAnalyser = class 13 | private 14 | fText : String; 15 | fPos : Integer; 16 | fPrevPrev : String; // 2 symbols back 17 | fPrev : String; // 1 symbols back 18 | fSym : string; 19 | fCh : Char; 20 | fLineNo : Integer; 21 | fLogging : Boolean; 22 | fFileName : String; 23 | fLogProc : TInfoProc; 24 | procedure GetCh; 25 | procedure GetASym; 26 | procedure ShowError(S: String); 27 | function TextBetween(Start: Integer; Finish: Integer): String; 28 | function LineStart: Integer; 29 | function LineEnd: Integer; 30 | procedure Log(S: String; Level: TLogLevel = llInfo); 31 | public 32 | constructor CreateFromFile(FileName: String); 33 | constructor CreateFromString(S: String); 34 | 35 | function CurrentSym: String; 36 | function PreviousSym(SymbolsAgo: Integer): String; 37 | function GetSym: String; 38 | 39 | function AtEnd: Boolean; 40 | 41 | function SymbolIs(S: String): Boolean; 42 | procedure RequiredSym(S: String); 43 | function OptionalSym(S: String): Boolean; 44 | procedure SkipToEof; 45 | 46 | procedure SkipTo(S: String); 47 | 48 | property Logging: Boolean read fLogging write fLogging; 49 | property LineNo : Integer read fLineNo; 50 | property LogProc: TInfoProc read fLogProc write fLogProc; 51 | property Text : String read fText; 52 | end; 53 | 54 | implementation 55 | 56 | uses 57 | IOUtils, 58 | SysUtils; 59 | 60 | const 61 | cLetters = ['a'..'z', 'A'..'Z']; 62 | cDigits = ['0'..'9']; 63 | cNumStarts = cDigits + ['-', '$']; 64 | cNumChars = cDigits + ['.', '-', '#', 'E']; 65 | cHexChars = cDigits + ['a'..'f', 'A'..'F']; 66 | cIdStarts = cLetters + ['_']; 67 | cIdChars = cLetters + cDigits + ['_']; 68 | 69 | 70 | { TLexicalAnalyser } 71 | 72 | constructor TLexicalAnalyser.CreateFromFile(FileName: String); 73 | begin 74 | fText:=''; 75 | fPos:=1; 76 | fSym:=''; 77 | fLogging:=False; 78 | fLineNo:=1; 79 | fFileName:=FileName; 80 | fText := TFile.ReadAllText(fFileName); 81 | if Length(fText) > 0 then 82 | fCh:=fText[1] 83 | else 84 | fCh:=#0; 85 | fPos:=1; 86 | GetSym 87 | end; 88 | 89 | constructor TLexicalAnalyser.CreateFromString(S: String); 90 | begin 91 | fText:=''; 92 | fPos:=1; 93 | fSym:=''; 94 | fLogging:=False; 95 | fLineNo:=1; 96 | fFileName:=''; 97 | fText := S; 98 | if Length(fText) > 0 then 99 | fCh:=fText[1] 100 | else 101 | fCh:=#0; 102 | GetSym 103 | end; 104 | 105 | function TLexicalAnalyser.CurrentSym: String; 106 | begin 107 | Result:=fSym; 108 | end; 109 | 110 | function TLexicalAnalyser.AtEnd: Boolean; 111 | begin 112 | Result:=fPos > Length(fText) 113 | end; 114 | 115 | procedure TLexicalAnalyser.GetCh; 116 | (* read the next character off the input buffer and advance the pointer *) 117 | begin 118 | fPos:=fPos+1; 119 | fCh:=fText[fPos]; 120 | if fCh = chr(13) then 121 | begin 122 | fLineNo:=fLineNo + 1 123 | end 124 | end; 125 | 126 | procedure TLexicalAnalyser.GetASym; 127 | 128 | procedure IgnoreComment; 129 | begin 130 | while (fPos < Length(fText)) and (fCh <> '}') do 131 | GetCh 132 | end; 133 | 134 | procedure IgnoreSingleLineComment; 135 | begin 136 | while (fPos < Length(fText)) and (fCh <> chr(13)) and (fCh <> chr(10)) do 137 | GetCh 138 | end; 139 | 140 | procedure IgnoreTraditionalComment; 141 | begin 142 | repeat 143 | GetCh; 144 | until (fPos >= Length(fText)) or ((fCh = '*') and (fText[fPos+1] = ')')); 145 | GetCh; 146 | end; 147 | 148 | procedure SkipWhiteSpace; 149 | begin 150 | while (fPos <= Length(fText)) and (CharInSet(fCh, [' ', '{', chr(9), chr(10), chr(13), '/', '('])) do 151 | begin 152 | if (fCh = '/') then 153 | begin 154 | if fText[fPos+1] = '/' then 155 | IgnoreSingleLineComment 156 | else 157 | Exit 158 | end 159 | else if (fCh = '(') then 160 | begin 161 | if fText[fPos+1] = '*' then 162 | IgnoreTraditionalComment 163 | else 164 | Exit 165 | end 166 | else if fCh = '{' then 167 | IgnoreComment; 168 | GetCh 169 | end 170 | end; 171 | 172 | procedure GetIdentifier; 173 | begin 174 | fSym:=''; 175 | while CharInSet(fCh, cIdChars) do 176 | begin 177 | fSym:=fSym + fCh; 178 | GetCh 179 | end 180 | end; 181 | 182 | procedure GetNumber; 183 | 184 | function GetHex(): String; 185 | begin 186 | Result:='$'; 187 | repeat 188 | GetCh; 189 | if CharInSet(fCh, cHexChars) then 190 | Result := Result + fCh 191 | else 192 | break; 193 | until (fPos >= Length(fText)); 194 | end; 195 | 196 | function GetDecimal(): String; 197 | begin 198 | Result:=fCh; 199 | while (fPos < Length(fText)) do 200 | begin 201 | GetCh; 202 | if CharInSet(fCh, cNumChars) and (fCh <> '#') then 203 | Result:=Result + fCh 204 | else 205 | break; 206 | end 207 | end; 208 | 209 | begin 210 | if fCh = '$' then 211 | fSym:= GetHex() 212 | else 213 | fSym:=GetDecimal() 214 | end; 215 | 216 | procedure GetString; 217 | var 218 | Done: Boolean; 219 | begin 220 | GetCh; // skip leading ''' 221 | Done:=False; 222 | repeat 223 | if fCh = Chr(13) then 224 | begin 225 | ShowError('String spans more then one line'); 226 | Exit 227 | end; 228 | if fCh <> '''' then 229 | begin 230 | fSym:=fSym + fCh; 231 | GetCh 232 | end 233 | else // test for double quote 234 | if (fPos < Length(fText)) and (fText[fPos+1] = '''') then 235 | begin 236 | fSym:=fSym+''''; 237 | GetCh; 238 | GetCh 239 | end 240 | else 241 | Done:=True 242 | until (fPos >= Length(fText)) or Done; 243 | GetCh; 244 | end; 245 | 246 | procedure GetOperator; 247 | begin 248 | fSym:=fCh; 249 | GetCh; 250 | case fSym[1] of 251 | '<': if fCh = '=' then 252 | begin 253 | GetCh; 254 | fSym:='<=' 255 | end 256 | else if fCh = '>' then 257 | begin 258 | GetCh; 259 | fSym:='<>' 260 | end; 261 | '>': if fCh = '=' then 262 | begin 263 | GetCh; 264 | fSym:='>=' 265 | end; 266 | '.': if fCh = '.' then 267 | begin 268 | GetCh; 269 | fSym:='..' 270 | end; 271 | else 272 | // Skip 273 | end; 274 | end; 275 | 276 | begin 277 | fSym:=''; 278 | if not AtEnd then 279 | begin 280 | SkipWhiteSpace; 281 | if not AtEnd then 282 | begin 283 | if CharInSet(fCh, cIdStarts) then 284 | GetIdentifier 285 | else if CharInSet(fCh, cNumStarts) then 286 | GetNumber 287 | else if fCh = '''' then 288 | GetString 289 | else 290 | GetOperator; 291 | end 292 | end 293 | else 294 | begin 295 | fSym:=#0 296 | end; 297 | // if fLogging then 298 | // Log('Lex: ' + fSym); 299 | end; 300 | 301 | function TLexicalAnalyser.GetSym: String; 302 | begin 303 | if fSym = #0 then 304 | raise Exception.Create('GetSym: EOF!!! previous was: ' + fSym); 305 | fPrevPrev:=fPrev; 306 | fPrev:=fSym; 307 | GetASym; 308 | Result:=fSym; 309 | end; 310 | 311 | procedure TLexicalAnalyser.RequiredSym(S: String); 312 | begin 313 | if not SymbolIs(S) then 314 | begin 315 | ShowError('"' + S + '" expected, "' + fSym + '" found: ' + TextBetween(LineStart, LineEnd)); 316 | end; 317 | GetSym 318 | end; 319 | 320 | function TLexicalAnalyser.SymbolIs(S: String): Boolean; 321 | begin 322 | Result:=AnsiSameText(S, fSym) 323 | end; 324 | 325 | function TLexicalAnalyser.TextBetween(Start, Finish: Integer): String; 326 | begin 327 | Result:=Copy(fText, Start, Finish - Start + 1) 328 | end; 329 | 330 | function TLexicalAnalyser.LineStart: Integer; 331 | begin 332 | Result:=fPos; 333 | while (Result > 0) and (fText[Result] <> chr(10)) do 334 | Result:=Result - 1; 335 | end; 336 | 337 | function TLexicalAnalyser.LineEnd: Integer; 338 | begin 339 | Result:=fPos; 340 | while (Result < Length(fText)) and (fText[Result] <> chr(13)) do 341 | Result:=Result + 1; 342 | Result:=Result-1 343 | end; 344 | 345 | procedure TLexicalAnalyser.Log(S: String; Level: TLogLevel); 346 | begin 347 | if fLogging and Assigned(fLogProc) then 348 | fLogProc(IntToStr(LineNo) + ': ' + S) 349 | end; 350 | 351 | procedure TLexicalAnalyser.SkipTo(S: String); 352 | begin 353 | while not SymbolIs(S) and not AtEnd do 354 | GetSym; 355 | GetSym; 356 | //Log('Found ' + S); 357 | end; 358 | 359 | procedure TLexicalAnalyser.SkipToEof; 360 | begin 361 | while not AtEnd do 362 | GetSym; 363 | end; 364 | 365 | procedure TLexicalAnalyser.ShowError(S: String); 366 | begin 367 | Log(S + ' in ' + fFileName + ' at line ' + IntToStr(fLineNo), llError); 368 | end; 369 | 370 | function TLexicalAnalyser.OptionalSym(S: String): Boolean; 371 | begin 372 | Result:=False; 373 | if Self.SymbolIs(S) then 374 | begin 375 | Result:=True; 376 | Self.GetSym 377 | end 378 | end; 379 | 380 | function TLexicalAnalyser.PreviousSym(SymbolsAgo: Integer): String; begin 381 | if SymbolsAgo = 0 then 382 | Result:=fPrev 383 | else if SymbolsAgo = 1 then 384 | Result:=fPrevPrev 385 | else 386 | raise Exception.Create('PreviousSym: too far back!'); 387 | end; 388 | 389 | end. -------------------------------------------------------------------------------- /Main.dfm: -------------------------------------------------------------------------------- 1 | object FormMain: TFormMain 2 | Left = 0 3 | Top = 0 4 | Caption = 'Uses Analyser' 5 | ClientHeight = 563 6 | ClientWidth = 842 7 | Color = clBtnFace 8 | Font.Charset = DEFAULT_CHARSET 9 | Font.Color = clWindowText 10 | Font.Height = -11 11 | Font.Name = 'Tahoma' 12 | Font.Style = [] 13 | Menu = MainMenu1 14 | OldCreateOrder = False 15 | OnCreate = FormCreate 16 | OnDestroy = FormDestroy 17 | PixelsPerInch = 96 18 | TextHeight = 13 19 | object PageControl1: TPageControl 20 | Left = 0 21 | Top = 0 22 | Width = 842 23 | Height = 563 24 | ActivePage = TabSheetClasses 25 | Align = alClient 26 | TabOrder = 0 27 | OnChange = PageControl1Change 28 | ExplicitHeight = 529 29 | object TabSheetSettings: TTabSheet 30 | Caption = 'Project Settings' 31 | object PanelDPIFudge: TPanel 32 | Left = 0 33 | Top = 0 34 | Width = 834 35 | Height = 535 36 | Align = alClient 37 | TabOrder = 0 38 | DesignSize = ( 39 | 834 40 | 535) 41 | object Label1: TLabel 42 | Left = 3 43 | Top = 64 44 | Width = 42 45 | Height = 13 46 | Caption = 'Root File' 47 | end 48 | object GroupBox1: TGroupBox 49 | Left = 3 50 | Top = 96 51 | Width = 823 52 | Height = 398 53 | Anchors = [akLeft, akTop, akRight, akBottom] 54 | Caption = 'Search Paths' 55 | TabOrder = 0 56 | DesignSize = ( 57 | 823 58 | 398) 59 | object ButtonAddSearchPath: TButton 60 | Left = 750 61 | Top = 24 62 | Width = 70 63 | Height = 25 64 | Anchors = [akRight, akBottom] 65 | Caption = 'Add...' 66 | TabOrder = 0 67 | OnClick = ButtonAddSearchPathClick 68 | end 69 | object ListBoxSearchPaths: TListBox 70 | Left = 15 71 | Top = 24 72 | Width = 729 73 | Height = 353 74 | Anchors = [akLeft, akTop, akRight, akBottom] 75 | ItemHeight = 13 76 | TabOrder = 1 77 | OnClick = ListBoxSearchPathsClick 78 | end 79 | object ButtonRemoveSearchPath: TButton 80 | Left = 748 81 | Top = 64 82 | Width = 70 83 | Height = 25 84 | Anchors = [akRight, akBottom] 85 | Caption = 'Remove' 86 | TabOrder = 2 87 | OnClick = ButtonRemoveSearchPathClick 88 | end 89 | end 90 | object EditRoot: TEdit 91 | Left = 72 92 | Top = 61 93 | Width = 673 94 | Height = 21 95 | Anchors = [akLeft, akTop, akRight] 96 | TabOrder = 1 97 | OnChange = EditRootChange 98 | end 99 | object ButtonBrowseRoot: TButton 100 | Left = 751 101 | Top = 59 102 | Width = 70 103 | Height = 25 104 | Anchors = [akTop, akRight] 105 | Caption = '...' 106 | TabOrder = 2 107 | OnClick = ButtonBrowseRootClick 108 | end 109 | object ButtonAnalyse: TButton 110 | Left = 3 111 | Top = 500 112 | Width = 134 113 | Height = 25 114 | Anchors = [akLeft, akBottom] 115 | Caption = 'Analyse Root File' 116 | TabOrder = 3 117 | OnClick = ButtonAnalyseClick 118 | end 119 | object Panel2: TPanel 120 | Left = 1 121 | Top = 1 122 | Width = 832 123 | Height = 35 124 | Align = alTop 125 | Caption = 'Project Settings' 126 | Font.Charset = DEFAULT_CHARSET 127 | Font.Color = clBlue 128 | Font.Height = -11 129 | Font.Name = 'Tahoma' 130 | Font.Style = [] 131 | ParentFont = False 132 | TabOrder = 4 133 | VerticalAlignment = taAlignTop 134 | end 135 | object ProgressBarAnalyse: TProgressBar 136 | Left = 152 137 | Top = 505 138 | Width = 674 139 | Height = 17 140 | Anchors = [akLeft, akRight, akBottom] 141 | TabOrder = 5 142 | end 143 | end 144 | end 145 | object TabSheetStatistics: TTabSheet 146 | Caption = 'Statistics' 147 | ImageIndex = 2 148 | object PanelDPIFudgeStats: TPanel 149 | Left = 0 150 | Top = 0 151 | Width = 834 152 | Height = 535 153 | Align = alClient 154 | TabOrder = 0 155 | object Splitter1: TSplitter 156 | Left = 1 157 | Top = 434 158 | Width = 832 159 | Height = 3 160 | Cursor = crVSplit 161 | Align = alBottom 162 | ExplicitLeft = 0 163 | ExplicitTop = 433 164 | end 165 | object StringGridStats: TStringGrid 166 | Left = 1 167 | Top = 36 168 | Width = 832 169 | Height = 398 170 | Align = alClient 171 | DefaultDrawing = False 172 | FixedCols = 0 173 | Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goThumbTracking] 174 | TabOrder = 0 175 | OnDrawCell = StringGridStatsDrawCell 176 | OnMouseDown = StringGridStatsMouseDown 177 | OnSelectCell = StringGridStatsSelectCell 178 | end 179 | object PanelStatsTop: TPanel 180 | Left = 1 181 | Top = 1 182 | Width = 832 183 | Height = 35 184 | Align = alTop 185 | Caption = 'Statistical Analysis of units found' 186 | Font.Charset = DEFAULT_CHARSET 187 | Font.Color = clBlue 188 | Font.Height = -11 189 | Font.Name = 'Tahoma' 190 | Font.Style = [] 191 | ParentFont = False 192 | TabOrder = 1 193 | VerticalAlignment = taAlignTop 194 | object LabelStats: TLabel 195 | Left = 160 196 | Top = 16 197 | Width = 71 198 | Height = 13 199 | Caption = 'Showing 0 files' 200 | Font.Charset = DEFAULT_CHARSET 201 | Font.Color = clWindowText 202 | Font.Height = -11 203 | Font.Name = 'Tahoma' 204 | Font.Style = [] 205 | ParentFont = False 206 | end 207 | object CheckBoxShowExternalUnits: TCheckBox 208 | Left = 0 209 | Top = 12 210 | Width = 177 211 | Height = 17 212 | Caption = 'Show External Units' 213 | TabOrder = 0 214 | OnClick = CheckBoxShowExternalUnitsClick 215 | end 216 | end 217 | object ListBoxUnits: TListBox 218 | Left = 1 219 | Top = 437 220 | Width = 832 221 | Height = 97 222 | Align = alBottom 223 | ItemHeight = 13 224 | TabOrder = 2 225 | end 226 | end 227 | end 228 | object TabSheetClasses: TTabSheet 229 | Caption = 'Classes' 230 | ImageIndex = 6 231 | object Splitter2: TSplitter 232 | Left = 0 233 | Top = 435 234 | Width = 834 235 | Height = 3 236 | Cursor = crVSplit 237 | Align = alBottom 238 | ExplicitTop = 429 239 | end 240 | object PanelClasses: TPanel 241 | Left = 0 242 | Top = 0 243 | Width = 834 244 | Height = 35 245 | Align = alTop 246 | Caption = 'Statistical Analysis of classes found' 247 | Font.Charset = DEFAULT_CHARSET 248 | Font.Color = clBlue 249 | Font.Height = -11 250 | Font.Name = 'Tahoma' 251 | Font.Style = [] 252 | ParentFont = False 253 | TabOrder = 0 254 | VerticalAlignment = taAlignTop 255 | object LabelClasses: TLabel 256 | Left = 160 257 | Top = 16 258 | Width = 71 259 | Height = 13 260 | Caption = 'Showing 0 files' 261 | Font.Charset = DEFAULT_CHARSET 262 | Font.Color = clWindowText 263 | Font.Height = -11 264 | Font.Name = 'Tahoma' 265 | Font.Style = [] 266 | ParentFont = False 267 | end 268 | end 269 | object StringGridClasses: TStringGrid 270 | Left = 0 271 | Top = 35 272 | Width = 834 273 | Height = 400 274 | Align = alClient 275 | DefaultDrawing = False 276 | FixedCols = 0 277 | Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goThumbTracking] 278 | TabOrder = 1 279 | OnDrawCell = StringGridClassesDrawCell 280 | OnMouseDown = StringGridClassesMouseDown 281 | OnSelectCell = StringGridClassesSelectCell 282 | end 283 | object ListBoxClassDetails: TListBox 284 | Left = 0 285 | Top = 438 286 | Width = 834 287 | Height = 97 288 | Align = alBottom 289 | ItemHeight = 13 290 | TabOrder = 2 291 | end 292 | end 293 | object TabSheetGEXF: TTabSheet 294 | Caption = 'GEXF' 295 | ImageIndex = 3 296 | object PanelFudgeGEXF: TPanel 297 | Left = 0 298 | Top = 0 299 | Width = 834 300 | Height = 535 301 | Align = alClient 302 | TabOrder = 0 303 | object MemoGEXF: TMemo 304 | Left = 1 305 | Top = 42 306 | Width = 832 307 | Height = 492 308 | Align = alClient 309 | ScrollBars = ssVertical 310 | TabOrder = 0 311 | end 312 | object PanelGexfTop: TPanel 313 | Left = 1 314 | Top = 1 315 | Width = 832 316 | Height = 41 317 | Align = alTop 318 | Caption = 'Export Data to GEXF for Gephi graph analysis' 319 | Font.Charset = DEFAULT_CHARSET 320 | Font.Color = clBlue 321 | Font.Height = -11 322 | Font.Name = 'Tahoma' 323 | Font.Style = [] 324 | ParentFont = False 325 | TabOrder = 1 326 | VerticalAlignment = taAlignTop 327 | object CheckBoxGexfIntfUses: TCheckBox 328 | Left = 9 329 | Top = 18 330 | Width = 137 331 | Height = 17 332 | Caption = 'Export InterfaceUses' 333 | Checked = True 334 | State = cbChecked 335 | TabOrder = 0 336 | OnClick = CheckBoxGexfIntfUsesClick 337 | end 338 | object CheckBoxGexfImplUses: TCheckBox 339 | Left = 152 340 | Top = 18 341 | Width = 166 342 | Height = 17 343 | Caption = 'Export Implementation Uses' 344 | TabOrder = 1 345 | OnClick = CheckBoxGexfImplUsesClick 346 | end 347 | end 348 | end 349 | end 350 | object TabSheetIgnoredFiles: TTabSheet 351 | Caption = 'Ignored Files' 352 | ImageIndex = 4 353 | object PanelFudgeIgnore: TPanel 354 | Left = 0 355 | Top = 0 356 | Width = 834 357 | Height = 535 358 | Align = alClient 359 | TabOrder = 0 360 | object Panel1: TPanel 361 | Left = 1 362 | Top = 1 363 | Width = 832 364 | Height = 41 365 | Align = alTop 366 | Caption = 367 | 'Units used but their source can'#39't be found, so ignored from the ' + 368 | 'analysis' 369 | Font.Charset = DEFAULT_CHARSET 370 | Font.Color = clBlue 371 | Font.Height = -11 372 | Font.Name = 'Tahoma' 373 | Font.Style = [] 374 | ParentFont = False 375 | TabOrder = 0 376 | VerticalAlignment = taAlignTop 377 | end 378 | object MemoIgnoredFiles: TMemo 379 | Left = 1 380 | Top = 42 381 | Width = 832 382 | Height = 492 383 | Align = alClient 384 | ScrollBars = ssVertical 385 | TabOrder = 1 386 | end 387 | end 388 | end 389 | object TabSheetLog: TTabSheet 390 | Caption = 'Log' 391 | ImageIndex = 1 392 | object MemoLog: TMemo 393 | Left = 0 394 | Top = 0 395 | Width = 834 396 | Height = 535 397 | Align = alClient 398 | Lines.Strings = ( 399 | '') 400 | ScrollBars = ssBoth 401 | TabOrder = 0 402 | end 403 | end 404 | object TabSheetJSON: TTabSheet 405 | Caption = 'JSON' 406 | ImageIndex = 5 407 | object PanelJSONExport: TPanel 408 | Left = 0 409 | Top = 0 410 | Width = 834 411 | Height = 41 412 | Align = alTop 413 | Caption = 'Export Data to JSON for GraohCommons graph analysis' 414 | Font.Charset = DEFAULT_CHARSET 415 | Font.Color = clBlue 416 | Font.Height = -11 417 | Font.Name = 'Tahoma' 418 | Font.Style = [] 419 | ParentFont = False 420 | TabOrder = 0 421 | VerticalAlignment = taAlignTop 422 | object CheckBoxJSONInterfaceUses: TCheckBox 423 | Left = 9 424 | Top = 18 425 | Width = 137 426 | Height = 17 427 | Caption = 'Export InterfaceUses' 428 | Checked = True 429 | State = cbChecked 430 | TabOrder = 0 431 | OnClick = CheckBoxGexfIntfUsesClick 432 | end 433 | object CheckBoxJSONImplementationUses: TCheckBox 434 | Left = 152 435 | Top = 18 436 | Width = 166 437 | Height = 17 438 | Caption = 'Export Implementation Uses' 439 | TabOrder = 1 440 | OnClick = CheckBoxGexfImplUsesClick 441 | end 442 | end 443 | object MemoJSON: TMemo 444 | Left = 0 445 | Top = 41 446 | Width = 834 447 | Height = 494 448 | Align = alClient 449 | ScrollBars = ssVertical 450 | TabOrder = 1 451 | end 452 | end 453 | end 454 | object DirectoryListBox1: TDirectoryListBox 455 | Left = 632 456 | Top = 160 457 | Width = 1 458 | Height = 25 459 | TabOrder = 1 460 | end 461 | object OpenDialogRoot: TOpenDialog 462 | Filter = 'Dephi files|*.pas|Delphi projects|*.dpr|Delphi LIbrarie|*.dpk' 463 | Left = 528 464 | Top = 136 465 | end 466 | object MainMenu1: TMainMenu 467 | Left = 56 468 | Top = 232 469 | object File1: TMenuItem 470 | Caption = 'File' 471 | object Open1: TMenuItem 472 | Caption = 'Open Project...' 473 | OnClick = Open1Click 474 | end 475 | object SaveProject1: TMenuItem 476 | Caption = 'Save Project...' 477 | OnClick = SaveProject1Click 478 | end 479 | object Exit1: TMenuItem 480 | Caption = 'Exit' 481 | OnClick = Exit1Click 482 | end 483 | end 484 | end 485 | object OpenDialogProject: TOpenDialog 486 | Filter = 'Usage Analysis files|*.uaf' 487 | Left = 616 488 | Top = 136 489 | end 490 | object SaveDialogProject: TSaveDialog 491 | DefaultExt = '.uaf' 492 | Filter = 'Usage Analysis files|*.uaf' 493 | Options = [ofOverwritePrompt, ofHideReadOnly, ofEnableSizing] 494 | Left = 416 495 | Top = 296 496 | end 497 | end 498 | -------------------------------------------------------------------------------- /Main.pas: -------------------------------------------------------------------------------- 1 | unit Main; 2 | 3 | interface 4 | 5 | uses 6 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, 7 | Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, Vcl.StdCtrls, 8 | DelphiProject, LexicalAnalyser, Vcl.Grids, 9 | DelphiUnit, 10 | DelphiClass, 11 | Vcl.ComCtrls, Vcl.ExtCtrls, System.UITypes, 12 | {$WARN SYMBOL_PLATFORM OFF} 13 | Vcl.FileCtrl 14 | {$WARN SYMBOL_PLATFORM ON} 15 | ; 16 | 17 | type 18 | TFormMain = class(TForm) 19 | OpenDialogRoot: TOpenDialog; 20 | MainMenu1: TMainMenu; 21 | File1: TMenuItem; 22 | Open1: TMenuItem; 23 | Exit1: TMenuItem; 24 | OpenDialogProject: TOpenDialog; 25 | SaveDialogProject: TSaveDialog; 26 | SaveProject1: TMenuItem; 27 | PageControl1: TPageControl; 28 | TabSheetSettings: TTabSheet; 29 | TabSheetLog: TTabSheet; 30 | TabSheetStatistics: TTabSheet; 31 | MemoLog: TMemo; 32 | PanelDPIFudge: TPanel; 33 | Label1: TLabel; 34 | GroupBox1: TGroupBox; 35 | EditRoot: TEdit; 36 | ButtonBrowseRoot: TButton; 37 | ButtonAnalyse: TButton; 38 | PanelDPIFudgeStats: TPanel; 39 | StringGridStats: TStringGrid; 40 | PanelStatsTop: TPanel; 41 | CheckBoxShowExternalUnits: TCheckBox; 42 | LabelStats: TLabel; 43 | Splitter1: TSplitter; 44 | ListBoxUnits: TListBox; 45 | TabSheetGEXF: TTabSheet; 46 | PanelFudgeGEXF: TPanel; 47 | MemoGEXF: TMemo; 48 | PanelGexfTop: TPanel; 49 | CheckBoxGexfIntfUses: TCheckBox; 50 | CheckBoxGexfImplUses: TCheckBox; 51 | TabSheetIgnoredFiles: TTabSheet; 52 | PanelFudgeIgnore: TPanel; 53 | Panel1: TPanel; 54 | MemoIgnoredFiles: TMemo; 55 | Panel2: TPanel; 56 | ButtonAddSearchPath: TButton; 57 | DirectoryListBox1: TDirectoryListBox; 58 | ListBoxSearchPaths: TListBox; 59 | ButtonRemoveSearchPath: TButton; 60 | TabSheetJSON: TTabSheet; 61 | PanelJSONExport: TPanel; 62 | CheckBoxJSONInterfaceUses: TCheckBox; 63 | CheckBoxJSONImplementationUses: TCheckBox; 64 | MemoJSON: TMemo; 65 | TabSheetClasses: TTabSheet; 66 | PanelClasses: TPanel; 67 | LabelClasses: TLabel; 68 | StringGridClasses: TStringGrid; 69 | ListBoxClassDetails: TListBox; 70 | Splitter2: TSplitter; 71 | ProgressBarAnalyse: TProgressBar; 72 | procedure Exit1Click(Sender: TObject); 73 | procedure Open1Click(Sender: TObject); 74 | procedure FormCreate(Sender: TObject); 75 | procedure FormDestroy(Sender: TObject); 76 | procedure ButtonAnalyseClick(Sender: TObject); 77 | procedure SaveProject1Click(Sender: TObject); 78 | procedure ButtonBrowseRootClick(Sender: TObject); 79 | procedure EditRootChange(Sender: TObject); 80 | procedure CheckBoxShowExternalUnitsClick(Sender: TObject); 81 | procedure StringGridStatsDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); 82 | procedure StringGridStatsSelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); 83 | procedure StringGridStatsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 84 | procedure PageControl1Change(Sender: TObject); 85 | procedure CheckBoxGexfIntfUsesClick(Sender: TObject); 86 | procedure CheckBoxGexfImplUsesClick(Sender: TObject); 87 | procedure ButtonAddSearchPathClick(Sender: TObject); 88 | procedure ButtonRemoveSearchPathClick(Sender: TObject); 89 | procedure ListBoxSearchPathsClick(Sender: TObject); 90 | procedure StringGridClassesDrawCell(Sender: TObject; ACol, ARow: Integer; 91 | Rect: TRect; State: TGridDrawState); 92 | procedure StringGridClassesMouseDown(Sender: TObject; Button: TMouseButton; 93 | Shift: TShiftState; X, Y: Integer); 94 | procedure StringGridClassesSelectCell(Sender: TObject; ACol, ARow: Integer; 95 | var CanSelect: Boolean); 96 | private 97 | fProject: TDelphiProject; 98 | procedure CheckControls; 99 | function Confirm(Msg: String): Boolean; 100 | function ConfirmYesNo(Msg: String): Boolean; 101 | procedure ParseFile(FileName: String); 102 | procedure Log(S: String; Level: TLogLevel = llInfo); 103 | procedure Progress(I: Integer; Total: Integer); 104 | procedure InitStatsGrid; 105 | procedure InitClassesGrid; 106 | function UnitStatTypeForCol(Col: Integer): TDelphiUnitStatType; 107 | procedure UpdateGexf(); 108 | procedure UpdateIgnoredFiles(); 109 | procedure UpdateJson; 110 | procedure LoadStatsGrid(SortCol: TDelphiUnitStatType; Ascending: Boolean; ShowExternalUnits: Boolean); 111 | procedure LoadClassesGrid(SortCol: TDelphiClassStatType; Ascending: Boolean); 112 | function ClassStatTypeForCol(Col: Integer): TDelphiClassStatType; 113 | public 114 | { Public declarations } 115 | end; 116 | 117 | var 118 | FormMain: TFormMain; 119 | 120 | implementation 121 | 122 | {$R *.dfm} 123 | 124 | uses 125 | System.Generics.Collections, 126 | System.Math, 127 | GexfExport, JSONExport; 128 | 129 | const 130 | cStatsColName = 0; 131 | cStatsColIntfUses = 1; 132 | cStatsColImplUses = 2; 133 | cStatsColIntfRefs = 3; 134 | cStatsColImplRefs = 4; 135 | cStatsColLineCount = 5; 136 | cStatsColWeighting = 6; 137 | cStatsColDepth = 7; 138 | cStatsColDepthDiff = 8; 139 | cStatsColIntfClasses = 9; 140 | cStatsColIntfProcs = 10; 141 | cStatsColIntfDependency = 11; 142 | cStatsColImplDependency = 12; 143 | cStatsColCyclic = 13; 144 | cStatsColFileName = 14; 145 | 146 | cClassesColName = 0; 147 | cClassesColPrivateProcs = 1; 148 | cClassesColProtectedProcs = 2; 149 | cClassesColPublicProcs = 3; 150 | cClassesColPublishedProcs = 4; 151 | cClassesColProperties = 5; 152 | cClassesColUnits = 6; 153 | cClassesColFileName = 7; 154 | 155 | procedure TFormMain.ButtonAddSearchPathClick(Sender: TObject); 156 | begin 157 | {$WARN SYMBOL_PLATFORM OFF} 158 | with TFileOpenDialog.Create(nil) do 159 | try 160 | Options := [fdoPickFolders]; 161 | if Execute then 162 | begin 163 | ListBoxSearchPaths.AddItem(FileName, nil); 164 | fProject.Settings.SearchDirs.Add(FileName); 165 | CheckControls 166 | end; 167 | finally 168 | Free; 169 | end; 170 | {$WARN SYMBOL_PLATFORM ON} 171 | end; 172 | 173 | procedure TFormMain.ButtonAnalyseClick(Sender: TObject); 174 | begin 175 | MemoLog.Lines.BeginUpdate; 176 | try 177 | //PageControl1.ActivePage:=TabSheetLog; 178 | ParseFile(EditRoot.Text); 179 | PageControl1.ActivePage:=TabSheetStatistics; 180 | finally 181 | MemoLog.Lines.EndUpdate 182 | end; 183 | end; 184 | 185 | procedure TFormMain.ButtonBrowseRootClick(Sender: TObject); 186 | begin 187 | if OpenDialogRoot.Execute then 188 | EditRoot.Text:=OpenDialogRoot.FileName 189 | end; 190 | 191 | procedure TFormMain.ButtonRemoveSearchPathClick(Sender: TObject); 192 | var 193 | Selected: String; 194 | Index : Integer; 195 | begin 196 | if (ListBoxSearchPaths.ItemIndex <> -1) then 197 | begin 198 | Selected:=ListBoxSearchPaths.Items[ListBoxSearchPaths.ItemIndex]; 199 | if Confirm('Remove "' + Selected + '" ?') then 200 | begin 201 | ListBoxSearchPaths.DeleteSelected; 202 | CheckControls; 203 | Index:=fProject.Settings.SearchDirs.IndexOf(Selected); 204 | if Index <> -1 then 205 | fProject.Settings.SearchDirs.Delete(Index); 206 | end 207 | end; 208 | end; 209 | 210 | procedure TFormMain.CheckBoxGexfImplUsesClick(Sender: TObject); 211 | begin 212 | UpdateGexf 213 | end; 214 | 215 | procedure TFormMain.CheckBoxGexfIntfUsesClick(Sender: TObject); 216 | begin 217 | UpdateGexf; 218 | end; 219 | 220 | procedure TFormMain.CheckBoxShowExternalUnitsClick(Sender: TObject); 221 | begin 222 | LoadStatsGrid(duName, True, CheckBoxShowExternalUnits.Checked); 223 | end; 224 | 225 | procedure TFormMain.CheckControls; 226 | begin 227 | ButtonRemoveSearchPath.Enabled:=ListBoxSearchPaths.ItemIndex <> -1 228 | end; 229 | 230 | function TFormMain.Confirm(Msg: String): Boolean; 231 | begin 232 | Result:=MessageDlg(Msg, mtConfirmation, [mbOK, mbCancel], 0) = mrOk 233 | end; 234 | 235 | function TFormMain.ConfirmYesNo(Msg: String): Boolean; 236 | begin 237 | Result:=MessageDlg(Msg, mtConfirmation, [mbYes, mbNo], 0) = mrYes 238 | end; 239 | 240 | procedure TFormMain.EditRootChange(Sender: TObject); 241 | begin 242 | fProject.Settings.RootFileName:=EditRoot.Text; 243 | end; 244 | 245 | procedure TFormMain.Exit1Click(Sender: TObject); 246 | begin 247 | Self.Close; 248 | end; 249 | 250 | procedure TFormMain.FormCreate(Sender: TObject); 251 | begin 252 | fProject:=TDelphiProject.Create; 253 | InitStatsGrid; 254 | InitClassesGrid; 255 | PageControl1.TabIndex:=0; 256 | end; 257 | 258 | procedure TFormMain.FormDestroy(Sender: TObject); 259 | begin 260 | FreeAndNil(fProject) 261 | end; 262 | 263 | procedure TFormMain.InitStatsGrid; 264 | 265 | var 266 | LastColIndex: Integer; 267 | 268 | procedure AddHeading(Col: Integer; Title: String; Width: Integer); 269 | begin 270 | StringGridStats.Cells [Col, 0] := Title; 271 | StringGridStats.ColWidths[Col ] := width; 272 | StringGridStats.Objects [Col, 0] := TObject(False); // last sort order 273 | LastColIndex:=Max(LastColIndex, Col); 274 | end; 275 | 276 | begin 277 | LastColIndex:=0; 278 | StringGridStats.ColCount:=100; 279 | AddHeading( cStatsColName, 'Unit', 300); 280 | AddHeading( cStatsColIntfUses, 'Int Uses', 100); 281 | AddHeading( cStatsColImplUses, 'Impl Uses', 100); 282 | AddHeading( cStatsColIntfRefs, 'Refs from Intf', 100); 283 | AddHeading( cStatsColImplRefs, 'Refs from Impl', 100); 284 | AddHeading( cStatsColLineCount, 'Lines', 100); 285 | AddHeading( cStatsColWeighting, 'Weighting', 100); 286 | AddHeading( cStatsColDepth, 'Depth', 100); 287 | AddHeading( cStatsColDepthDiff, 'Depth Diff', 100); 288 | AddHeading( cStatsColIntfClasses, 'Intf Classes', 100); 289 | AddHeading( cStatsColIntfProcs, 'Intf Routines', 100); 290 | AddHeading( cStatsColIntfDependency, 'Intf Dependency', 100); 291 | AddHeading( cStatsColImplDependency, 'Impl Dependency', 100); 292 | AddHeading( cStatsColCyclic, 'Cyclic', 100); 293 | AddHeading( cStatsColFileName, 'File Name', 500); 294 | StringGridStats.ColCount:=LastColIndex+1 295 | end; 296 | 297 | procedure TFormMain.InitClassesGrid; 298 | 299 | var 300 | LastColIndex: Integer; 301 | 302 | procedure AddHeading(Col: Integer; Title: String; Width: Integer); 303 | begin 304 | StringGridClasses.Cells [Col, 0] := Title; 305 | StringGridClasses.ColWidths[Col ] := width; 306 | StringGridClasses.Objects [Col, 0] := TObject(False); // last sort order 307 | LastColIndex:=Max(LastColIndex, Col); 308 | end; 309 | 310 | begin 311 | LastColIndex:=0; 312 | StringGridClasses.ColCount:=100; 313 | AddHeading( cClassesColName, 'Unit', 300); 314 | AddHeading( cClassesColPrivateProcs, 'Private Procs', 100); 315 | AddHeading( cClassesColProtectedProcs, 'Protected Procs', 100); 316 | AddHeading( cClassesColPublicProcs, 'Public Procs', 100); 317 | AddHeading( cClassesColPublishedProcs, 'Published Procs', 100); 318 | AddHeading( cClassesColProperties, 'Properties', 100); 319 | AddHeading( cClassesColUnits, 'Units', 100); 320 | AddHeading( cClassesColFileName, 'File Name', 500); 321 | 322 | StringGridClasses.ColCount:=LastColIndex+1 323 | end; 324 | 325 | procedure TFormMain.ListBoxSearchPathsClick(Sender: TObject); 326 | begin 327 | CheckControls 328 | end; 329 | 330 | procedure TFormMain.LoadStatsGrid(SortCol: TDelphiUnitStatType; Ascending: Boolean; ShowExternalUnits: Boolean); 331 | 332 | procedure AddRow(U: TDelphiUnit; Row: Integer); 333 | begin 334 | StringGridStats.Objects[0, Row] := U; 335 | StringGridStats.Cells[cStatsColName , Row] := U.Name; 336 | StringGridStats.Cells[cStatsColIntfUses, Row] := IntToStr(U.InterfaceUses.Count); 337 | StringGridStats.Cells[cStatsColImplUses, Row] := IntToStr(U.ImplementationUses.Count); 338 | StringGridStats.Cells[cStatsColIntfRefs, Row] := IntToStr(U.RefsFromInterfaces.Count); 339 | StringGridStats.Cells[cStatsColImplRefs, Row] := IntToStr(U.RefsFromImplementations.Count); 340 | StringGridStats.Cells[cStatsColLineCount, Row] := IntToStr(U.LineCount); 341 | StringGridStats.Cells[cStatsColWeighting, Row] := IntToStr(U.Weighting); 342 | StringGridStats.Cells[cStatsColDepth , Row] := IntToStr(U.Depth); 343 | StringGridStats.Cells[cStatsColDepthDiff, Row] := IntToStr(U.DepthDifferential); 344 | StringGridStats.Cells[cStatsColIntfClasses,Row] := IntToStr(U.InterfaceClasses.Count); 345 | StringGridStats.Cells[cStatsColIntfProcs, Row] := IntToStr(U.InterfaceRoutines.Count); 346 | StringGridStats.Cells[cStatsColIntfDependency, Row] := IntToStr(U.MaxInterfaceDependency); 347 | StringGridStats.Cells[cStatsColImplDependency, Row] := IntToStr(U.MaxDependency); 348 | StringGridStats.Cells[cStatsColCyclic, Row] := BoolToStr(U.ContainsCycles, True); 349 | StringGridStats.Cells[cStatsColFileName, Row] := U.FileName; 350 | end; 351 | 352 | var 353 | Units: TObjectList; 354 | U: TDelphiUnit; 355 | Row: Integer; 356 | begin 357 | Units:=TObjectList.Create(False); 358 | try 359 | fProject.GetUnitsSorted(SortCol, Ascending, ShowExternalUnits, Units); 360 | LabelStats.Caption:='Showing ' + IntToStr(Units.Count) + ' units'; 361 | StringGridStats.RowCount:=1+Units.Count; 362 | Row:=1; 363 | for U in Units do 364 | begin 365 | AddRow(U, Row); 366 | Inc(Row) 367 | end; 368 | finally 369 | FreeAndnil(Units); 370 | end; 371 | end; 372 | 373 | procedure TFormMain.LoadClassesGrid(SortCol: TDelphiClassStatType; Ascending: Boolean); 374 | 375 | procedure AddRow(C: TDelphiClass; Row: Integer); 376 | begin 377 | StringGridClasses.Objects[0, Row] := C; 378 | StringGridClasses.Cells[cClassesColName , Row] := C.Name; 379 | StringGridClasses.Cells[cClassesColPrivateProcs , Row] := IntToStr(C.PrivateRoutines.Count); 380 | StringGridClasses.Cells[cClassesColProtectedProcs , Row] := IntToStr(C.ProtectedRoutines.Count); 381 | StringGridClasses.Cells[cClassesColPublicProcs , Row] := IntToStr(C.PublicRoutines.Count); 382 | StringGridClasses.Cells[cClassesColPublishedProcs , Row] := IntToStr(C.PublishedRoutines.Count); 383 | StringGridClasses.Cells[cClassesColProperties , Row] := IntToStr(C.Properties.Count); 384 | StringGridClasses.Cells[cClassesColUnits , Row] := IntToStr(C.UnitsReferencing.Count); 385 | StringGridClasses.Cells[cClassesColFileName , Row] := C.FileName; 386 | end; 387 | 388 | var 389 | Classes: TObjectList; 390 | C: TDelphiClass; 391 | Row: Integer; 392 | begin 393 | Classes:=TObjectList.Create(False); 394 | try 395 | fProject.GetClassesSorted(SortCol, Ascending, Classes); 396 | LabelClasses.Caption:='Showing ' + IntToStr(Classes.Count) + ' classes'; 397 | StringGridClasses.RowCount:=1+Classes.Count; 398 | Row:=1; 399 | for C in Classes do 400 | begin 401 | AddRow(C, Row); 402 | Inc(Row) 403 | end; 404 | finally 405 | FreeAndnil(Classes); 406 | end; 407 | end; 408 | 409 | procedure TFormMain.Log(S: String; Level: TLogLevel); 410 | begin 411 | case Level of 412 | llInfo : MemoLog.Lines.Add(s); 413 | llWarning: MemoLog.Lines.Add('Warning: ' + s); 414 | llError : MemoLog.Lines.Add('ERROR: ' + s); 415 | end; 416 | end; 417 | 418 | procedure TFormMain.Open1Click(Sender: TObject); 419 | begin 420 | if OpenDialogProject.Execute then 421 | begin 422 | fProject.LoadFromFile(OpenDialogProject.FileName); 423 | EditRoot.Text:=fProject.Settings.RootFileName; 424 | ListBoxSearchPaths.Items.Assign(fProject.Settings.SearchDirs); 425 | CheckControls; 426 | end; 427 | end; 428 | 429 | procedure TFormMain.UpdateGexf(); 430 | var 431 | Exporter: TGexfExport; 432 | Options: TGexfExportOptions; 433 | begin 434 | Options:=[]; 435 | if CheckBoxGexfIntfUses.Checked then 436 | Options:=Options + [gexfExportIntfUses]; 437 | if CheckBoxGexfImplUses.Checked then 438 | Options:=Options + [gexfExportImplUses]; 439 | Exporter:=TGexfExport.Create; 440 | try 441 | Exporter.ExportProjectToStrings(fProject, MemoGEXF.Lines, Options); 442 | finally 443 | FreeAndNil(Exporter); 444 | end; 445 | end; 446 | 447 | procedure TFormMain.UpdateJson(); 448 | var 449 | Exporter: TJSONExport; 450 | Options : TJSONExportOptions; 451 | begin 452 | Options:=[]; 453 | if CheckBoxJSONInterfaceUses.Checked then 454 | Options:=Options + [JSONExportIntfUses]; 455 | if CheckBoxJSONImplementationUses.Checked then 456 | Options:=Options + [JSONExportImplUses]; 457 | Exporter:=TJSONExport.Create; 458 | try 459 | Exporter.ExportProjectToStrings(fProject, MemoJSON.Lines, Options); 460 | finally 461 | FreeAndNil(Exporter); 462 | end; 463 | end; 464 | 465 | procedure TFormMain.UpdateIgnoredFiles; 466 | begin 467 | fProject.GetIgnoredFiles(MemoIgnoredFiles.Lines) 468 | end; 469 | 470 | procedure TFormMain.PageControl1Change(Sender: TObject); 471 | begin 472 | if PageControl1.ActivePage = TabSheetGEXF then 473 | UpdateGexf() 474 | else if PageControl1.ActivePage = TabSheetJSON then 475 | UpdateJSON() 476 | else if PageControl1.ActivePage = TabSheetIgnoredFiles then 477 | UpdateIgnoredFiles() 478 | end; 479 | 480 | procedure TFormMain.ParseFile(FileName: String); 481 | begin 482 | fProject.ProgressProc:=Progress; 483 | fProject.Parse(FileName, Log); 484 | if ConfirmYesNo('Analyse references to classes? This may take several minutes?') then 485 | fProject.AnalyseClassReferences; 486 | Log(''); 487 | Log('Done.'); 488 | MemoLog.SelStart:=Length(MemoLog.Text); 489 | LoadStatsGrid(duName, True, CheckBoxShowExternalUnits.Checked); 490 | LoadClassesGrid(dcName, True); 491 | //fProject.UnParse(MemoLog.Lines); 492 | end; 493 | 494 | procedure TFormMain.Progress(I, Total: Integer); 495 | begin 496 | I:=Max(I, 1); 497 | I:=Min(I, Total); 498 | ProgressBarAnalyse.Min:=1; 499 | ProgressBarAnalyse.Max:=Total; 500 | ProgressBarAnalyse.Position:=I; 501 | end; 502 | 503 | procedure TFormMain.SaveProject1Click(Sender: TObject); 504 | begin 505 | if SaveDialogProject.Execute then 506 | fProject.SaveToFile(SaveDialogProject.FileName); 507 | end; 508 | 509 | function TFormMain.UnitStatTypeForCol(Col: Integer): TDelphiUnitStatType; 510 | begin 511 | case col of 512 | cStatsColName : Result:= duName; 513 | cStatsColIntfUses : Result:= duIntfUses; 514 | cStatsColImplUses : Result:= duImplUses; 515 | cStatsColIntfRefs : Result:= duIntfRefs; 516 | cStatsColImplRefs : Result:= duImplRefs; 517 | cStatsColLineCount : Result:= duLineCount; 518 | cStatsColWeighting : Result:= duWeighting; 519 | cStatsColDepth : Result:= duDepth; 520 | cStatsColDepthDiff : Result:= duDepthDiff; 521 | cStatsColIntfClasses : Result:= duClasses; 522 | cStatsColIntfProcs : Result:= duRoutines; 523 | cStatsColFileName : Result:= duFileName; 524 | cStatsColIntfDependency : Result:= duIntfDependency; 525 | cStatsColImplDependency : Result:= duImplDependency; 526 | cStatsColCyclic : Result:= duCyclic 527 | else 528 | raise Exception.Create('UnitStatTypeForCol: unknown column'); 529 | end 530 | end; 531 | 532 | function TFormMain.ClassStatTypeForCol(Col: Integer): TDelphiClassStatType; 533 | begin 534 | case col of 535 | cClassesColName : Result:= dcName; 536 | cClassesColPrivateProcs : Result:= dcPrivateRoutines; 537 | cClassesColProtectedProcs : Result:= dcProtectedRoutines; 538 | cClassesColPublicProcs : Result:= dcPublicRoutines; 539 | cClassesColPublishedProcs : Result:= dcPublishedRoutines; 540 | cClassesColProperties : Result:= dcProperties; 541 | cClassesColUnits : Result:= dcUnitsReferencing; 542 | cClassesColFileName : Result:= dcFileName; 543 | else 544 | raise Exception.Create('ClassStatTypeForCol: unknown column'); 545 | end 546 | end; 547 | 548 | procedure TFormMain.StringGridClassesDrawCell(Sender: TObject; ACol, 549 | ARow: Integer; Rect: TRect; State: TGridDrawState); 550 | var 551 | SaveBrush: TBrushRecall; 552 | SaveFont : TFontRecall; 553 | begin 554 | with Sender as TStringGrid do 555 | begin 556 | SaveBrush:=TBrushRecall.Create(Canvas.Brush); 557 | SaveFont :=TFontRecall.Create(Canvas.Font); 558 | try 559 | if gdFixed in State then 560 | begin 561 | Canvas.Brush.Color := clNavy; 562 | Canvas.Font.Color := clWhite; 563 | end; 564 | Canvas.FillRect(Rect); 565 | if gdSelected in State then 566 | begin 567 | Canvas.Brush.Color := clSkyBlue; 568 | Canvas.Font.Style:=Canvas.Font.Style + [fsBold]; 569 | end; 570 | Canvas.TextOut(Rect.Left+2,Rect.Top+2, Cells[ACol, ARow]); 571 | finally 572 | FreeAndNil(SaveBrush); 573 | FreeAndNil(SaveFont); 574 | end; 575 | end; 576 | end; 577 | 578 | 579 | procedure TFormMain.StringGridClassesMouseDown(Sender: TObject; 580 | Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 581 | 582 | function ColWasAscending(Col: Integer): Boolean; 583 | begin 584 | Result:= Boolean(StringGridClasses.Objects [Col, 0]) 585 | end; 586 | 587 | procedure SetColSortOrder(Col: Integer; Ascending: Boolean); 588 | begin 589 | StringGridClasses.Objects [Col, 0] := TObject(Ascending); 590 | end; 591 | 592 | procedure SortGrid(Col: Integer); 593 | var 594 | WasAscending: Boolean; 595 | begin 596 | WasAscending:=ColWasAscending(Col); 597 | LoadClassesGrid(ClassStatTypeForCol(Col), not WasAscending); 598 | SetColSortOrder(Col, not WasAscending); 599 | end; 600 | 601 | var 602 | ACol, ARow: Integer; 603 | begin 604 | StringGridClasses.MouseToCell(X, Y, ACol, ARow); 605 | if (ARow = 0) then 606 | begin 607 | SortGrid(ACol); 608 | //ListBoxUnits.Clear; 609 | end 610 | end; 611 | 612 | procedure TFormMain.StringGridClassesSelectCell(Sender: TObject; ACol, 613 | ARow: Integer; var CanSelect: Boolean); 614 | 615 | var 616 | SelectedClass: TDelphiClass; 617 | StatType: TDelphiClassStatType; 618 | begin 619 | if (ARow > 0) then 620 | begin 621 | if StringGridClasses.Objects[0, ARow] is TDelphiClass then 622 | begin 623 | StatType:=ClassStatTypeForCol(ACol); 624 | SelectedClass:=StringGridClasses.Objects[0, ARow] as TDelphiClass; 625 | SelectedClass.GetStatDetails(StatType, ListBoxClassDetails.Items); 626 | end 627 | else 628 | ListBoxClassDetails.Clear; 629 | end 630 | end; 631 | 632 | procedure TFormMain.StringGridStatsDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); 633 | var 634 | SaveBrush: TBrushRecall; 635 | SaveFont : TFontRecall; 636 | begin 637 | with Sender as TStringGrid do 638 | begin 639 | SaveBrush:=TBrushRecall.Create(Canvas.Brush); 640 | SaveFont :=TFontRecall.Create(Canvas.Font); 641 | try 642 | if gdFixed in State then 643 | begin 644 | Canvas.Brush.Color := clNavy; 645 | Canvas.Font.Color := clWhite; 646 | end; 647 | Canvas.FillRect(Rect); 648 | if gdSelected in State then 649 | begin 650 | Canvas.Brush.Color := clSkyBlue; 651 | Canvas.Font.Style:=Canvas.Font.Style + [fsBold]; 652 | end; 653 | Canvas.TextOut(Rect.Left+2,Rect.Top+2, Cells[ACol, ARow]); 654 | finally 655 | FreeAndNil(SaveBrush); 656 | FreeAndNil(SaveFont); 657 | end; 658 | end; 659 | end; 660 | 661 | procedure TFormMain.StringGridStatsMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 662 | 663 | function ColWasAscending(Col: Integer): Boolean; 664 | begin 665 | Result:= Boolean(StringGridStats.Objects [Col, 0]) 666 | end; 667 | 668 | procedure SetColSortOrder(Col: Integer; Ascending: Boolean); 669 | begin 670 | StringGridStats.Objects [Col, 0] := TObject(Ascending); 671 | end; 672 | 673 | procedure SortGrid(Col: Integer); 674 | var 675 | WasAscending: Boolean; 676 | begin 677 | WasAscending:=ColWasAscending(Col); 678 | LoadStatsGrid(UnitStatTypeForCol(Col), not WasAscending, CheckBoxShowExternalUnits.Checked); 679 | SetColSortOrder(Col, not WasAscending); 680 | end; 681 | 682 | var 683 | ACol, ARow: Integer; 684 | begin 685 | StringGridStats.MouseToCell(X, Y, ACol, ARow); 686 | if (ARow = 0) then 687 | begin 688 | SortGrid(ACol); 689 | ListBoxUnits.Clear; 690 | end 691 | end; 692 | 693 | procedure TFormMain.StringGridStatsSelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); 694 | var 695 | SelectedUnit: TDelphiUnit; 696 | begin 697 | if (ARow > 0) then 698 | begin 699 | if StringGridStats.Objects[0, ARow] is TDelphiUnit then 700 | begin 701 | SelectedUnit:=StringGridStats.Objects[0, ARow] as TDelphiUnit; 702 | SelectedUnit.GetStatDetails(UnitStatTypeForCol(ACol), ListBoxUnits.Items); 703 | end 704 | else 705 | ListBoxUnits.Clear; 706 | end 707 | end; 708 | 709 | end. 710 | -------------------------------------------------------------------------------- /ProjectSettings.pas: -------------------------------------------------------------------------------- 1 | unit ProjectSettings; 2 | 3 | interface 4 | 5 | uses 6 | Classes; 7 | 8 | type 9 | 10 | TProjectSettings = class 11 | private 12 | fRootFileName: String; 13 | fSearchDirs: TStrings; 14 | public 15 | constructor Create; 16 | destructor Destroy; override; 17 | 18 | procedure LoadFromFile(FileName: String); 19 | procedure SaveToFile(FileName: String); 20 | 21 | property RootFileName: String read fRootFileName write fRootFileName; 22 | property SearchDirs: TStrings read fSearchDirs; 23 | 24 | end; 25 | 26 | implementation 27 | 28 | uses 29 | IoUtils, 30 | System.JSON, 31 | SysUtils; 32 | 33 | { TProjectSettings } 34 | 35 | constructor TProjectSettings.Create; 36 | begin 37 | fRootFileName:=''; 38 | fSearchDirs:=TStringList.Create; 39 | end; 40 | 41 | destructor TProjectSettings.Destroy; 42 | begin 43 | FreeAndNil(fSearchDirs); 44 | inherited; 45 | end; 46 | 47 | procedure TProjectSettings.LoadFromFile(FileName: String); 48 | var 49 | Text : String; 50 | JSON : TJSONValue; 51 | DirArray: TJSONArray; 52 | Dir : TJSONValue; 53 | begin 54 | fRootFileName:=''; 55 | fSearchDirs.Clear; 56 | Text := TFile.ReadAllText(FileName); 57 | JSON := TJSonObject.ParseJSONValue(Text); 58 | try 59 | if JSON is TJSONObject then 60 | begin 61 | fRootFileName:=(JSON as TJSONObject).GetValue('RootFileName'); 62 | DirArray:=(JSON as TJSONObject).GetValue('SearchDirs') as TJSONArray; 63 | if DirArray <> nil then 64 | begin 65 | for Dir in DirArray do 66 | fSearchDirs.Add(Dir.Value); 67 | end; 68 | end; 69 | finally 70 | FreeAndNil(JSON); 71 | end; 72 | end; 73 | 74 | procedure TProjectSettings.SaveToFile(FileName: String); 75 | var 76 | JSON: TJSONObject; 77 | JSONDirs: TJsonArray; 78 | Dir : String; 79 | begin 80 | JSON:=TJSONObject.Create; 81 | try 82 | 83 | JSON.AddPair('RootFileName', fRootFileName); 84 | 85 | JSONDirs:=TJsonArray.Create; 86 | for Dir in fSearchDirs do 87 | JSONDirs.Add(Dir); 88 | JSON.AddPair('SearchDirs', JSONDirs); 89 | TFile.WriteAllText(fileName, JSON.ToJSON()); 90 | 91 | finally 92 | FreeAndNil(JSON); 93 | end; 94 | end; 95 | 96 | end. 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DelphiUsesGraph 2 | 3 | A small, VERY fast micro parser to analyse very large Delphi projects (it can cope with million line projects and thousands of modules with ease). Provides an export to Gephi for graph analysis of unit dependencies. 4 | 5 | ## What it does 6 | 7 | DelphiUsesGraph allows the user to configure a small project file containing a main .pas file, and a list of library paths to other .pas source files. 8 | 9 | When 'Analyse' is clicked, the parser does the following:- 10 | 11 | - The parser acquires a list of all the delphi files it can find in the specified directories, and their subdirectories 12 | - It then scans the files, from the root file down, and extracts interface and implementations uses, plus interface procedure/function names 13 | - An analysis of the parse graph is conducted, and statistics are gathered 14 | - These statistics are shown in a grid on the Statistics tab. Each row of the grid contains details for one unit analysed. Details include:- 15 | - Unit name 16 | - Number of units used from the interface 17 | - Number of units used from the implementation 18 | - Number of units referencing this unit from their interface 19 | - Number of units referencing this unit from their implementation 20 | - Number of lines of code in the unit 21 | - Number of classes in the unit's interface, and their methods 22 | - Number of routines in the unit's interface 23 | - Whether the unit has or depends on cylic uses structures 24 | - Clicking on any cell will give a breakdown in the list view below 25 | - The GEXF tab creates an XML graph structure of your project in a format (GEXF) that Gephi can import. Gephi is an open source graph anlyser, which may help you make sense of the structure of your project. 26 | 27 | ## What it doesn't do 28 | 29 | DelphiUsesGraph is NOT a compiler. It should only be used on successfuly compiled projects:- 30 | 31 | - It won't check for syntactic errors 32 | - It won't check types, method signatures, inheritance or anything else involving processor time 33 | - It won't generate code 34 | 35 | The parser is VERY resilient to errors, and in the event of almost any error it will simply continue. 36 | 37 | ## Operating instructions 38 | 39 | - Launch the program 40 | - Select your root .pas file (typically the main form for a VCL project) 41 | - Specify a list of directories to search (each is searched recursiively, so this is usually very easy) 42 | - If you wish, save your project file for later use 43 | - Click 'Analyse'. You should get results in a few seconds 44 | - Explore your project from the statistics tab 45 | - If you wish, copy the GEXF XML and import into Gephi. 46 | 47 | ## Building instructions 48 | 49 | This has been built for Delphi 10.2.3. The tests use DUnitX, and it should build without issue. Note that I had an older library reference to an earlier external DUnitX build which I had to remove, so check for this if you encouter build errors when building tests. 50 | 51 | Enjoy! 52 | -------------------------------------------------------------------------------- /Tests/LexicalAnalyserTests.pas: -------------------------------------------------------------------------------- 1 | unit LexicalAnalyserTests; 2 | 3 | interface 4 | uses 5 | DUnitX.TestFramework, 6 | LexicalAnalyser; 7 | 8 | type 9 | 10 | [TestFixture] 11 | TLexicalAnalyserTests = class 12 | private 13 | public 14 | [Setup] 15 | procedure Setup; 16 | [TearDown] 17 | procedure TearDown; 18 | // Sample Methods 19 | // Simple single Test 20 | [Test] 21 | [TestCase('Empty', ', True')] 22 | [TestCase('Non-empty', 'X, False')] 23 | procedure TestEOF(const InputString : String; const ExpectedResult: Boolean); 24 | 25 | [Test] 26 | [TestCase('Number: Simple Integer', '1,1')] 27 | [TestCase('Number: Simple Integer And Other', '1 X,1')] 28 | [TestCase('Number: Double Digit', '12,12')] 29 | [TestCase('Number: Decimal', '12.1 X,12.1')] 30 | [TestCase('Number: DoubleDecimal', '12.21 X,12.21')] 31 | [TestCase('Number: Hex', '$12 X,$12')] 32 | procedure TestNumbers(const InputString : String; const ExpectedResult: String); 33 | 34 | [Test] 35 | [TestCase('Whitespace: Simple Space', 'A B,A,B')] 36 | [TestCase('Whitespace: Tab Between Chars', 'A'#9'B,A,B')] 37 | [TestCase('Whitespace: NewLine', 'A'#13#10'B,A,B')] 38 | procedure TestWhitespace(const InputString : String; const FirstString, SecondString: String); 39 | 40 | [Test] 41 | [TestCase('Comment: Traditional ', 'A (*comment*) B,A,B')] 42 | [TestCase('Comment: Traditional non-terminated', 'A (*comment,A,'#0)] 43 | [TestCase('Comment: Traditional compact', 'A(*comment*)B,A,B')] 44 | [TestCase('Comment: Multi-line traditional', 'A (*A comment'#13#10'another line'#13#10'*) B,A,B')] 45 | [TestCase('Comment: Brace', 'A {comment} B,A,B')] 46 | [TestCase('Comment: Brace compact', 'A{comment}B,A,B')] 47 | [TestCase('Comment: Multi-line brace', 'A{A comment'#13#10'another line'#13#10'}B,A,B')] 48 | [TestCase('Comment: Brace within traditional', 'A (* {A comment} *) B,A,B')] 49 | [TestCase('Comment: Traditional within brace', 'A {(* A comment *) } B,A,B')] 50 | [TestCase('Comment: Single line', 'A// A comment'#13#10'B,A,B')] 51 | [TestCase('Comment: Single line LF', 'A// A comment'#10'B,A,B')] 52 | procedure TestComments(const InputString : String; const FirstString, SecondString: String); 53 | 54 | [Test] 55 | [TestCase('Identifier: Single character', 'A B,A,B')] 56 | [TestCase('Identifier: Starts with underscore', '_A B,_A,B')] 57 | [TestCase('Identifier: Ends with underscore', 'A_ B,A_,B')] 58 | [TestCase('Identifier: Contains digits and underscores', 'A_123 B,A_123,B')] 59 | procedure TestIdentifier(const InputString : String; const FirstString, SecondString: String); 60 | 61 | [Test] 62 | [TestCase('Unary: -ve identifier', '-A,-,A')] 63 | [TestCase('Unary: +ve identifier', '+A,+,A')] 64 | [TestCase('Unary: not identifier', 'not A,not,A')] 65 | procedure TestUnary(const InputString : String; const Op, Operand: String); 66 | 67 | [Test] 68 | [TestCase('Binary: add', 'A+B,A,+,B')] 69 | [TestCase('Binary: subtract', 'A-B,A,-,B')] 70 | [TestCase('Binary: multiply', 'A*B,A,*,B')] 71 | [TestCase('Binary: divide', 'A/B,A,/,B')] 72 | [TestCase('Binary: div', 'A div B,A,div,B')] 73 | [TestCase('Binary: mod', 'A mod B,A,mod,B')] 74 | [TestCase('Binary: equal', 'A = B,A,=,B')] 75 | [TestCase('Binary: not equal', 'A <> B,A,<>,B')] 76 | [TestCase('Binary: less', 'A < B,A,<,B')] 77 | [TestCase('Binary: less equal', 'A <= B,A,<=,B')] 78 | [TestCase('Binary: greater', 'A > B,A,>,B')] 79 | [TestCase('Binary: greater equal', 'A >= B,A,>=,B')] 80 | [TestCase('Binary: range', 'A..B,A,..,B')] 81 | procedure TestBinary(const InputString : String; const Operand1, Op, Operand2: String); 82 | 83 | [Test] 84 | [TestCase('Parenthesis: simple', '(A),(,A,)')] 85 | [TestCase('Parenthesis: array', '[A],[,A,]')] 86 | procedure TestParenthesis(const InputString : String; const Open, Content, Close: String); 87 | 88 | [Test] 89 | [TestCase('Previous', 'A = B,=,A')] 90 | procedure TestPrevious(const InputString : String; const Previous0, Previous1: String); 91 | 92 | end; 93 | 94 | implementation 95 | 96 | uses 97 | SysUtils; 98 | 99 | procedure TLexicalAnalyserTests.Setup; 100 | begin 101 | end; 102 | 103 | procedure TLexicalAnalyserTests.TearDown; 104 | begin 105 | 106 | end; 107 | 108 | procedure TLexicalAnalyserTests.TestBinary(const InputString, Operand1, Op, Operand2: String); 109 | var 110 | Lex: TLexicalAnalyser; 111 | Operand1Sym: String; 112 | OperatorSym: String; 113 | Operand2Sym: String; 114 | begin 115 | Lex:=TLexicalAnalyser.CreateFromString(InputString); 116 | try 117 | Operand1Sym := Lex.CurrentSym; 118 | OperatorSym := Lex.GetSym; 119 | Operand2Sym := Lex.GetSym; 120 | Assert.AreEqual(Operand1Sym, Operand1); 121 | Assert.AreEqual(OperatorSym, Op); 122 | Assert.AreEqual(Operand2Sym, Operand2); 123 | finally 124 | FreeAndNil(Lex); 125 | end; 126 | end; 127 | 128 | procedure TLexicalAnalyserTests.TestComments(const InputString, FirstString, SecondString: String); 129 | var 130 | Lex: TLexicalAnalyser; 131 | FirstSym: String; 132 | SecondSym: String; 133 | begin 134 | Lex:=TLexicalAnalyser.CreateFromString(InputString); 135 | try 136 | FirstSym := Lex.CurrentSym; 137 | SecondSym := Lex.GetSym; 138 | Assert.AreEqual(FirstSym, FirstString); 139 | Assert.AreEqual(SecondSym, SecondString); 140 | finally 141 | FreeAndNil(Lex); 142 | end; 143 | end; 144 | 145 | procedure TLexicalAnalyserTests.TestEOF(const InputString: String; const ExpectedResult: Boolean); 146 | var 147 | Lex: TLexicalAnalyser; 148 | begin 149 | try 150 | Lex:=TLexicalAnalyser.CreateFromString(InputString); 151 | try 152 | Assert.AreEqual(Lex.AtEnd, ExpectedResult); 153 | finally 154 | FreeAndNil(Lex); 155 | end; 156 | except 157 | on E: Exception do 158 | 159 | end; 160 | end; 161 | 162 | 163 | procedure TLexicalAnalyserTests.TestIdentifier(const InputString, FirstString, SecondString: String); 164 | var 165 | Lex: TLexicalAnalyser; 166 | FirstSym: String; 167 | SecondSym: String; 168 | begin 169 | Lex:=TLexicalAnalyser.CreateFromString(InputString); 170 | try 171 | FirstSym := Lex.CurrentSym; 172 | SecondSym := Lex.GetSym; 173 | Assert.AreEqual(FirstSym, FirstString); 174 | Assert.AreEqual(SecondSym, SecondString); 175 | finally 176 | FreeAndNil(Lex); 177 | end; 178 | end; 179 | 180 | procedure TLexicalAnalyserTests.TestNumbers(const InputString, ExpectedResult: String); 181 | var 182 | Lex: TLexicalAnalyser; 183 | Sym: String; 184 | begin 185 | Lex:=TLexicalAnalyser.CreateFromString(InputString); 186 | try 187 | Sym := Lex.CurrentSym; 188 | Assert.AreEqual(Sym, ExpectedResult); 189 | finally 190 | FreeAndNil(Lex); 191 | end; 192 | end; 193 | 194 | procedure TLexicalAnalyserTests.TestParenthesis(const InputString, Open, Content, Close: String); 195 | var 196 | Lex: TLexicalAnalyser; 197 | OpenSym: String; 198 | ContentSym: String; 199 | CloseSym: String; 200 | begin 201 | Lex:=TLexicalAnalyser.CreateFromString(InputString); 202 | try 203 | OpenSym := Lex.CurrentSym; 204 | ContentSym := Lex.GetSym; 205 | CloseSym := Lex.GetSym; 206 | Assert.AreEqual(OpenSym, Open); 207 | Assert.AreEqual(ContentSym, Content); 208 | Assert.AreEqual(CloseSym, Close); 209 | finally 210 | FreeAndNil(Lex); 211 | end; 212 | end; 213 | 214 | procedure TLexicalAnalyserTests.TestPrevious(const InputString, Previous0, Previous1: String); 215 | var 216 | Lex: TLexicalAnalyser; 217 | FirstSym: String; 218 | SecondSym: String; 219 | ThirdSym: String; 220 | begin 221 | Lex:=TLexicalAnalyser.CreateFromString(InputString); 222 | try 223 | FirstSym := Lex.CurrentSym; 224 | SecondSym := Lex.GetSym; 225 | ThirdSym := Lex.GetSym; 226 | Assert.AreEqual(Lex.PreviousSym(0), Previous0); 227 | Assert.AreEqual(Lex.PreviousSym(1), Previous1); 228 | finally 229 | FreeAndNil(Lex); 230 | end; 231 | end; 232 | 233 | procedure TLexicalAnalyserTests.TestUnary(const InputString, Op, Operand: String); 234 | var 235 | Lex: TLexicalAnalyser; 236 | FirstSym: String; 237 | SecondSym: String; 238 | begin 239 | Lex:=TLexicalAnalyser.CreateFromString(InputString); 240 | try 241 | FirstSym := Lex.CurrentSym; 242 | SecondSym := Lex.GetSym; 243 | Assert.AreEqual(FirstSym, Op); 244 | Assert.AreEqual(SecondSym, Operand); 245 | finally 246 | FreeAndNil(Lex); 247 | end; 248 | end; 249 | 250 | procedure TLexicalAnalyserTests.TestWhitespace(const InputString, FirstString, SecondString: String); 251 | var 252 | Lex: TLexicalAnalyser; 253 | FirstSym: String; 254 | SecondSym: String; 255 | begin 256 | Lex:=TLexicalAnalyser.CreateFromString(InputString); 257 | try 258 | FirstSym := Lex.CurrentSym; 259 | SecondSym := Lex.GetSym; 260 | Assert.AreEqual(FirstSym, FirstString); 261 | Assert.AreEqual(SecondSym, SecondString); 262 | finally 263 | FreeAndNil(Lex); 264 | end; 265 | end; 266 | 267 | 268 | initialization 269 | TDUnitX.RegisterTestFixture(TLexicalAnalyserTests); 270 | end. 271 | -------------------------------------------------------------------------------- /Tests/Tests.dpr: -------------------------------------------------------------------------------- 1 | program Tests; 2 | {$WARN DUPLICATE_CTOR_DTOR OFF} 3 | {--$IFNDEF TESTINSIGHT} 4 | {--$APPTYPE CONSOLE} 5 | {--$ENDIF}{$STRONGLINKTYPES ON} 6 | uses 7 | System.SysUtils, 8 | Vcl.Forms, 9 | DUnitX.Loggers.Console, 10 | DUnitX.Loggers.Xml.NUnit, 11 | DUnitX.Loggers.GUIVCL, 12 | DUnitX.TestRunner, 13 | DUnitX.TestFramework, 14 | LexicalAnalyserTests in 'LexicalAnalyserTests.pas', 15 | LexicalAnalyser in '..\LexicalAnalyser.pas'; 16 | 17 | begin 18 | Application.Initialize; 19 | Application.Title := 'DUnitX'; 20 | Application.CreateForm(TGUIVCLTestRunner, GUIVCLTestRunner); 21 | Application.Run; 22 | end. 23 | -------------------------------------------------------------------------------- /Tests/Tests.dproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {2FC2E2A1-3063-4DE9-BDE7-DBF2820411D2} 4 | 18.8 5 | None 6 | Tests.dpr 7 | True 8 | Debug 9 | Win32 10 | 1 11 | Console 12 | 13 | 14 | true 15 | 16 | 17 | true 18 | Base 19 | true 20 | 21 | 22 | true 23 | Base 24 | true 25 | 26 | 27 | true 28 | Cfg_1 29 | true 30 | true 31 | 32 | 33 | true 34 | Base 35 | true 36 | 37 | 38 | .\$(Platform)\$(Config) 39 | .\$(Platform)\$(Config) 40 | false 41 | false 42 | false 43 | false 44 | false 45 | RESTComponents;FireDACIBDriver;FireDACCommon;RESTBackendComponents;soapserver;CloudService;FireDACCommonDriver;inet;FireDAC;FireDACSqliteDriver;soaprtl;soapmidas;$(DCC_UsePackage) 46 | System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace) 47 | true 48 | $(BDS)\bin\delphi_PROJECTICON.ico 49 | $(BDS)\bin\delphi_PROJECTICNS.icns 50 | $(DUnitX);$(DCC_UnitSearchPath) 51 | Tests 52 | 53 | 54 | DBXSqliteDriver;DBXInterBaseDriver;vclactnband;vclFireDAC;tethering;svnui;FireDACADSDriver;rbRCL1825;rbDAD1825;rbADO1825;dclRBE1825;tmsxlsdXE11;vcltouch;RpsCodeTidy;vcldb;bindcompfmx;svn;Intraweb;rbUSER1825;rbFireDAC1825;inetdb;RaizeComponentsVcl;RpsDesktop;FmxTeeUI;RpsVisualisors;RaizeComponentsVclDb;fmx;fmxdae;tmsdXE11;tmsexdXE11;dbexpress;IndyCore;rbIDE1825;rbRTL1825;RapideOTA;vclx;sdlbasepack_rt_106XT;dsnap;dclRBDBE1825;rbDIDE1825;GR32_DSGN_RSDELPHI10_2;VCLRESTComponents;rbUSERDesign1825;dclRBADO1825;vclie;bindengine;DBXMySQLDriver;FireDACMySQLDriver;FireDACCommonODBC;rbTCUI1825;rbRIDE1825;bindcompdbx;IndyIPCommon;vcl;IndyIPServer;IndySystem;sdlmathpack_106XT;dsnapcon;madExcept_;FireDACMSAccDriver;fmxFireDAC;rbTC1825;vclimg;madBasic_;TeeDB;rbRAP1825;rbBDE1825;FireDACPgDriver;FMXTee;DbxCommonDriver;rbDB1825;Tee;rbCIDE1825;xmlrtl;fmxobj;vclwinx;rtl;madDisAsm_;DbxClientDriver;sdlmathpack_rt_106XT;CustomIPTransport;vcldsnap;xdeviceDelphi10_2;bindcomp;appanalytics;tmswizdXE11;RpsCommon;IndyIPClient;bindcompvcl;rbRest1825;TeeUI;rbDBE1825;RpsGraphics;RPSControls;dbxcds;VclSmp;adortl;WclWiFiFrameworkR;GR32_RSDELPHI10_2;dsnapxml;dbrtl;inetdbxpress;IndyProtocols;RpsProjectTidy;dclRBFireDAC1825;fmxase;$(DCC_UsePackage) 55 | Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) 56 | Debug 57 | CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 58 | 1033 59 | 60 | 61 | DEBUG;$(DCC_Define) 62 | true 63 | false 64 | true 65 | true 66 | true 67 | 68 | 69 | false 70 | 71 | 72 | false 73 | RELEASE;$(DCC_Define) 74 | 0 75 | 0 76 | 77 | 78 | 79 | MainSource 80 | 81 | 82 | 83 | 84 | Cfg_2 85 | Base 86 | 87 | 88 | Base 89 | 90 | 91 | Cfg_1 92 | Base 93 | 94 | 95 | 96 | Delphi.Personality.12 97 | Console 98 | 99 | 100 | 101 | Tests.dpr 102 | 103 | 104 | 105 | 106 | 107 | Tests.exe 108 | true 109 | 110 | 111 | 112 | 113 | true 114 | 115 | 116 | 117 | 118 | true 119 | 120 | 121 | 122 | 123 | true 124 | 125 | 126 | 127 | 128 | true 129 | 130 | 131 | 132 | 133 | true 134 | 135 | 136 | 137 | 138 | 1 139 | 140 | 141 | 0 142 | 143 | 144 | 145 | 146 | classes 147 | 1 148 | 149 | 150 | classes 151 | 1 152 | 153 | 154 | 155 | 156 | res\xml 157 | 1 158 | 159 | 160 | res\xml 161 | 1 162 | 163 | 164 | 165 | 166 | library\lib\armeabi-v7a 167 | 1 168 | 169 | 170 | 171 | 172 | library\lib\armeabi 173 | 1 174 | 175 | 176 | library\lib\armeabi 177 | 1 178 | 179 | 180 | 181 | 182 | library\lib\armeabi-v7a 183 | 1 184 | 185 | 186 | 187 | 188 | library\lib\mips 189 | 1 190 | 191 | 192 | library\lib\mips 193 | 1 194 | 195 | 196 | 197 | 198 | library\lib\armeabi-v7a 199 | 1 200 | 201 | 202 | library\lib\arm64-v8a 203 | 1 204 | 205 | 206 | 207 | 208 | library\lib\armeabi-v7a 209 | 1 210 | 211 | 212 | 213 | 214 | res\drawable 215 | 1 216 | 217 | 218 | res\drawable 219 | 1 220 | 221 | 222 | 223 | 224 | res\values 225 | 1 226 | 227 | 228 | res\values 229 | 1 230 | 231 | 232 | 233 | 234 | res\values-v21 235 | 1 236 | 237 | 238 | res\values-v21 239 | 1 240 | 241 | 242 | 243 | 244 | res\values 245 | 1 246 | 247 | 248 | res\values 249 | 1 250 | 251 | 252 | 253 | 254 | res\drawable 255 | 1 256 | 257 | 258 | res\drawable 259 | 1 260 | 261 | 262 | 263 | 264 | res\drawable-xxhdpi 265 | 1 266 | 267 | 268 | res\drawable-xxhdpi 269 | 1 270 | 271 | 272 | 273 | 274 | res\drawable-ldpi 275 | 1 276 | 277 | 278 | res\drawable-ldpi 279 | 1 280 | 281 | 282 | 283 | 284 | res\drawable-mdpi 285 | 1 286 | 287 | 288 | res\drawable-mdpi 289 | 1 290 | 291 | 292 | 293 | 294 | res\drawable-hdpi 295 | 1 296 | 297 | 298 | res\drawable-hdpi 299 | 1 300 | 301 | 302 | 303 | 304 | res\drawable-xhdpi 305 | 1 306 | 307 | 308 | res\drawable-xhdpi 309 | 1 310 | 311 | 312 | 313 | 314 | res\drawable-mdpi 315 | 1 316 | 317 | 318 | res\drawable-mdpi 319 | 1 320 | 321 | 322 | 323 | 324 | res\drawable-hdpi 325 | 1 326 | 327 | 328 | res\drawable-hdpi 329 | 1 330 | 331 | 332 | 333 | 334 | res\drawable-xhdpi 335 | 1 336 | 337 | 338 | res\drawable-xhdpi 339 | 1 340 | 341 | 342 | 343 | 344 | res\drawable-xxhdpi 345 | 1 346 | 347 | 348 | res\drawable-xxhdpi 349 | 1 350 | 351 | 352 | 353 | 354 | res\drawable-xxxhdpi 355 | 1 356 | 357 | 358 | res\drawable-xxxhdpi 359 | 1 360 | 361 | 362 | 363 | 364 | res\drawable-small 365 | 1 366 | 367 | 368 | res\drawable-small 369 | 1 370 | 371 | 372 | 373 | 374 | res\drawable-normal 375 | 1 376 | 377 | 378 | res\drawable-normal 379 | 1 380 | 381 | 382 | 383 | 384 | res\drawable-large 385 | 1 386 | 387 | 388 | res\drawable-large 389 | 1 390 | 391 | 392 | 393 | 394 | res\drawable-xlarge 395 | 1 396 | 397 | 398 | res\drawable-xlarge 399 | 1 400 | 401 | 402 | 403 | 404 | res\values 405 | 1 406 | 407 | 408 | res\values 409 | 1 410 | 411 | 412 | 413 | 414 | 1 415 | 416 | 417 | 1 418 | 419 | 420 | 0 421 | 422 | 423 | 424 | 425 | 1 426 | .framework 427 | 428 | 429 | 1 430 | .framework 431 | 432 | 433 | 0 434 | 435 | 436 | 437 | 438 | 1 439 | .dylib 440 | 441 | 442 | 1 443 | .dylib 444 | 445 | 446 | 0 447 | .dll;.bpl 448 | 449 | 450 | 451 | 452 | 1 453 | .dylib 454 | 455 | 456 | 1 457 | .dylib 458 | 459 | 460 | 1 461 | .dylib 462 | 463 | 464 | 1 465 | .dylib 466 | 467 | 468 | 1 469 | .dylib 470 | 471 | 472 | 0 473 | .bpl 474 | 475 | 476 | 477 | 478 | 0 479 | 480 | 481 | 0 482 | 483 | 484 | 0 485 | 486 | 487 | 0 488 | 489 | 490 | 0 491 | 492 | 493 | 0 494 | 495 | 496 | 0 497 | 498 | 499 | 0 500 | 501 | 502 | 503 | 504 | 1 505 | 506 | 507 | 1 508 | 509 | 510 | 1 511 | 512 | 513 | 514 | 515 | 1 516 | 517 | 518 | 1 519 | 520 | 521 | 1 522 | 523 | 524 | 525 | 526 | 1 527 | 528 | 529 | 1 530 | 531 | 532 | 1 533 | 534 | 535 | 536 | 537 | 1 538 | 539 | 540 | 1 541 | 542 | 543 | 1 544 | 545 | 546 | 547 | 548 | 1 549 | 550 | 551 | 1 552 | 553 | 554 | 1 555 | 556 | 557 | 558 | 559 | 1 560 | 561 | 562 | 1 563 | 564 | 565 | 1 566 | 567 | 568 | 569 | 570 | 1 571 | 572 | 573 | 1 574 | 575 | 576 | 1 577 | 578 | 579 | 580 | 581 | 1 582 | 583 | 584 | 1 585 | 586 | 587 | 1 588 | 589 | 590 | 591 | 592 | 1 593 | 594 | 595 | 1 596 | 597 | 598 | 1 599 | 600 | 601 | 602 | 603 | 1 604 | 605 | 606 | 1 607 | 608 | 609 | 1 610 | 611 | 612 | 613 | 614 | 1 615 | 616 | 617 | 1 618 | 619 | 620 | 1 621 | 622 | 623 | 624 | 625 | 1 626 | 627 | 628 | 1 629 | 630 | 631 | 1 632 | 633 | 634 | 635 | 636 | 1 637 | 638 | 639 | 1 640 | 641 | 642 | 1 643 | 644 | 645 | 646 | 647 | 1 648 | 649 | 650 | 1 651 | 652 | 653 | 1 654 | 655 | 656 | 657 | 658 | 1 659 | 660 | 661 | 1 662 | 663 | 664 | 1 665 | 666 | 667 | 668 | 669 | 1 670 | 671 | 672 | 1 673 | 674 | 675 | 1 676 | 677 | 678 | 679 | 680 | 1 681 | 682 | 683 | 1 684 | 685 | 686 | 1 687 | 688 | 689 | 690 | 691 | 1 692 | 693 | 694 | 1 695 | 696 | 697 | 1 698 | 699 | 700 | 701 | 702 | 1 703 | 704 | 705 | 1 706 | 707 | 708 | 1 709 | 710 | 711 | 712 | 713 | 1 714 | 715 | 716 | 1 717 | 718 | 719 | 1 720 | 721 | 722 | 723 | 724 | 1 725 | 726 | 727 | 1 728 | 729 | 730 | 1 731 | 732 | 733 | 734 | 735 | 1 736 | 737 | 738 | 1 739 | 740 | 741 | 1 742 | 743 | 744 | 745 | 746 | 1 747 | 748 | 749 | 1 750 | 751 | 752 | 1 753 | 754 | 755 | 756 | 757 | 1 758 | 759 | 760 | 1 761 | 762 | 763 | 1 764 | 765 | 766 | 767 | 768 | 1 769 | 770 | 771 | 1 772 | 773 | 774 | 1 775 | 776 | 777 | 778 | 779 | 1 780 | 781 | 782 | 1 783 | 784 | 785 | 1 786 | 787 | 788 | 789 | 790 | 1 791 | 792 | 793 | 1 794 | 795 | 796 | 1 797 | 798 | 799 | 800 | 801 | 1 802 | 803 | 804 | 1 805 | 806 | 807 | 1 808 | 809 | 810 | 811 | 812 | 1 813 | 814 | 815 | 1 816 | 817 | 818 | 819 | 820 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 821 | 1 822 | 823 | 824 | ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 825 | 1 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 1 834 | 835 | 836 | 1 837 | 838 | 839 | 1 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | Contents\Resources 848 | 1 849 | 850 | 851 | Contents\Resources 852 | 1 853 | 854 | 855 | 856 | 857 | library\lib\armeabi-v7a 858 | 1 859 | 860 | 861 | library\lib\arm64-v8a 862 | 1 863 | 864 | 865 | 1 866 | 867 | 868 | 1 869 | 870 | 871 | 1 872 | 873 | 874 | 1 875 | 876 | 877 | 1 878 | 879 | 880 | 1 881 | 882 | 883 | 0 884 | 885 | 886 | 887 | 888 | library\lib\armeabi-v7a 889 | 1 890 | 891 | 892 | 893 | 894 | 1 895 | 896 | 897 | 1 898 | 899 | 900 | 901 | 902 | Assets 903 | 1 904 | 905 | 906 | Assets 907 | 1 908 | 909 | 910 | 911 | 912 | Assets 913 | 1 914 | 915 | 916 | Assets 917 | 1 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | True 933 | 934 | 935 | 12 936 | 937 | 938 | 939 | 940 | 941 | -------------------------------------------------------------------------------- /UsesGraph.dpr: -------------------------------------------------------------------------------- 1 | program UsesGraph; 2 | {$WARN DUPLICATE_CTOR_DTOR OFF} 3 | uses 4 | Vcl.Forms, 5 | Main in 'Main.pas' {FormMain}, 6 | DelphiUnit in 'DelphiUnit.pas', 7 | LexicalAnalyser in 'LexicalAnalyser.pas', 8 | DelphiProject in 'DelphiProject.pas', 9 | ProjectSettings in 'ProjectSettings.pas', 10 | GexfExport in 'GexfExport.pas', 11 | DelphiClass in 'DelphiClass.pas', 12 | JSONExport in 'JSONExport.pas'; 13 | 14 | {$R *.res} 15 | 16 | 17 | begin 18 | Application.Initialize; 19 | Application.MainFormOnTaskbar := True; 20 | Application.CreateForm(TFormMain, FormMain); 21 | Application.Run; 22 | end. 23 | -------------------------------------------------------------------------------- /UsesGraphFamily.groupproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {BB288398-0ABD-46C3-A683-E87F81131F07} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Default.Personality.12 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 | -------------------------------------------------------------------------------- /UsesGraphFamily.~dsk: -------------------------------------------------------------------------------- 1 | [Closed Files] 2 | File_0=TSourceModule,'c:\program files (x86)\embarcadero\studio\19.0\source\rtl\common\System.Generics.Collections.pas',0,1,4587,1,4608,0,0,, 3 | File_1=TSourceModule,'c:\program files (x86)\embarcadero\studio\19.0\SOURCE\VCL\Vcl.Grids.pas',0,1,5445,1,5466,0,0,, 4 | File_2=TSourceModule,'c:\program files (x86)\embarcadero\studio\19.0\SOURCE\RTL\SYS\System.pas',0,1,30218,1,30239,0,0,, 5 | File_3=TSourceModule,'c:\program files (x86)\embarcadero\studio\19.0\source\rtl\common\System.IOUtils.pas',0,1,2683,1,2704,0,0,, 6 | File_4=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\key_accounts_gridlet_control.pas',0,1,1,1,1,0,0,, 7 | File_5=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\main_contracts_gridlet_control.pas',0,1,1,1,1,0,0,, 8 | File_6=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\recent_mail_picker_control.pas',0,1,1,1,1,0,0,, 9 | File_7=TSourceModule,'C:\RPS\rpsinternal\Contract\Delphi\FormContract.pas',0,1,2374,5,2402,0,0,, 10 | File_8=TSourceModule,'C:\RPS\rpsinternal\Contract\Delphi\FormMain.pas',0,1,1,1,1,0,0,, 11 | File_9=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\main_form_form.pas',0,1,1,1,1,0,0,, 12 | File_10=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\key_accounts_gridlet_frame.pas',0,1,1,1,1,0,0,, 13 | File_11=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\main_contracts_gridlet_frame.pas',0,1,1,1,1,0,0,, 14 | File_12=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\task_filter_control.pas',0,1,1,1,1,0,0,, 15 | File_13=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\task_gridlet_control.pas',0,1,1,1,1,0,0,, 16 | File_14=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\outstanding_calls_gridlet_control.pas',0,1,1,1,1,0,0,, 17 | File_15=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\parked_calls_gridlet_control.pas',0,1,1,1,1,0,0,, 18 | File_16=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\payment_batches_gridlet_control.pas',0,1,1,1,1,0,0,, 19 | File_17=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\code_renewal_filter_control.pas',0,1,1,1,1,0,0,, 20 | File_18=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\contract_renewal_group_filter_control.pas',0,1,1,1,1,0,0,, 21 | File_19=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\hold_review_gridlet_control.pas',0,1,1,1,1,0,0,, 22 | File_20=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\failed_invoice_gridlet_control.pas',0,1,1,1,1,0,0,, 23 | File_21=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\new_business_filter_control.pas',0,1,1,1,1,0,0,, 24 | File_22=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\new_business_gridlet_control.pas',0,1,1,1,1,0,0,, 25 | File_23=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\paycentre_export_gridlet_control.pas',0,1,1,1,1,0,0,, 26 | File_24=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\suppliers_gridlet_control.pas',0,1,1,1,1,0,0,, 27 | File_25=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\recent_mail_picker_frame.pas',0,1,1,1,1,0,0,, 28 | File_26=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\sales_leads_gridlet_control.pas',0,1,1,1,1,0,0,, 29 | File_27=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\bundles_gridlet_control.pas',0,1,1,1,1,0,0,, 30 | File_28=TSourceModule,'C:\RPS\rpsinternal\Contract\generated\delphi\ranked_values_gridlet_control.pas',0,1,1,1,1,0,0,, 31 | File_29=TSourceModule,'C:\RPS\rpsinternal\Contract\Generated\Delphi\renewal_detail_gridlet_control.pas',0,1,1,1,1,0,0,, 32 | 33 | [Modules] 34 | Module0=C:\RPS\DelphiUsesGraph2\DelphiUnit.pas 35 | Module1=C:\RPS\DelphiUsesGraph2\DelphiClass.pas 36 | Module2=C:\RPS\DelphiUsesGraph2\DelphiProject.pas 37 | Module3=C:\RPS\DelphiUsesGraph2\LexicalAnalyser.pas 38 | Module4=C:\RPS\DelphiUsesGraph2\Tests\LexicalAnalyserTests.pas 39 | Module5=C:\RPS\DelphiUsesGraph2\Main.pas 40 | Module6=default.htm 41 | Module7=documentation.htm 42 | Count=8 43 | EditWindowCount=1 44 | 45 | [C:\RPS\DelphiUsesGraph2\DelphiUnit.pas] 46 | ModuleType=TSourceModule 47 | 48 | [C:\RPS\DelphiUsesGraph2\DelphiClass.pas] 49 | ModuleType=TSourceModule 50 | 51 | [C:\RPS\DelphiUsesGraph2\DelphiProject.pas] 52 | ModuleType=TSourceModule 53 | 54 | [C:\RPS\DelphiUsesGraph2\LexicalAnalyser.pas] 55 | ModuleType=TSourceModule 56 | 57 | [C:\RPS\DelphiUsesGraph2\Tests\LexicalAnalyserTests.pas] 58 | ModuleType=TSourceModule 59 | 60 | [C:\RPS\DelphiUsesGraph2\Main.pas] 61 | ModuleType=TSourceModule 62 | 63 | [default.htm] 64 | ModuleType=TURLModule 65 | 66 | [documentation.htm] 67 | ModuleType=TURLModule 68 | 69 | [EditWindow0] 70 | ViewCount=8 71 | CurrentEditView=C:\RPS\DelphiUsesGraph2\DelphiUnit.pas 72 | View0=0 73 | View1=1 74 | View2=2 75 | View3=3 76 | View4=4 77 | View5=5 78 | View6=6 79 | View7=7 80 | PercentageSizes=1 81 | Create=1 82 | Visible=1 83 | Docked=1 84 | State=0 85 | Left=0 86 | Top=0 87 | Width=10000 88 | Height=9290 89 | MaxLeft=-1 90 | MaxTop=-1 91 | ClientWidth=10000 92 | ClientHeight=9290 93 | DockedToMainForm=1 94 | BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 95 | TopPanelSize=0 96 | LeftPanelSize=1896 97 | LeftPanelClients=PropertyInspector,DockSite3 98 | LeftPanelData=00000800010100000000181600000000000001680700000000000001000000005B0E000009000000446F636B536974653301000000005A2300001100000050726F7065727479496E73706563746F72FFFFFFFF 99 | RightPanelSize=2000 100 | RightPanelClients=DockSite2,DockSite4 101 | RightPanelData=00000800010100000000181600000000000001D00700000000000001000000004B12000009000000446F636B536974653201000000005A23000009000000446F636B5369746534FFFFFFFF 102 | BottomPanelSize=0 103 | BottomPanelClients=DockSite1,MessageView 104 | BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D1534000000000000022706000000000000FFFFFFFF 105 | BottomMiddlePanelSize=0 106 | BottomMiddlePanelClients=DockSite0,GraphDrawingModel 107 | BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779F1D00000000000002F706000000000000FFFFFFFF 108 | 109 | [View0] 110 | CustomEditViewType=TWelcomePageView 111 | WelcomePageURL=bds:/default.htm 112 | 113 | [View1] 114 | CustomEditViewType=TWelcomePageView 115 | WelcomePageURL=bds:/documentation.htm 116 | 117 | [View2] 118 | CustomEditViewType=TEditView 119 | Module=C:\RPS\DelphiUsesGraph2\Main.pas 120 | CursorX=1 121 | CursorY=459 122 | TopLine=438 123 | LeftCol=1 124 | Elisions= 125 | Bookmarks= 126 | EditViewName=C:\RPS\DelphiUsesGraph2\Main.pas 127 | 128 | [View3] 129 | CustomEditViewType=TEditView 130 | Module=C:\RPS\DelphiUsesGraph2\LexicalAnalyser.pas 131 | CursorX=16 132 | CursorY=34 133 | TopLine=18 134 | LeftCol=1 135 | Elisions= 136 | Bookmarks= 137 | EditViewName=C:\RPS\DelphiUsesGraph2\LexicalAnalyser.pas 138 | 139 | [View4] 140 | CustomEditViewType=TEditView 141 | Module=C:\RPS\DelphiUsesGraph2\Tests\LexicalAnalyserTests.pas 142 | CursorX=39 143 | CursorY=226 144 | TopLine=204 145 | LeftCol=1 146 | Elisions= 147 | Bookmarks= 148 | EditViewName=C:\RPS\DelphiUsesGraph2\Tests\LexicalAnalyserTests.pas 149 | 150 | [View5] 151 | CustomEditViewType=TEditView 152 | Module=C:\RPS\DelphiUsesGraph2\DelphiProject.pas 153 | CursorX=57 154 | CursorY=257 155 | TopLine=256 156 | LeftCol=1 157 | Elisions= 158 | Bookmarks= 159 | EditViewName=C:\RPS\DelphiUsesGraph2\DelphiProject.pas 160 | 161 | [View6] 162 | CustomEditViewType=TEditView 163 | Module=C:\RPS\DelphiUsesGraph2\DelphiClass.pas 164 | CursorX=35 165 | CursorY=18 166 | TopLine=4 167 | LeftCol=1 168 | Elisions= 169 | Bookmarks= 170 | EditViewName=C:\RPS\DelphiUsesGraph2\DelphiClass.pas 171 | 172 | [View7] 173 | CustomEditViewType=TEditView 174 | Module=C:\RPS\DelphiUsesGraph2\DelphiUnit.pas 175 | CursorX=81 176 | CursorY=405 177 | TopLine=371 178 | LeftCol=1 179 | Elisions= 180 | Bookmarks= 181 | EditViewName=C:\RPS\DelphiUsesGraph2\DelphiUnit.pas 182 | 183 | [UndockedDesigner] 184 | Count=0 185 | 186 | [Watches] 187 | Count=0 188 | 189 | [WatchWindow] 190 | WatchColumnWidth=120 191 | WatchShowColumnHeaders=1 192 | PercentageSizes=1 193 | Create=1 194 | Visible=1 195 | Docked=1 196 | State=0 197 | Left=0 198 | Top=0 199 | Width=3823 200 | Height=1206 201 | MaxLeft=-1 202 | MaxTop=-1 203 | ClientWidth=3823 204 | ClientHeight=1206 205 | TBDockHeight=214 206 | LRDockWidth=13604 207 | Dockable=1 208 | StayOnTop=0 209 | 210 | [Breakpoints] 211 | Count=3 212 | Breakpoint0='C:\RPS\DelphiUsesGraph2\DelphiProject.pas',174,'',0,1,'',1,0,0,'',1,'','','',0,'' 213 | Breakpoint1='C:\RPS\DelphiUsesGraph2\DelphiUnit.pas',169,'',0,1,'',1,0,0,'',1,'','','',0,'' 214 | Breakpoint2='C:\RPS\DelphiUsesGraph2\Tests\LexicalAnalyserTests.pas',225,'',0,1,'',1,0,0,'',1,'','','',0,'' 215 | 216 | [EmbarcaderoWin32Debugger_AddressBreakpoints] 217 | Count=0 218 | 219 | [Main Window] 220 | PercentageSizes=1 221 | Create=1 222 | Visible=1 223 | Docked=0 224 | State=2 225 | Left=146 226 | Top=274 227 | Width=8932 228 | Height=8520 229 | MaxLeft=-5 230 | MaxTop=-9 231 | MaxWidth=8932 232 | MaxHeight=8520 233 | ClientWidth=10000 234 | ClientHeight=9803 235 | BottomPanelSize=9050 236 | BottomPanelClients=EditWindow0 237 | BottomPanelData=0000080000000000000000000000000000000000000000000000000100000000000000000C0000004564697457696E646F775F30FFFFFFFF 238 | 239 | [ProjectManager] 240 | PercentageSizes=1 241 | Create=1 242 | Visible=1 243 | Docked=1 244 | State=0 245 | Left=0 246 | Top=0 247 | Width=2000 248 | Height=4405 249 | MaxLeft=-1 250 | MaxTop=-1 251 | ClientWidth=2000 252 | ClientHeight=4405 253 | TBDockHeight=5902 254 | LRDockWidth=2349 255 | Dockable=1 256 | StayOnTop=0 257 | 258 | [MessageView] 259 | PercentageSizes=1 260 | Create=1 261 | Visible=0 262 | Docked=1 263 | State=0 264 | Left=0 265 | Top=0 266 | Width=2771 267 | Height=1420 268 | MaxLeft=-1 269 | MaxTop=-1 270 | ClientWidth=2771 271 | ClientHeight=1420 272 | TBDockHeight=1420 273 | LRDockWidth=2771 274 | Dockable=1 275 | StayOnTop=0 276 | 277 | [ToolForm] 278 | PercentageSizes=1 279 | Create=1 280 | Visible=1 281 | Docked=1 282 | State=0 283 | Left=0 284 | Top=0 285 | Width=2000 286 | Height=4328 287 | MaxLeft=-1 288 | MaxTop=-1 289 | ClientWidth=2000 290 | ClientHeight=4328 291 | TBDockHeight=7151 292 | LRDockWidth=2000 293 | Dockable=1 294 | StayOnTop=0 295 | 296 | [ClipboardHistory] 297 | PercentageSizes=1 298 | Create=1 299 | Visible=0 300 | Docked=0 301 | State=0 302 | Left=0 303 | Top=0 304 | Width=1969 305 | Height=3815 306 | MaxLeft=-5 307 | MaxTop=-9 308 | ClientWidth=1885 309 | ClientHeight=3482 310 | TBDockHeight=3815 311 | LRDockWidth=1969 312 | Dockable=1 313 | StayOnTop=0 314 | 315 | [ProjectStatistics] 316 | PercentageSizes=1 317 | Create=1 318 | Visible=0 319 | Docked=0 320 | State=0 321 | Left=0 322 | Top=0 323 | Width=1375 324 | Height=4388 325 | MaxLeft=-5 326 | MaxTop=-9 327 | ClientWidth=1292 328 | ClientHeight=4055 329 | TBDockHeight=4388 330 | LRDockWidth=1375 331 | Dockable=1 332 | StayOnTop=0 333 | 334 | [ClassBrowserTool] 335 | PercentageSizes=1 336 | Create=1 337 | Visible=0 338 | Docked=1 339 | State=0 340 | Left=-36 341 | Top=-141 342 | Width=1849 343 | Height=3139 344 | MaxLeft=-1 345 | MaxTop=-1 346 | ClientWidth=1849 347 | ClientHeight=3139 348 | TBDockHeight=3139 349 | LRDockWidth=1849 350 | Dockable=1 351 | StayOnTop=0 352 | 353 | [MetricsView] 354 | PercentageSizes=1 355 | Create=1 356 | Visible=1 357 | Docked=1 358 | State=0 359 | Left=0 360 | Top=0 361 | Width=2339 362 | Height=1266 363 | MaxLeft=-1 364 | MaxTop=-1 365 | ClientWidth=2339 366 | ClientHeight=1266 367 | TBDockHeight=4833 368 | LRDockWidth=3562 369 | Dockable=1 370 | StayOnTop=0 371 | 372 | [QAView] 373 | PercentageSizes=1 374 | Create=1 375 | Visible=1 376 | Docked=1 377 | State=0 378 | Left=0 379 | Top=0 380 | Width=2339 381 | Height=1266 382 | MaxLeft=-1 383 | MaxTop=-1 384 | ClientWidth=2339 385 | ClientHeight=1266 386 | TBDockHeight=4833 387 | LRDockWidth=3562 388 | Dockable=1 389 | StayOnTop=0 390 | 391 | [PropertyInspector] 392 | PercentageSizes=1 393 | Create=1 394 | Visible=1 395 | Docked=1 396 | State=0 397 | Left=0 398 | Top=459 399 | Width=1896 400 | Height=5364 401 | MaxLeft=-1 402 | MaxTop=-1 403 | ClientWidth=1896 404 | ClientHeight=5364 405 | TBDockHeight=9016 406 | LRDockWidth=1896 407 | Dockable=1 408 | StayOnTop=0 409 | SplitPos=111 410 | 411 | [frmDesignPreview] 412 | PercentageSizes=1 413 | Create=1 414 | Visible=1 415 | Docked=1 416 | State=0 417 | Left=0 418 | Top=0 419 | Width=2000 420 | Height=7305 421 | MaxLeft=-1 422 | MaxTop=-1 423 | ClientWidth=2000 424 | ClientHeight=7305 425 | TBDockHeight=5962 426 | LRDockWidth=2510 427 | Dockable=1 428 | StayOnTop=0 429 | 430 | [TFileExplorerForm] 431 | PercentageSizes=1 432 | Create=1 433 | Visible=0 434 | Docked=1 435 | State=0 436 | Left=-1351 437 | Top=-141 438 | Width=2844 439 | Height=6202 440 | MaxLeft=-1 441 | MaxTop=-1 442 | ClientWidth=2844 443 | ClientHeight=6202 444 | TBDockHeight=6202 445 | LRDockWidth=2844 446 | Dockable=1 447 | StayOnTop=0 448 | 449 | [TemplateView] 450 | PercentageSizes=1 451 | Create=1 452 | Visible=0 453 | Docked=1 454 | State=0 455 | Left=0 456 | Top=0 457 | Width=276 458 | Height=359 459 | MaxLeft=-1 460 | MaxTop=-1 461 | ClientWidth=276 462 | ClientHeight=359 463 | TBDockHeight=359 464 | LRDockWidth=276 465 | Dockable=1 466 | StayOnTop=0 467 | Name=120 468 | Description=334 469 | filter=1 470 | 471 | [DebugLogView] 472 | PercentageSizes=1 473 | Create=1 474 | Visible=1 475 | Docked=1 476 | State=0 477 | Left=0 478 | Top=0 479 | Width=3823 480 | Height=1206 481 | MaxLeft=-1 482 | MaxTop=-1 483 | ClientWidth=3823 484 | ClientHeight=1206 485 | TBDockHeight=411 486 | LRDockWidth=4953 487 | Dockable=1 488 | StayOnTop=0 489 | 490 | [ThreadStatusWindow] 491 | PercentageSizes=1 492 | Create=1 493 | Visible=1 494 | Docked=1 495 | State=0 496 | Left=0 497 | Top=0 498 | Width=3823 499 | Height=1206 500 | MaxLeft=-1 501 | MaxTop=-1 502 | ClientWidth=3823 503 | ClientHeight=1206 504 | TBDockHeight=214 505 | LRDockWidth=7406 506 | Dockable=1 507 | StayOnTop=0 508 | Column0Width=145 509 | Column1Width=100 510 | Column2Width=115 511 | Column3Width=250 512 | 513 | [LocalVarsWindow] 514 | PercentageSizes=1 515 | Create=1 516 | Visible=1 517 | Docked=1 518 | State=0 519 | Left=0 520 | Top=0 521 | Width=3823 522 | Height=1206 523 | MaxLeft=-1 524 | MaxTop=-1 525 | ClientWidth=3823 526 | ClientHeight=1206 527 | TBDockHeight=1540 528 | LRDockWidth=3484 529 | Dockable=1 530 | StayOnTop=0 531 | 532 | [CallStackWindow] 533 | PercentageSizes=1 534 | Create=1 535 | Visible=1 536 | Docked=1 537 | State=0 538 | Left=0 539 | Top=0 540 | Width=3823 541 | Height=1206 542 | MaxLeft=-1 543 | MaxTop=-1 544 | ClientWidth=3823 545 | ClientHeight=1206 546 | TBDockHeight=2062 547 | LRDockWidth=3484 548 | Dockable=1 549 | StayOnTop=0 550 | 551 | [PatchForm] 552 | PercentageSizes=1 553 | Create=1 554 | Visible=1 555 | Docked=1 556 | State=0 557 | Left=0 558 | Top=0 559 | Width=2339 560 | Height=1266 561 | MaxLeft=-1 562 | MaxTop=-1 563 | ClientWidth=2339 564 | ClientHeight=1266 565 | TBDockHeight=2498 566 | LRDockWidth=3401 567 | Dockable=1 568 | StayOnTop=0 569 | 570 | [FindReferencsForm] 571 | PercentageSizes=1 572 | Create=1 573 | Visible=1 574 | Docked=1 575 | State=0 576 | Left=0 577 | Top=0 578 | Width=2339 579 | Height=1266 580 | MaxLeft=-1 581 | MaxTop=-1 582 | ClientWidth=2339 583 | ClientHeight=1266 584 | TBDockHeight=2318 585 | LRDockWidth=2823 586 | Dockable=1 587 | StayOnTop=0 588 | 589 | [RefactoringForm] 590 | PercentageSizes=1 591 | Create=1 592 | Visible=1 593 | Docked=1 594 | State=0 595 | Left=0 596 | Top=0 597 | Width=2339 598 | Height=1266 599 | MaxLeft=-1 600 | MaxTop=-1 601 | ClientWidth=2339 602 | ClientHeight=1266 603 | TBDockHeight=3208 604 | LRDockWidth=2823 605 | Dockable=1 606 | StayOnTop=0 607 | 608 | [ToDo List] 609 | PercentageSizes=1 610 | Create=1 611 | Visible=1 612 | Docked=1 613 | State=0 614 | Left=0 615 | Top=0 616 | Width=2339 617 | Height=1266 618 | MaxLeft=-1 619 | MaxTop=-1 620 | ClientWidth=2339 621 | ClientHeight=1266 622 | TBDockHeight=1155 623 | LRDockWidth=3677 624 | Dockable=1 625 | StayOnTop=0 626 | Column0Width=314 627 | Column1Width=30 628 | Column2Width=150 629 | Column3Width=172 630 | Column4Width=129 631 | SortOrder=4 632 | ShowHints=1 633 | ShowChecked=1 634 | 635 | [DataExplorerContainer] 636 | PercentageSizes=1 637 | Create=1 638 | Visible=1 639 | Docked=1 640 | State=0 641 | Left=0 642 | Top=0 643 | Width=2000 644 | Height=7305 645 | MaxLeft=-1 646 | MaxTop=-1 647 | ClientWidth=2000 648 | ClientHeight=7305 649 | TBDockHeight=4885 650 | LRDockWidth=7151 651 | Dockable=1 652 | StayOnTop=0 653 | 654 | [GraphDrawingModel] 655 | PercentageSizes=1 656 | Create=1 657 | Visible=0 658 | Docked=1 659 | State=0 660 | Left=0 661 | Top=0 662 | Width=2854 663 | Height=3208 664 | MaxLeft=-1 665 | MaxTop=-1 666 | ClientWidth=2854 667 | ClientHeight=3208 668 | TBDockHeight=3208 669 | LRDockWidth=2854 670 | Dockable=1 671 | StayOnTop=0 672 | 673 | [BreakpointWindow] 674 | PercentageSizes=1 675 | Create=1 676 | Visible=1 677 | Docked=1 678 | State=0 679 | Left=0 680 | Top=0 681 | Width=3823 682 | Height=1206 683 | MaxLeft=-1 684 | MaxTop=-1 685 | ClientWidth=3823 686 | ClientHeight=1206 687 | TBDockHeight=1548 688 | LRDockWidth=8740 689 | Dockable=1 690 | StayOnTop=0 691 | Column0Width=200 692 | Column1Width=75 693 | Column2Width=200 694 | Column3Width=200 695 | Column4Width=200 696 | Column5Width=75 697 | Column6Width=75 698 | 699 | [StructureView] 700 | PercentageSizes=1 701 | Create=1 702 | Visible=1 703 | Docked=1 704 | State=0 705 | Left=0 706 | Top=0 707 | Width=1896 708 | Height=3584 709 | MaxLeft=-1 710 | MaxTop=-1 711 | ClientWidth=1896 712 | ClientHeight=3584 713 | TBDockHeight=3678 714 | LRDockWidth=1896 715 | Dockable=1 716 | StayOnTop=0 717 | 718 | [ModelViewTool] 719 | PercentageSizes=1 720 | Create=1 721 | Visible=1 722 | Docked=1 723 | State=0 724 | Left=0 725 | Top=0 726 | Width=2000 727 | Height=7305 728 | MaxLeft=-1 729 | MaxTop=-1 730 | ClientWidth=2000 731 | ClientHeight=7305 732 | TBDockHeight=4885 733 | LRDockWidth=5307 734 | Dockable=1 735 | StayOnTop=0 736 | 737 | [BorlandEditorCodeExplorer@EditWindow0] 738 | PercentageSizes=1 739 | Create=1 740 | Visible=0 741 | Docked=0 742 | State=0 743 | Left=0 744 | Top=0 745 | Width=1823 746 | Height=6176 747 | MaxLeft=-5 748 | MaxTop=-9 749 | ClientWidth=1740 750 | ClientHeight=5843 751 | TBDockHeight=6176 752 | LRDockWidth=1823 753 | Dockable=1 754 | StayOnTop=0 755 | 756 | [DockHosts] 757 | DockHostCount=5 758 | 759 | [DockSite0] 760 | HostDockSite=DockBottomCenterPanel 761 | DockSiteType=1 762 | PercentageSizes=1 763 | Create=1 764 | Visible=0 765 | Docked=1 766 | State=0 767 | Left=8 768 | Top=8 769 | Width=2339 770 | Height=1480 771 | MaxLeft=-1 772 | MaxTop=-1 773 | ClientWidth=2339 774 | ClientHeight=1480 775 | TBDockHeight=1480 776 | LRDockWidth=2339 777 | Dockable=1 778 | StayOnTop=0 779 | TabPosition=1 780 | ActiveTabID=RefactoringForm 781 | TabDockClients=RefactoringForm,PatchForm,FindReferencsForm,ToDo List,MetricsView,QAView 782 | 783 | [DockSite1] 784 | HostDockSite=DockBottomPanel 785 | DockSiteType=1 786 | PercentageSizes=1 787 | Create=1 788 | Visible=0 789 | Docked=1 790 | State=0 791 | Left=8 792 | Top=8 793 | Width=3823 794 | Height=1420 795 | MaxLeft=-1 796 | MaxTop=-1 797 | ClientWidth=3823 798 | ClientHeight=1420 799 | TBDockHeight=1420 800 | LRDockWidth=3823 801 | Dockable=1 802 | StayOnTop=0 803 | TabPosition=1 804 | ActiveTabID=DebugLogView 805 | TabDockClients=DebugLogView,BreakpointWindow,ThreadStatusWindow,CallStackWindow,WatchWindow,LocalVarsWindow 806 | 807 | [DockSite2] 808 | HostDockSite=DockRightPanel 809 | DockSiteType=1 810 | PercentageSizes=1 811 | Create=1 812 | Visible=1 813 | Docked=1 814 | State=0 815 | Left=0 816 | Top=18 817 | Width=2000 818 | Height=4619 819 | MaxLeft=-1 820 | MaxTop=-1 821 | ClientWidth=2000 822 | ClientHeight=4619 823 | TBDockHeight=9016 824 | LRDockWidth=2000 825 | Dockable=1 826 | StayOnTop=0 827 | TabPosition=1 828 | ActiveTabID=ProjectManager 829 | TabDockClients=ProjectManager,ModelViewTool,DataExplorerContainer,frmDesignPreview,TFileExplorerForm 830 | 831 | [DockSite3] 832 | HostDockSite=DockLeftPanel 833 | DockSiteType=1 834 | PercentageSizes=1 835 | Create=1 836 | Visible=1 837 | Docked=1 838 | State=0 839 | Left=0 840 | Top=18 841 | Width=1896 842 | Height=3584 843 | MaxLeft=-1 844 | MaxTop=-1 845 | ClientWidth=1896 846 | ClientHeight=3584 847 | TBDockHeight=9016 848 | LRDockWidth=1896 849 | Dockable=1 850 | StayOnTop=0 851 | TabPosition=1 852 | ActiveTabID=StructureView 853 | TabDockClients=StructureView,ClassBrowserTool 854 | 855 | [DockSite4] 856 | HostDockSite=DockRightPanel 857 | DockSiteType=1 858 | PercentageSizes=1 859 | Create=1 860 | Visible=1 861 | Docked=1 862 | State=0 863 | Left=0 864 | Top=580 865 | Width=2000 866 | Height=4328 867 | MaxLeft=-1 868 | MaxTop=-1 869 | ClientWidth=2000 870 | ClientHeight=4328 871 | TBDockHeight=9016 872 | LRDockWidth=2000 873 | Dockable=1 874 | StayOnTop=0 875 | TabPosition=1 876 | ActiveTabID=ToolForm 877 | TabDockClients=ToolForm,TemplateView 878 | 879 | [ActiveProject] 880 | ActiveProject=1 881 | 882 | -------------------------------------------------------------------------------- /UsesGraphFamily_prjgroup.tvsconfig: -------------------------------------------------------------------------------- 1 | 2 | --------------------------------------------------------------------------------