Aspects: Get body of IMethodDefinition

Is there a way to get the body of a IMethodDefinition?

I want to surround it wit a try-except. where the original body will function as the body of the Try.

So the method:

method x;
begin
   // do something
end

becomes (will be much complexer in real life)

method x;
begin
    try
        begin
            // do something
        end
    except 
    end;
end;

I think you are looking for PlaceHolderStatement if you use ReplaceMethodBody(newBodyStatement), or
RemObjects.Elements.Cirrus.Aspects.OriginalBody if you use SetBody(Services,method begin …

1 Like

Indeed. You can use replace to replace the full body or surround it. You can’t currently get the body itself because it will have tons of statement types that Cirrus doesn’t support yet.

1 Like