FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DelphiCodeCoverage/Source/ModuleNameSpaceUnit.pas at master · DelphiCodeCoverage/DelphiCodeCoverage · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DelphiCodeCoverage
/
DelphiCodeCoverage
Public
Notifications
You must be signed in to change notification settings
Fork
39
Star
94
Code
Issues
12
Pull requests
4
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
DelphiCodeCoverage
/
Source
/
ModuleNameSpaceUnit.pas
Copy path
More file actions
More file actions
Latest commit
History
History
History
234 lines (189 loc) · 5.78 KB
Breadcrumbs
DelphiCodeCoverage
/
Source
/
ModuleNameSpaceUnit.pas
Copy path
File metadata and controls
234 lines (189 loc) · 5.78 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
(*
*********************************************************************
*)
(*
Delphi Code Coverage
*)
(*
*)
(*
A quick hack of a Code Coverage Tool for Delphi
*)
(*
by Christer Fahlgren and Nick Ring
*)
(*
*)
(*
This Source Code Form is subject to the terms of the Mozilla Public
*)
(*
License, v. 2.0. If a copy of the MPL was not distributed with this
*)
(*
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)
unit
ModuleNameSpaceUnit;
interface
uses
System.Classes,
System.Generics.Collections;
type
TModuleNameSpace =
class
strict
private
FName: string;
FModules: TStringList;
function
GetCount
: Integer;
public
property
Name
: String read FName;
property
Modules: TStringList read FModules;
property
Count: Integer read GetCount;
constructor
Create(
const
AName: string);
destructor
Destroy; override;
procedure
AddModule
(
const
AModuleName: string);
function
HasModule
(
const
AModuleName: string): Boolean;
end
;
TModuleNameSpaceList =
class
strict
private
FNameSpaceList: TDictionary<string, TModuleNameSpace>;
procedure
ClearNameSpaceList
;
function
GetModuleNameSpaceFromModuleName
(
const
AModuleName: string): TModuleNameSpace;
public
property
Items[
const
AModuleName: string]: TModuleNameSpace read GetModuleNameSpaceFromModuleName; default;
constructor
Create;
destructor
Destroy; override;
procedure
Add
(
const
AModuleNameSpace: TModuleNameSpace);
end
;
TUnitNameSpace =
class
strict
private
FModuleName: string;
FUnits: TStringList;
function
GetCount
: Integer;
public
property
ModuleName: string read FModuleName;
property
Count: Integer read GetCount;
constructor
Create(
const
AModuleName: string);
destructor
Destroy; override;
procedure
AddUnit
(
const
AUnitName: string);
function
HasUnit
(
const
AUnitName: string): Boolean;
end
;
TUnitNameSpaceList =
class
strict
private
FNameSpaceList: TDictionary<string, TUnitNameSpace>;
procedure
ClearNameSpaceList
;
function
GetUnitNameSpace
(
const
AName: string): TUnitNameSpace;
public
property
Items[
const
AName: string]: TUnitNameSpace read GetUnitNameSpace; default;
constructor
Create;
destructor
Destroy; override;
procedure
Add
(
const
AUnitNameSpace: TUnitNameSpace);
end
;
implementation
uses
System.SysUtils;
{
$region 'TModuleNameSpace'
}
constructor
TModuleNameSpace.Create(
const
AName: string);
begin
inherited
Create;
FModules := TStringList.Create;
FName := AName;
end
;
destructor
TModuleNameSpace.Destroy;
begin
FModules.Free;
inherited
Destroy;
end
;
function
TModuleNameSpace.GetCount
: Integer;
begin
Result := Modules.Count;
end
;
procedure
TModuleNameSpace.AddModule
(
const
AModuleName: string);
begin
Modules.Add(AModuleName);
end
;
function
TModuleNameSpace.HasModule
(
const
AModuleName: string): boolean;
begin
Result := Modules.IndexOf(AModuleName) > -
1
;
end
;
{
$endregion 'TModuleNameSpace'
}
{
$region 'TModuleNameSpaceList'
}
constructor
TModuleNameSpaceList.Create;
begin
inherited
Create;
FNameSpaceList := TDictionary<string, TModuleNameSpace>.Create;
end
;
destructor
TModuleNameSpaceList.Destroy;
begin
ClearNameSpaceList;
FNameSpaceList.Destroy;
inherited
Destroy;
end
;
procedure
TModuleNameSpaceList.ClearNameSpaceList
;
var
key: string;
begin
for
key
in
FNameSpaceList.Keys
do
FNameSpaceList[key].Free;
end
;
function
TModuleNameSpaceList.GetModuleNameSpaceFromModuleName
(
const
AModuleName: STring): TModuleNameSpace;
var
CurrentNameSpace: TModuleNameSpace;
begin
Result :=
nil
;
for
CurrentNameSpace
in
FNameSpaceList.Values
do
begin
if
CurrentNameSpace.HasModule(AModuleName)
then
begin
Result := CurrentNameSpace;
break;
end
;
end
;
end
;
procedure
TModuleNameSpaceList.Add
(
const
AModuleNameSpace: TModuleNameSpace);
begin
FNameSpaceList.Add(AModuleNameSpace.
Name
, AModuleNameSpace);
end
;
{
$endregion 'TModuleNameSpaceList'
}
{
$region 'TUnitNameSpace'
}
constructor
TUnitNameSpace.Create(
const
AModuleName: string);
begin
inherited
Create;
FModuleName := AModuleName;
FUnits := TStringList.Create;
end
;
destructor
TUnitNameSpace.Destroy;
begin
FUnits.Free;
inherited
Destroy;
end
;
procedure
TUnitNameSpace.AddUnit
(
const
AUnitName: string);
begin
FUnits.Add(AUnitName);
end
;
function
TUnitNameSpace.GetCount
: Integer;
begin
Result := FUnits.Count;
end
;
function
TUnitNameSpace.HasUnit
(
const
AUnitName: string): Boolean;
begin
Result := FUnits.IndexOf(AUnitName) > -
1
;
end
;
{
$endregion 'TUnitNameSpace'
}
{
$region 'TUnitNameSpaceList'
}
constructor
TUnitNameSpaceList.Create;
begin
inherited
Create;
FNameSpaceList := TDictionary<string, TUnitNameSpace>.Create;
end
;
destructor
TUnitNameSpaceList.Destroy;
begin
ClearNameSpaceList;
FNameSpaceList.Free;
inherited
Destroy;
end
;
procedure
TUnitNameSpaceList.ClearNameSpaceList
;
var
key: string;
begin
for
key
in
FNameSpaceList.Keys
do
FNameSpaceList[key].Free;
end
;
procedure
TUnitNameSpaceList.Add
(
const
AUnitNameSpace: TUnitNameSpace);
begin
FNameSpaceList.Add(AnsiUpperCase(AUnitNameSpace.ModuleName), AUnitNameSpace);
end
;
function
TUnitNameSpaceList.GetUnitNameSpace
(
const
AName: string): TUnitNameSpace;
var
key: string;
begin
Result :=
nil
;
key := UpperCase(AName);
if
FNameSpaceList.ContainsKey(key)
then
Result := FNameSpaceList.Items[key];
end
;
{
$endregion 'TUnitNameSpaceList'
}
end
.
Back
|
FazBrowse Home
|
New Git URL