Detect fields accessed on queried SObjects that weren't included in the query and prompt to add them

Issue #695 new
Derek Wiers created an issue

This is a super fancy sounding idea, and seems like a ton of overhead - but: what if, when accessing a field of an SObject that has been queried for the first time, IC/IntelliJ offers to add it to the query that originated the object? Example:

List<Account> accountList = [SELECT Id FROM Account LIMIT 10];
for (Account acc : accountList) {
    acc.Name = 'Acme'; // when I type this, IC/IJ offers to add "Name" to the above query since that is where it originated.
}

Comments (4)

  1. Eric Alexander

    Great idea.

    Even better / more convoluted, add the reference to the dynamic string used to generate the query

    String q = 'SELECT Id FROM Account LIMIT 10';
    Account[] accountList = database.query(q);
    for (Account acc : accountList) {
        acc.Name = 'Acme'; // when I type this, IC/IJ offers to add "Name" to the above query string since that is where it originated.
    }
    

    also in cases like

    string q = 'SELECT Id, CreatedBy ' + 'FROM Account LIMIT 10';

  2. Log in to comment