Hi all,
Just a quick question - does anyone know a way to count the lines of user-written code in a schema or schemas?
Cheers in advance,
Avinash.
Code: Select all
constants
Debug = false;
vars
classClass, class: Class;
numberOfClasses, numberOfMethods, linesOfCode: Integer;
meth: Method;
code: String;
classes: ClassColl;
object: Object;
delta: DeltaInfo;
sch: Schema;
schemas: SchemaColl;
prim: Type;
begin
create schemas transient;
rootSchema.allSubschemas(schemas);
foreach sch in schemas do
numberOfMethods := 0;
numberOfClasses := 0;
linesOfCode := 0;
create classes transient;
classes.add(Class);
Class.allSubclasses(classes);
Class.allSubclassesInSubschemas(classes);
foreach classClass in classes do
foreach object in classClass.instances where (object.Class.schema = sch) do
class := object.Class;
if (class.isKindOf(JadeImportedClass)) then
continue;
endif;
foreach meth in class.getGreentreeMethods do
code := meth.getPropertyValue("source").String;
if (code <> "") then
linesOfCode := linesOfCode + code.noOfLines();
endif;
numberOfMethods := numberOfMethods + 1;
if (Debug) then
write "Method " & class.name & " " & meth.name;
endif;
endforeach;
if (class.superschemaType = null) then
numberOfClasses := numberOfClasses + 1;
if (Debug) then
write "Class " & class.name;
endif;
endif;
endforeach;
endforeach;
foreach prim in sch.allPrimitives() do
prim := sch.findName(prim.name);
foreach meth in prim.getPropertyValue("methods").MethodNDict where (meth.schemaType.schema = sch) do
code := meth.getPropertyValue("source").String;
if (code <> "") then
linesOfCode := linesOfCode + code.noOfLines();
endif;
numberOfMethods := numberOfMethods + 1;
if (Debug) then
write "Method " & prim.name & " " & meth.name;
endif;
endforeach;
endforeach;
delete classes;
write sch.name & "," & numberOfClasses.String & "," & numberOfMethods.String & "," & linesOfCode.String;
endforeach;
epilog
delete schemas;
delete classes;
end;
Code: Select all
noOfLines():Integer;
//returns the number of lines in the string
vars
i, count: Integer;
begin
i := 1;
count := 1;
while (i < self.length) do
if (self[i] = Cr) then
count := count + 1;
endif;
i := i + 1;
endwhile;
return count;
end;
Hi all,
Just a quick question - does anyone know a way to count the lines of user-written code in a schema or schemas?
Cheers in advance,
Avinash.
Return to “General Discussion”
Users browsing this forum: No registered users and 24 guests