Attempting to obtain method references using the REST version of the Tooling API.



public with sharing class MyApexClass {

public void testA(){}

public void testB(){

public with sharing class MyApexClassTwo {

public void testC(){
    MyApexClass mac = new MyApexClass();

Why all references = null, if I call testA() in testB() in class ‘MyApexClass’ and then tesB() in testC() in external class ‘MyApexClassTwo’?


As you have found, you need to use an ApexClassMember to access the full SymbolTable.

The ApexClassMember’s often don’t exist for the class of interest, so you must create them. The same with ApexTriggerMember records.

General steps to get the SymbolTable:

  1. Create a MetadataContainer record with a unique name. Record the MetadataContainerId
  2. Create a collection of ApexClassMember records referencing the MetadataContainerId. Populate the Body for each ApexClassMember with the corresponding ApexClass body. Populate the ContentEntityId with the Apex Class ID.
  3. Create a ContainterAsyncRequest for the MetadataContainerId. Use the IsCheckOnly option to avoid making changes.
  4. Keep retrieving the State until it is no longer Queued.
  5. Retrieve the ApexClassMember with the SymbolTable.