Cannot resolve symbol

Issue #2374 resolved
alexdev created an issue

I use WebStorm with the Illuminated Cloud 2 plugin and the WebStorm shows errors for Apex classes like ‘Cannot resolve symbol 'Id'', 'Cannot resolve symbol 'ContactId'', 'Expected type Exception; found AuraHandledException', 'Cannot resolve symbol 'getRecordTypeInfosByName'' in the Problems tab.
I’ve already generated the OST but I still have issues.

Comments (35)

  1. Scott Wells repo owner

    Hi. It sounds like your OST either didn’t generate properly or isn’t set up for the project correctly. Can you please send over the idea*.log* files from Help>Show Log in Explorer/Finder/Files for review? You can either attach them here or email them to support@illuminatedcloud.com.

  2. Scott Wells repo owner

    Thank you. I’m seeing a whole host of issues with the base IDE in those logs that might be contributing to the problems you’re seeing, e.g.:

    2023-06-08 17:55:37,126 [  30028] SEVERE - #c.i.u.j.JBCefApp - no jcef in java.library.path: /Users/alexanderzaplatin/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
    

    and:

    java.lang.NullPointerException
        at com.intellij.openapi.fileEditor.impl.FileEditorProviderManagerImpl.providerSelected(FileEditorProviderManagerImpl.kt:118)
        at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$fireSelectionChanged$task$1.invoke(FileEditorManagerImpl.kt:1617)
        at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$fireSelectionChanged$task$1.invoke(FileEditorManagerImpl.kt:1610)
        at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.fireSelectionChanged(FileEditorManagerImpl.kt:1626)
        at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.access$fireSelectionChanged(FileEditorManagerImpl.kt:119)
        at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$1$1.invokeSuspend(FileEditorManagerImpl.kt:223)
    

    I think it’s best to clear those up before debugging the IC2 issues further just in case they are the root cause. I wouldn’t be surprised if they’re not related, but minimally the issues shown above could be causing a number of other behavioral problems.

    I’d recommend that you uninstall and reinstall WebStorm. You shouldn’t lose any configuration by doing so. Once you’ve done that, please regenerate your OST in IC2 again and see if the original issues are still present. If so, please attach new log files for review.

  3. Scott Wells repo owner

    Okay. In the new log I’m also seeing that the IDE is using the default maximum heap size and is running out of memory indexing:

    2023-06-09 17:49:05,758 [ 498563] SEVERE - #c.i.u.i.d.BrokenIndexingDiagnostics - Failed to build index 'ApexDerivedInvokableDeclarationIndex' for file jar:///Users/alexanderzaplatin/WebstormProjects/na_gold/IlluminatedCloud/dev2/OfflineSymbolTable.zip!/TASKRAY/trIterateTasks.cls (id = 96982) (file type = Apex) [Plugin: com.illuminatedcloud2.intellij]
    com.intellij.diagnostic.PluginException: Failed to build index 'ApexDerivedInvokableDeclarationIndex' for file jar:///Users/alexanderzaplatin/WebstormProjects/na_gold/IlluminatedCloud/dev2/OfflineSymbolTable.zip!/TASKRAY/trIterateTasks.cls (id = 96982) (file type = Apex) [Plugin: com.illuminatedcloud2.intellij]
        at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
        at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:89)
        ... 49 more
    Caused by: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
        at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:205)
        at com.intellij.openapi.progress.util.ProgressIndicatorUtils.awaitWithCheckCanceled(ProgressIndicatorUtils.java:332)
        ... 144 more
    

    Can you please use Help>Change Memory Settings and supply a value of at least 2048, click Save, and then use File>Invalidate Caches to rebuild all indices under the higher memory configuration?

  4. Scott Wells repo owner

    Sorry, I’m not sure I follow. Here is the maximum heap of the running process from the most recent log you provided:

    2023-06-09 17:49:19,898 [     74]   INFO - #c.i.i.AppStarter - JVM options: [...-Xms128m, -Xmx750m, ...]
    

    and in that same log I can see several OutOfMemoryErrors including at least one during indexing.

    You can also see the maximum heap in About WebStorm using Copy and Close which will result in something like the following being copied to your clipboard:

    IntelliJ IDEA 2023.1.2 (Ultimate Edition)
    Build #IU-231.9011.34, built on May 16, 2023
    ...
    Memory: 4096M
    ...
    

    Can you please confirm 100% that you are using a higher maximum heap as that’s not what I’m seeing any of the provided logs.

    Or if you’re saying that you made that change and rebuilt caches but are still seeing the issue, can you please attach a new log from after doing so?

  5. Scott Wells repo owner

    Sorry, but I’m still seeing the same thing in the latest log:

    2023-06-09 18:33:38,191 [     73]   INFO - #c.i.i.AppStarter - JVM options: [..., -Xms128m, -Xmx750m, ...]
    

    Note the default value of 750m in the line above. Can you please show me exactly what you're doing to try to increase the maximum heap of the IDE?

  6. alexdev reporter

    WebStorm 2023.1.2
    Build #WS-231.9011.35, built on May 16, 2023
    Licensed to Alexander Zaplatin
    Subscription is active until July 7, 2023.
    Runtime version: 17.0.7+10-b829.14 aarch64
    VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
    macOS 13.4
    GC: G1 Young Generation, G1 Old Generation
    Memory: 9216M
    Cores: 10
    Metal Rendering is ON
    Non-Bundled Plugins:
    zielu.gittoolbox (500.0.10+213)
    com.illuminatedcloud2.intellij (2.2.7.1)

  7. Scott Wells repo owner

    Got it. Strange that the log isn’t reflecting that, but good to know it’s set high. Sorry for thrashing you on that. Okay, and you rebuilt caches and indices, correct? If that’s the case, please regenerate your OST one more to see if that helps since it’s possible that the an OutOfMemoryError afffected things the last time. Assuming things still don’t work after that, can you please provide the project's .iml file for me to review so I can see whether it’s properly adding the OST as the project SDK?

  8. Scott Wells repo owner

    It will either be in the project root directory or under the .idea directory, typically named <project>.iml.

  9. Scott Wells repo owner

    Thank you. Overall that file looks fine. Can you confirm that these “Cannot resolve symbol” messages are being reported for an Apex class found under the force-app directory and not under some other directory? If it’s under another directory, please right-click on the root-most parent of that file and click Mark directory as > Sources root and let me know if that doesn’t help.

  10. Scott Wells repo owner

    Okay, can you create a separate, standalone project with a token Apex class that reproduces the issue? If so, please either attach or email that standalone project so that I can try to reproduce what you’re seeing locally.

  11. Scott Wells repo owner

    Thanks. I’m not seeing any issues in that project at all, actually. I opened it in WebStorm and then opened each Apex class in turn, and they all show up fine, e.g.:

    I am curious about the difference in project formats, though. This is a metadata format project with a src directory, and the one that we’ve been discussing seemed to be a source format projecty with a force-app directory. Is there a reason for the change? I’m just still wondering if you perhaps have a misconfigured project relative to the underlying structure.

    Also, just to clarify, the test project that you provided evidences the exact same types of issues for you, correct?

  12. alexdev reporter

    I’m sorry for the delay.

    Yes, the Test project shows the same errors. The Test project is a playground and the one that we’ve been discussing is my work project that’s why there is a different project source.

    I’ve noticed that there is no such issue when I open the same project in the IntelliJ IDEA.

  13. Scott Wells repo owner

    Wow, it’s bizarre that there would be any difference between the two IDEs for Apex as IC2 should be identical across supported JetBrains IDEs for everything but JavaScript and CSS. That’s a pretty clear indication to me that it’s something with your WebStorm install. You mentioned that you’ve fully uninstalled and reinstalled WebStorm already, correct?

    I’m wondering now if you have another copy of the OST files in your project. What file is opened if you type Ctrl+B on List or Account? If it’s not the corresponding stub class in IC2’s offline symbol table, that would explain what’s going on. You’d need to remove or exclude those other versions of the system classes. I’ve seen that happen before when folks had been playing with, for example, JetForcer, and its own analog to IC2’s OST was being picked up.

    Let’s see if that helps…

  14. Scott Wells repo owner

    Okay. And what are the paths of those files? Are they definitely the ones from the generated OST?

    and if so, does the List class have a size() method? Does the Account class extend the SObject class, and if so, does the SObject class have an Id field? Those are the ones it’s saying it can’t resolve in your screenshot.

  15. alexdev reporter

    Everything looks good but I cannot jump to the SObject.cls from the Account.cls, is it ok?

  16. Scott Wells repo owner

    No, that is likely a downstream symptom of whatever is causing these issues for you, but it would explain why it’s unable to find Id, and I suspect that the same root cause is behind the overall problem with type resolution.

    Can you please type Ctrl+Shift+N and then SObject.cls to see where all in the project it’s finding a file with that name? Filtering out the partial matches, e.g., SObjectType.cls and such, there should be exactly one, e.g.:

    My guess is that it’s going to find more than one, and that ambiguity is why this is happening. I’m fairly certain it’s something like that; hopefully at this point it’s just a matter of finding whatever is causing this ambiguity and removing/excluding it. My only real reservation is that it wouldn’t explain why things working in IntelliJ IDEA and not WebStorm if they’re both opening the exact same project directory/files.

  17. alexdev reporter

    I noticed another difference. The WebStorm doesn’t show the OST in the IlluminatedCloud folder but the IntelliJ shows

    webstorm:

    IntelliJ:

  18. Scott Wells repo owner

    Yeah, there’s something really weird going on in WebStorm. Let’s just try to reset the project. Close the project in WebStorm (or just close the app) and remove the following from ~/WebstormProjects/test/:

    • .idea
    • *.iml (if it wasn’t under .idea already)
    • IlluminatedCloud (which contains the OST)

    If you’d prefer not the remove them, you can move them aside.

    Then reopen the project and it should show you a notification about needing to configure the project:

    Click Resolve and walk through the resolution including selection of a connection and generation of a brand new OST. Once that completes, is the problem still present?

    It just seems like something’s…wrong?…with this project when opened in WebStorm, so hopefully allowing a full reset of the project will make things right. If not, I’m likely going to recommend that you uninstall WebStorm including settings and caches before reinstalling as the behavior you’re seeing is completely anomalous, and that would seem to indicate that it’s something jammed at the IDE-level instead of the project-level.

  19. alexdev reporter

    Thank you very much for taking the time to help me! I really appreciate you :)

    Have a nice day!

  20. Scott Wells repo owner

    Oh wow! I’m glad you found that as I wouldn’t have thought to look there. How did you find it? And thanks for slogging through all of this patiently. I’m glad it’s resolved for you now.

  21. Log in to comment