"Cannot resolve symbol" for Apex code written in-project. (multiple modules)

Issue #1188 resolved
quietopus created an issue

Overview

New erroneous behavior appeared in a recent update.

In a multi-module project, I cannot find a way to make one module aware of ongoing changes made through the other module. Note below that I am also encountering another seemingly unavoidable quirk, outlined in a separate ticket (Issue #1187).

Context

  • IntelliJ IDEA Version: 2018.3.1 (Ultimate Edition)
  • IntelliJ IDEA Build: UI-183.4588.61
  • Illuminated Cloud Version: 2.0.4.4
  • OS: Windows 10 Pro, Version 1803, Build 17134.407
  • Problem First Noticed: Dec 3, 2018

Setup Preconditions

  • IDEA onfigured to save on CTRL+s.
  • Illuminated Cloud settings:
    • Deploy on Save is true.
    • Prefer Tooling API is true for Apex (and all other categories).
    • Salesforce DX executable is left blank.
  • Illuminated Cloud settings contain a valid connection to a sandbox org
    • Name of connection (and sandbox) is myorg--mysandbox.
    • Uses a System Administrator account.
    • Uses a custom URL.
    • Use parallel processing is false.
  • The org at connection myorg--mysandbox contains two Apex classes:
    • MyGenericUtilityClass: A public Apex class with public methods.
    • MyProjectSpecificClass: A public Apex class with a public method, which instantiates MyGenericUtilityClass and calls at least one of its public methods.

How to reproduce

General Steps

  1. Create a project with:

    • two modules
    • an Apex class in each module
    • the Apex class in one module calling methods on the Apex class in the other module

    (Upon project creation, the cross-module references produce no errors.)

  2. Add a new method to one of the Apex classes.

  3. In the module without the new Apex method, add a call to the newly added method.

    (The new method call generates a Cannot resolve symbol error.)

  4. Generate a new symbol table for the module modified in Step 3.

    (All cross-module references now generate a Cannot resolve symbol error.)

Detailed Steps

  1. Open New Project > Illuminated Cloud

  2. Configure:

    Setting Value
    Connection myorg--mysandbox
    Subscription Selected > ApexClass > MyProjectSpecificClass (all other Metadata elements deselected)
  3. Click Next.

  4. Configure:

    Setting Value
    Project Name myproject
    Project location A path ending in myproject/workspace
    Retrieve metadata from Salesforce true
    Merge retrieved metadata false
    Deploy metadata to Salesforce disabled (false)
    Generate offline symbol table true
    Module name myorg--mysandbox__project
    Content root Path ending in myproject/workspace/myorg--mysandbox__project
    Module file location Path ending in myproject/workspace/myorg--mysandbox__project
    Project format .idea (directory based)
  5. Click Finish. (Click OK if prompted to create directory. Click This Window, or New Window according to preference.)

    (A dialog displays Generating offline symbol table for myorg--mysandbox)

  6. Wait for symbol table generation to finish.

    (Event log notifies about symbol table completion. Event log notifies about missing SDK in new module. The Rebuild Caches and Indices dialog displays three buttons.)

  7. Click Restart IDEA button.

  8. Wait for IDEA to restart.

    (If Tip of the Day displays, click Close.)

  9. Open File > Project Structure.

  10. Click Project.

  11. Under Project SDK, select IlluminatedCloud (myproject/myorg--mysandbox).

  12. Click Apply.

  13. Click Modules.

  14. At the top of the middle panel, click + > New Module > Illuminated Cloud.

  15. Configure:

    Setting Value
    Connection Sandbox Org, myorg--mysandbox
    Subscription Selected > ApexClass > MyGenericUtilityClass (all other Metadata elements deselected)
  16. Click Next

  17. Configure:

    Setting Value
    Module name myorg--mysandbox__generic
    Content root Path ending in myproject/workspace/myorg--mysandbox__generic
    Module file location Path ending in myproject/workspace/myorg--mysandbox__generic
    Project format .idea (directory based)
  18. Click Finish.

    (Project structure dialog consistent with new module but shows erroneous output unrelated to this bug report. See Issue #1187.)

  19. Click the X to close Project Structure dialog.

  20. Go to File > Invalidate Caches / Restart... > Invalidate and Restart.

  21. Wait for IDEA to restart.

    (If Tip of the Day displays, click Close.)

    (Status bar says Indexing... then Scanning files to Index....)

  22. Wait for all indexing to complete.

    (Event log notifies about missing SDK on myorg--mysandbox__generic project.)

  23. Open File > Project Structure... > Modules > myorg--mysandbox__generic.

    (In the right panel, under Project SDK, IlluminatedCloud (myproject/myorg--mysandbox) is already selected, but the table below it still indicates No SDK selected, in red.)

  24. Re-select IlluminatedCloud (myproject/myorg--mysandbox) to make the No SDK error go away.

  25. Click Apply and then click OK.

    (Status area at bottom of screen indicates the offline symbol table is out-of-date for myorg--mysandbox__generic.)

  26. In the Project panel, right-click myorg--mysandbox__generic and then select Illuminated Cloud > Generate Offline Symbol Table... > Full.

  27. Wait for all symbol table generation to complete.

    (The Rebuild Caches and Indices dialog displays.)

  28. Click Restart IDEA.

  29. Wait for IDEA to restart.

    (If Tip of the Day displays, click Close.)

  30. In the Project panel on the left, right-click myorg--mysandbox__generic and select Illuminated Cloud > Retrieve Metadata....

  31. Configure:

    Setting Value
    Connection myorg--mysandbox
    Contents Module myorg--mysandbox__generic
    ... the retrieved package.xml ... Merge
    Local Only false
    Local + Server false
    Server Only true
    Subscribed Only true
    Tree View: myorg--mysandbox__generic / classes / MyGenericUtilityClass true (No other selections in tree view)
  32. Click Retrieve.

    (After a moment, retrieval completes successfully.)

  33. Open MyGenericUtilityClass (under module myorg--mysandbox__generic) in the editor.

  34. Add a new method MyGenericUtilityClass.myNewMethod() to the MyGenericUtilityClass class and press CTRL+s to save.

    (Status bar indicates Deploying MyGenericUtilityClass to myorg--mysandbox. and then Deployment Complete: Deployed 1/1 ....)

  35. Open MyProjectSpecificClass in the editor.

  36. Add a call to MyGenericUtilityClass.myNewMethod()

Results

Expected

All references from MyProjectSpecificClass to MyGenericUtilityClass are treated as recognized. That is, they are not highlighted in red and do not generate a message saying Cannot resolve symbol....

Actual

The reference to MyGenericUtilityClass.myNewMethod() is highlighted in red. Hovering over it triggers the tooltip Cannot resolve symbol 'myNewMethod' ...

Prior references from MyProjectSpecificClass to MyGenericUtilityClass (those present upon project creation) are recognized, as expected.

Failed Remedies

All of the measures below failed to fix the problem. One of them (see below) made the problem worse.

(Where possible, MyProjectSpecificClass was closed and re-opened after each of these.)

  1. Press CTRL+s to save/deploy MyProjectSpecificClass.
  2. After saving/deploying changes to MyProjectSpecificClass, retrieve subscribed metadata for module myorg--mysandbox__project.
  3. Retrieve subscribed metadata for module myorg--mysandbox__generic.
  4. Run File > Invalidate Caches / Restart... > Invalidate and Restart. Wait for IDEA to restart, and wait for all indexing to complete. (MyGenericUtilityClass.myNewMethod() appears resolved until the indexing finishes. Then, it is highlighted in red again.)
  5. Right-click module myorg--mysandbox__project and run Illuminated Cloud > Generate Offline Symbol Table ... > Full. Wait for generation to complete and click Restart IDEA. This made the problem worse. Once complete, all references from MyProjectSpecificClass to MyGenericUtilityClass were marked as unresolved, even the ones which existed upon project creation.
  6. Right-click module myorg--mysandbox__generic and run Illuminated Cloud > Generate Offline Symbol Table ... > Full. Wait for generation to complete and click Restart IDEA. Wait for restart. Nothing changed.
  7. Repeat Steps 4 and 5, above. Nothing changed.

Comments (10)

  1. quietopus reporter

    @RoseSilverSoftware noted what appears to be a solution to this while investigating Issue 1266.

    Per the examples in this Issue, one can fix the unresolved references by noting the dependencies between modules, as follows:

    Click the following:

    1. File > Project Structure > Modules
    2. myorg--mysandbox__project > Dependencies > + > Module Dependency
    3. myorg--mysandbox__generic > OK
    4. Apply > OK

    This tells IntelliJ that the myorg--mysandbox__project module depends on the myorg--mysandbox__generic module and will cause any unresolved references from myorg--mysandbox__project to myorg--mysandbox__generic to be marked as resolved (assuming they are, in fact, valid).

  2. Scott Wells repo owner

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

  3. Log in to comment