You need to sign in to do that
Don't have an account?

Lines of Code - Lightning Components
Hi All,
I am able to retrieve the lines of code for Classes/Pages and Triggers using the below code. Is there a way to extract lines of code for lighting components ? Any help is appreciated.
Integer classLines = 0;
Integer triggerLines = 0;
Integer pageLines = 0;
for(ApexClass a : [Select Body From ApexClass]){
List<String> lines = a.Body.split('\n');
classLines += lines.size();
}
for(ApexTrigger a : [Select Body From ApexTrigger]){
List<String> lines = a.Body.split('\n');
triggerLines += lines.size();
}
for(ApexPage a : [Select Markup From ApexPage]){
List<String> lines = a.Markup.split('\n');
pageLines += lines.size();
}
system.debug('Apex Class lines: ' + classLines);
system.debug('Apex Trigger lines: ' + triggerLines);
system.debug('VisualForce lines: ' + pageLines);
system.debug('Apex Total lines: ' + (classLines+ triggerLines+pageLines));
Thanks
Natraj
I am able to retrieve the lines of code for Classes/Pages and Triggers using the below code. Is there a way to extract lines of code for lighting components ? Any help is appreciated.
Integer classLines = 0;
Integer triggerLines = 0;
Integer pageLines = 0;
for(ApexClass a : [Select Body From ApexClass]){
List<String> lines = a.Body.split('\n');
classLines += lines.size();
}
for(ApexTrigger a : [Select Body From ApexTrigger]){
List<String> lines = a.Body.split('\n');
triggerLines += lines.size();
}
for(ApexPage a : [Select Markup From ApexPage]){
List<String> lines = a.Markup.split('\n');
pageLines += lines.size();
}
system.debug('Apex Class lines: ' + classLines);
system.debug('Apex Trigger lines: ' + triggerLines);
system.debug('VisualForce lines: ' + pageLines);
system.debug('Apex Total lines: ' + (classLines+ triggerLines+pageLines));
Thanks
Natraj
As per the SOAP APi document AuraDefinitionBundle is not supported number of lines and Markup field s
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_auradefinitionbundle.htm?search_text=Aura
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_auradefinition.htm?search_text=Aura
1) https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_auradefinitionbundle.htm
In AuraDefinitionBundle you can access markup.
Thank you for the response. AuraDefinitionBundle does not have a Markup field.
I tried AuraDefinition Source field and it does return some lines of code. I am still not sure if its looking into the correct one.
Integer componentLines = 0;
for(AuraDefinition a : [Select Source From AuraDefinition]){
List<String> lines = a.Source .split('\n');
componentLines += lines.size();
}
system.debug('Component lines: ' + componentLines);
Thanks
Natraj
The above code worked and its accurate for lighting components. You can create similar ones for Apex Class (Refer Body), ApexTrigger (Refer Body) and ApexPage (Refer Markup) as well.
Thanks
Natraj