From 8638c0d42428c409b258d14a00a4b165b9822376 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Thu, 4 Oct 2018 16:33:11 +0300 Subject: [PATCH] stricter assertion: literal escaper must return valid offsets from its.getOffsetInHost() for all offsets which it was able to decode --- .../impl/source/tree/injected/InjectionRegistrarImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionRegistrarImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionRegistrarImpl.java index d4fbd4881ba0..cc26a214cd6d 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionRegistrarImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectionRegistrarImpl.java @@ -187,12 +187,11 @@ class InjectionRegistrarImpl extends MultiHostRegistrarImpl implements MultiHost // if there are invalid chars, adjust the range int charsDecodedSuccessfully = outChars.length() - before; int startOffsetInHost = textEscaper.getOffsetInHost(0, info.registeredRangeInsideHost); - assert startOffsetInHost <= relevantRange.getEndOffset() : textEscaper.getClass() +" .getOffsetInHost(0) = "+startOffsetInHost+" while its relevantRange="+relevantRange; + assert relevantRange.containsOffset(startOffsetInHost) : textEscaper.getClass() +" is inconsistent: its.getOffsetInHost(0) = "+startOffsetInHost+" while its relevantRange="+relevantRange; int endOffsetInHost = textEscaper.getOffsetInHost(charsDecodedSuccessfully, info.registeredRangeInsideHost); - assert endOffsetInHost <= relevantRange.getEndOffset() : textEscaper.getClass() +" .getOffsetInHost(" + charsDecodedSuccessfully + + assert relevantRange.containsOffset(endOffsetInHost) : textEscaper.getClass() +" is inconsistent: its.getOffsetInHost(" + charsDecodedSuccessfully + ") = "+startOffsetInHost+" while its relevantRange="+relevantRange; - ProperTextRange successfulHostRange = new ProperTextRange(Math.max(relevantRange.getStartOffset(), startOffsetInHost), - Math.max(relevantRange.getStartOffset(), endOffsetInHost)); + ProperTextRange successfulHostRange = new ProperTextRange(startOffsetInHost, endOffsetInHost); relevantRange = relevantRange.intersection(successfulHostRange); } }