Is there any Apex exchange tool or utility which can give me the following details in an Apex class.

  1. Number of methods defined
  2. Number of SOQL's used

and the respective character count for each of those.


Cannot tell about SOQL and the character count, but you can use the Tooling API to fetch data from ApexClass. There you get the SymbolTable object that contains list of all the methods used. Refer Tooling API documentation

Another method is as @Enry suggested, by querying the ApexClass object and writing a parser of your own.


I m not aware of packages to do that.

Some input to start from scratch: You can query "Apex Class" object. http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_apexclass.htm

Query the body and then parse it as a string. For example you can count the number of "from" to know how many queries there are.

  • I don't know whether this is the case in here or not. But if there's a variable named fromAddress or fromLocation or from* the count will fail. – Saket Joshi Jan 15 '15 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.