More Inner class completion/index/parser-recovery issues

Issue #1898 resolved
Xander Victory created an issue

Couldn’t locate an existing issue, apologies if duplicate.

Inner class references show as red after editing class contents above them. (see attachment)

Basic reproduction steps:

  • Add inner class at the bottom
  • Use it above where it’s defined
  • Make edits that leave the code in an invalid state (example below)
  • Finish editing to return to valid & deployable code
  • Red remains

In this case I believe there was a line where edits when as follows

  1. emailMessage.fileAttachments = new List<Messaging.EmailFileAttachment>(); (start)
  2. = new List<Messaging.EmailFileAttachment>(); (removing the variable by backspace or select & typing over, editor complains at this point, autocomplete for the variable side of the assignment is flaky)
  3. List<Messaging.EmailFileAttachment> attachments = new List<Messaging.EmailFileAttachment>(); (code is now valid)

Comments (7)

  1. Scott Wells repo owner

    Xander, I'm not able to reproduce this...or at least not much of it. The one thing I could reproduce successfully is the "autocomplete for the variable side of the assignment is flaky" where code completions aren't offered properly on the left side of the assignment operator until things are made whole again. But I don't see any leftover errors once things are back in a deployable state.

    Here's what I tried:

    Phase 1

    public with sharing class Issue1898
    {
        class Bar
        {
            String baz()
            {
                return null;
            }
        }
    }
    

    Phase 2

    public with sharing class Issue1898
    {
        static void foo()
        {
            System.debug(new Bar().baz());
        }
    
        class Bar
        {
            String baz()
            {
                return null;
            }
        }
    }
    

    Phase 3

    public with sharing class Issue1898
    {
        static void foo()
        {
            System.debug(new Bar().baz());
            List<Messaging.EmailFileAttachment> attachments;
            attachments = new List<Messaging.EmailFileAttachment>();
        }
    
        class Bar
        {
            String baz()
            {
                return null;
            }
        }
    }
    

    Phase 4 (correctly shows an error on the assignment operator)

    public with sharing class Issue1898
    {
        static void foo()
        {
            System.debug(new Bar().baz());
            List<Messaging.EmailFileAttachment> attachments;
            = new List<Messaging.EmailFileAttachment>();
        }
    
        class Bar
        {
            String baz()
            {
                return null;
            }
        }
    }
    

    Phase 5 (no completions on the left side of the assignment operator)

    public with sharing class Issue1898
    {
        static void foo()
        {
            System.debug(new Bar().baz());
            List<Messaging.EmailFileAttachment> attachments;
            att= new List<Messaging.EmailFileAttachment>();
        }
    
        class Bar
        {
            String baz()
            {
                return null;
            }
        }
    }
    

    Phase 6 (all good again)

    public with sharing class Issue1898
    {
        static void foo()
        {
            System.debug(new Bar().baz());
            List<Messaging.EmailFileAttachment> attachments;
            attachments = new List<Messaging.EmailFileAttachment>();
        }
    
        class Bar
        {
            String baz()
            {
                return null;
            }
        }
    }
    

    Perhaps you're doing something other than that?

    Either way I'll look into the lack of completions on the left side of the assignment operator as that should work fine.

  2. Xander Victory reporter

    I haven't had a chance to look through your step-by-step, but perhaps my problems are an issue with a Short Name cache?

    I define my inner classes at the bottom of my files, so often while I'm working in the file above it, the parser ends up invalidating the inner classes (usually blocks coming and going or other parser recovery failures).

    Today after completing the changes (i.e. the file in the screenshot is deployable), I'm left with this.

  3. Scott Wells repo owner

    Thanks for the follow-up. The new screenshot shows that it seems to have resolved to another inner class that shouldn't even have been accessible from that location. Or is bawStaffAllocationTriggerHandler the outer class shown in that screenshot? Once I know the answer to that question I'll spend some time trying to reproduce this again using the new information.

  4. Xander Victory reporter

    Apologies, yes bawStaffAllocationTriggerHandler is the outer class.

    There does appear to be a Reports.NotificationAction class which I was not previously aware of, not sure if that’s what it was resolving to (would need to re-trigger the issue to confirm)

  5. Scott Wells repo owner

    Gotcha. That should help. It'll be a week or so before I get a chance to return to this I'm about to take my family on a little getaway before school starts back up. I'll ping you here once I've had a chance to dive back in, though.

  6. Scott Wells repo owner

    Issue tracker grooming. If this is still an issue, please feel free to reopen, ideally with a concrete reproduction scenario.

  7. Log in to comment