How to Access Source Code?

What i Need it to Access the Source Code, But only the ‚Blocks‘ from specific classes/methods, for a Tool i‘m trying to write.

I already looked at how autosuggestion gets it‘s information and came to eclipses Block or more specifically ASTNode. I Even found a Field within it, that targets Comments (or at least it‘s called like that), which is also needed for what i want to do.

The Problem is that i don‘t know if there is a simpler way… because this seems to be a lot of work only deciphering what anything there does… so my Question is :

Is there a relatively simple way to get sourcecode from a method/class by its text only?

So that it can be used as code, and not by manually looking at github or so… just like autosuggestion gives you all methods from a class, just by the name and the previous „word“‘s class?

An example of what i mean Would be similar to this :

PVector a;

void setup() {
  a.a // and then it returns all methods and fields for a PVector in autosuggestion. 

What i Would Need Would be all the fields and methods as source Code and preferibly ordered.

Now, i can simply add all the methods Source Codes together that result there, that is not the Problem. The Problem is, that i don‘t know how to get the actual code Block… autosuggestion only returns method/field names, But not the relative code Block… and a Look at where this Block should be only left me with despair :sweat_smile:
So, any help is very much appreciated :blush:

You could look into using reflection to retried the functions and variables of a particular class.