Skip to content

SmartPsiElementPointer restoration fails for injected elements in ~S heredocs on IntelliJ 2025.1+ #3705

@joshuataylor

Description

@joshuataylor

I THINK this occurs when:

  1. A heredoc is a non-interpolating sigil (~S""").
  2. Language injection occurs inside it (??).
  3. A SmartPsiElementPointer is created for an element in the injected PSI.

Confused yet?

It seems:

  • On pointer restoration, IntelliJ 2025.1+ now throws an error if the pointer can’t be mapped back to the host via the LiteralTextEscaper.
  • Investigation with a custom fixture test shows that our LiteralTextEscaper mapping for ElixirLiteralSigilHeredocImpl fails — likely due to trimming indentation and/or removing the terminator in decode, which shifts offsets.
  • This bug did not cause test failures in earlier platform versions because the platform previously logged the error as a warning (yay).

Impact

  • All usages/search features relying on SmartPsiElementPointers for injected elements in ~S heredocs will break in 2025.1+.
  • Affects at least FindUsagesTest.testFunctionRecursiveUsage and other tests scanning kernel.ex.

Possible fixes

  1. Identity escaper for ~S heredocs

For non-interpolating heredocs, map decoded text 1:1 with the host range — no trimming or unescaping — so getOffsetInHost is a direct addition.

  1. Skip injection in ~S heredocs entirely (as a temporary workaround).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions