Completion and highlighting issues with Apex Namespaces

Issue #1552 resolved
Jason Clark created an issue

I’ve notice a couple issues in the past few days related to handling of Apex Namespaces (like Schema in Schema.DescribeSObjectResult). One is particular to the Schema namespace; when using completion, the namespace is not included in the result. For example, start typing DescribeSObjectResult:

And press tab. The completion works, but Schema. is omitted.

Perhaps it’s the Schema namespace is implicit in Apex, but all of the SF docs include it, and I prefer to see it in my code. I can add it manually, but the syntax highlighting makes it look like an error.

That red-orange color is only used for parameters in my apex color scheme, although it is also the Unknown Symbol color from the General Color Scheme. By comparison, completion of Database.SaveResult does not omit Database., although the color is the same Unknown Symbol color. I do not see an entry in the Apex Color Scheme page for Apex Namespace.

Finally, completion does not seem to recognize Namespace names as prefixes for Class names; for example if I type Schema.DescribeSO, the completions show me methods of the Schema class, but not classes within the Schema namespace.

This goes for all namespaces; for example, here I wanted to complete Database.SaveResult:

Comments (5)

  1. Scott Wells repo owner

    Regarding the first part with the Schema namespace being omitted, yes, that's intentional. The same thing happens with the System namespace and with the local namespace when working on content for a namespaced package.

    I'm not able to reproduce the other issue with namespaces. Can you please use Illuminated Cloud>Configure Project>Rebuild Caches and Indices and allow the project to close/reopen to see if that resolves it? There's an indexing issue immediately after a full IDE index rebuild that I've reported to JetBrains that can lead to the behavior you're seeing, and that type of explicit rebuild of IC's indices should address it.

  2. Jason Clark reporter

    Confirmed, Rebuild Caches and Indices fixed all of the completion & highlighting issues with namespaces.

    As to Schema being omitted; I guess it makes sense; I just thought System was the only implicit namespace. Now that completion is working, it’s simple enough for me to type Schema. first.

  3. Scott Wells repo owner

    Okay, glad to hear. Yeah, System and Schema are the two implicit system namespaces, and IC goes out of its way to keep them out of its code completions. I'm even planning to add a code inspection/intention that looks for unnecessary/superfluous namespace qualifications and helps you to remove them. Sounds like that's one you'd like disabled...at least for the Schema namespace...but I've heard from many other users that they'd love to remove those en masse.

  4. Log in to comment