Commenting out Apex class method causes IntelliJ to hang

Issue #1124 resolved
Jason Clark created an issue

Just updated this morning to IntelliJ 2018.2.4 and Illuminated Cloud 2.0.3.7. I performed the following steps and got a hang-crash, reproducibly, several times:

  1. Find in Path... (Cmd+Shift+F) to find usages of an SObject Field.
  2. Click a usage to open containing file.
  3. Click in containing method's name and Find Usages (Cmd+Opt+F7) to confirm method isn't used anywhere.
  4. Highlight the entire method (via shift+DnArrow)
  5. Comment out method via Comment with Line Comment (Cmd+/).

The comment line-prefixes ("//") appear, but the code highlighting never changes to comment coloring, and IntelliJ becomes unresponsive. After a minute or two, IntelliJ shows the SBOD, and I have to hard-force-quit.

I have attached a log file. Of note: I found that my Debug Log config still contains some directives from another issue I submitted a while back; I chose to leave these lines in place:

#com.illuminatedcloud.intellij.completion.ApexCompletionContext
#com.illuminatedcloud.intellij.completion.ApexCompletionRule
#com.illuminatedcloud.intellij.completion.ApexVariantsCompletionRule
#com.illuminatedcloud.intellij.completion.ApexSObjectFieldsCompletionRule
#com.illuminatedcloud.intellij.psi.util.SObjectUtil

The end of the log shows a long exception stack trace, right below "2018-09-24 09:46:24,741 [ 111615] ERROR - j.psi.stubs.StubTreeLoaderImpl - Outdated stub in index:...", so after capturing the attached log, I restarted IntelliJ and did a Full Rebuild of the OST. This did NOT resolve the issue; the reproduction steps above still cause a full crash and the same Error & Exception in the log.

The attached idea.log was grabbed right after one of the freezes and before a restart. The zip is from "Compress Logs and Show in Finder" after the full OST rebuild/restart/reproduce error.

Comments (8)

  1. Scott Wells repo owner

    Jason, your log definitely shows stale/corrupted caches/indices which may be a result of a bug in a previous build that should be fixed now. Do you mind rebuilding caches and indices and seeing whether this happens again? I'll keep this issue open for a while in case it does, but that's definitely where I'd recommend starting since it's an obvious issue in the log that should be easy to resolve.

  2. Jason Clark reporter

    Just dropped priority from "Blocker" to "Critical" as I found a work-around.

    I noticed that individually commenting out lines (starting from the method declaration ("public <type> <methodName>") didn't cause I hang. Instead of manually editing all 35 lines, I undid my changes and highlighted the whole method again, then used multi-edit mode (aka Column Selection Mode) to insert the "//" at the start of all the lines. No hang/crash. I then saved the file (this is standard non-DX project) and again no issues. So I am able to continue working on the project.

  3. Jason Clark reporter

    Scott, is "rebuilding caches and indices" different than "Generate Offline Symbol Table"? Because I tried that. If it is different, can you point me to the option?

  4. Jason Clark reporter

    Okay, found "Invalidate caches and Restart" option in the menu before I saw your reply, so I did the full rebuild. First, confirmed that I could undo the commented-out code (from the workaround) and still reproduce the freeze. Invalidated, Restarted, and waited for "Indexing..." to complete. After which I was able to successfully comment out the code via Cmd+/ without a freeze, and then save the code to the server.

    Thanks for your help. TIL regenerating OST != Rebuilding Caches

  5. Scott Wells repo owner

    Ah, good. This okay to resolve for now? Obviously feel free to reopen if you see it recur.

  6. Jason Clark reporter

    Don't know if there's any way for plugin updates to auto-invalidate the IC cache, but if so might be worth it. It's resolved for me, so feel free to close. Thanks for the help!

  7. Log in to comment