[icp-http-client] mapHostRangesToPathFirTree fix for Kotlin's interpolated strings

GitOrigin-RevId: ed1fc0fd52b60ee1a35ffdeeb846737fe14359bd
This commit is contained in:
Nicolay Mitropolsky
2019-09-09 12:15:12 +00:00
committed by intellij-monorepo-bot
parent 9f37bf12e6
commit abafb3b6dc
@@ -115,6 +115,17 @@ sealed class StringEntry {
class Known(val value: String, override val uExpression: UExpression, override val range: TextRange) : StringEntry()
class Unknown(override val uExpression: UExpression, override val range: TextRange) : StringEntry()
val rangeAlignedToHost: TextRange?
get() {
val entry = this
val sourcePsi = entry.uExpression.sourcePsi ?: return null
if (sourcePsi is PsiLanguageInjectionHost) return entry.range
if (sourcePsi.parent is PsiLanguageInjectionHost) { // Kotlin interpolated string, TODO: encapsulate this logic to range retrieval
return entry.range.shiftRight(sourcePsi.startOffsetInParent - ElementManipulators.getValueTextRange(sourcePsi.parent).startOffset)
}
return null
}
}
@ApiStatus.Experimental