ShredImpl(@Nonnull SmartPsiFileRange relevantRangeInHost, @Nonnull SmartPsiElementPointer<PsiLanguageInjectionHost> hostElementPointer, @Nonnull String prefix, @Nonnull String suffix, @Nonnull TextRange rangeInDecodedPSI, boolean usePsiRange, boolean isOneLine) { this.hostElementPointer = hostElementPointer; this.relevantRangeInHost = relevantRangeInHost; this.prefix = prefix; this.suffix = suffix; this.rangeInDecodedPSI = rangeInDecodedPSI; this.usePsiRange = usePsiRange; this.isOneLine = isOneLine; assertValid(); }
@Nonnull ShredImpl withRange(@Nonnull TextRange rangeInDecodedPSI, @Nonnull TextRange rangeInHostElementPSI, @Nonnull PsiLanguageInjectionHost newHost) { SmartPsiFileRange rangeMarker = relevantRangeInHost; Segment oldRangeInHostElementPSI = calcRangeInsideHostElement(false); SmartPointerManager pointerManager = SmartPointerManager.getInstance(rangeMarker.getProject()); SmartPsiElementPointer<PsiLanguageInjectionHost> newHostPointer = pointerManager.createSmartPsiElementPointer(newHost); if (!rangeInHostElementPSI.equals(TextRange.create(oldRangeInHostElementPSI))) { Segment hostElementRange = newHostPointer.getRange(); rangeMarker = ((SmartPointerManagerImpl)pointerManager).createSmartPsiFileRangePointer(rangeMarker.getContainingFile(), rangeInHostElementPSI.shiftRight(hostElementRange.getStartOffset()), true); } return new ShredImpl(rangeMarker, newHostPointer, prefix, suffix, rangeInDecodedPSI, usePsiRange, isOneLine); }