Possible Incorrect Handling of extract Variable when in new SObject declaration

Issue #1714 new
Justin Julicher created an issue

When you have something like:

Product2 site = new Product2(Name = 'Test_Name', ProductName=);

You’ve gotten to the end of the string and you now want to extract ‘Test_Name’ as a variable and assign it to ProductName. Now the line itself is now incorrectly formed as the ProductName= isn’t complete.

If you select ‘Test_Name’ and extract what happens is actually this:

 Product2 site = new Product2(Name = String str = 'Test_Ttest';
                'Test_Ttest', ProductCode=);

What I would expect is this:

String str = 'Test_Ttest';
Product2 site = new Product2(Name = str, ProductCode=);

Funny thing is if you do it without the '=' i.e.

Product2 site = new Product2(Name = 'Test_Name', ProductName);

It works.

very much an edge case. Not too bothered but thought I should list it.

Comments (1)

  1. Scott Wells repo owner

    Yeah, if you do it without the = or with a value for the second field, it's all good. It appears that the specific nature of the parse issue when this fails is the reason for the failure. As you mentioned, it's a corner-case, but certainly if it's a simple fix I'll take care of it.

  2. Log in to comment