Error in SonarLint for IntelliJ 2023-10-13 14:45


  • Java: JetBrains s.r.o.
  • OS: Windows 11 amd64
  • IDE: IntelliJ IDEA 2023.2.3
  • SonarLint:

*** exception class was changed or removed

  Exceptions occurred on invoking the intention 'SonarLint: Inline expression' on a copy of the file.
  java.lang.IndexOutOfBoundsException: Wrong endOffset: 2369; documentLength: 2362
at c.ij.oa.editor.impl.DocumentImpl.assertBounds(
at c.ij.oa.editor.impl.DocumentImpl.replaceString(
at c.ij.oa.editor.impl.DocumentImpl.replaceString(
at c.ij.codeInsight.intention.IntentionAction.generatePreview(
at c.ij.codeInsight.intention.impl.IntentionActionWithTextCaching$MyIntentionAction.generatePreview(
at c.ij.codeInsight.intention.impl.preview.IntentionPreviewComputable.invokePreview$lambda$3$lambda$2$lambda$1(IntentionPreviewComputable.kt:124)
at c.ij.model.SideEffectGuard.computeWithAllowedSideEffects(
at c.ij.model.SideEffectGuard.computeWithoutSideEffects(
at c.ij.codeInsight.intention.impl.preview.IntentionPreviewComputable.invokePreview$lambda$3$lambda$2(IntentionPreviewComputable.kt:123)
at c.ij.psi.impl.source.PostprocessReformattingAspectImpl.lambda$postponeFormattingInside$2(
at c.ij.psi.impl.source.PostprocessReformattingAspectImpl.postponeFormattingInside(

Hi @kalvintamas, thank you for your report.

Are you able to reproduce the error and does it happen for a specific code snippet? Do not hesitate to share if you have more details on what you did when this error happened.

It seems the file was modified when SonarLint tried to show the quick fix preview, it should be a very rare case as SonarLint also checks the file before applying this. I created a bug ticket on our side.