DavidFeldhoff / al-codeactions

MIT License
17 stars 8 forks source link

Extract to Procedure in combination with explicit with #96

Closed DavidFeldhoff closed 3 years ago

DavidFeldhoff commented 3 years ago

If code is extracted which is inside an explicit with code, then the extraction can lead to errors.

with Customer do begin
  Insert(); //extract this single line
end;

leads to

with Customer do begin
  newProcedure();
end;

local procedure newProcedure()
begin
  Insert(); //the reference to the customer is lost.
end;

should be:

with Customer do begin
  newProcedure(Customer);
end;

local procedure newProcedure(var Customer: Record Customer)
begin
  Customer.Insert();
end;
DavidFeldhoff commented 3 years ago

I won't invest some work in the "explicit with" feature anymore if it's not requested at all, so I'll close this issue for now without any action