mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
[http-client] IJPL-179625 Using full computed url for HttpClient request generation
If there is no full url information, we will use resolved version GitOrigin-RevId: c20a364561f5ecbb56d8e519558fbd9205d94edc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5621f8be9e
commit
fb807be02b
@@ -19,9 +19,8 @@ import org.jetbrains.uast.expressions.UInjectionHost
|
||||
fun urlInlayHintProvider(injector: UrlPathReferenceInjector<UExpression>): UastSemProvider<UrlPathInlayHintsProviderSemElement> {
|
||||
return uastSemElementProvider(listOf(UInjectionHost::class.java, UReferenceExpression::class.java)) { uExpression, _ ->
|
||||
val context = forbidExpensiveUrlContext {
|
||||
val rootContext = injector.defaultRootContextProvider(uExpression)
|
||||
if (!injector.ignoreSubPathContext) rootContext.subContext(injector.toUrlPath(uExpression))
|
||||
else rootContext
|
||||
injector.defaultRootContextProvider(uExpression)
|
||||
.subContext(injector.toUrlPath(uExpression))
|
||||
}
|
||||
|
||||
object : UrlPathInlayHintsProviderSemElement {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.util.PartiallyKnownString
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.util.lazyPub
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
class UrlPathContext private constructor(
|
||||
private val immediate: LazyChain.Immediate<UrlPathContextData>,
|
||||
@@ -25,7 +26,8 @@ class UrlPathContext private constructor(
|
||||
val authorities: Set<String>,
|
||||
val methods: Set<String>,
|
||||
val contentTypes: Set<String>,
|
||||
val isDeclaration: Boolean
|
||||
val isDeclaration: Boolean,
|
||||
val fullUrlComputation: (() -> UrlPathContext?)? = null
|
||||
) {
|
||||
init {
|
||||
if (ApplicationManager.getApplication().run { isUnitTestMode || isInternal }) {
|
||||
@@ -45,6 +47,9 @@ class UrlPathContext private constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString(): String =
|
||||
"Info(schemes=$schemes, authorities=$authorities, methods=$methods, contentTypes=$contentTypes, isDeclaration=$isDeclaration)"
|
||||
}
|
||||
|
||||
private data class UrlPathContextData(
|
||||
@@ -75,6 +80,19 @@ class UrlPathContext private constructor(
|
||||
trans.invoke(it.context).genuineChain.value
|
||||
})
|
||||
|
||||
/**
|
||||
* Provides full url information for generation from [UrlPathContext]
|
||||
*
|
||||
* This method is a workaround for HttpClient.
|
||||
* Right now, we can't provide full url information from a resolved version of [UrlPathContext]
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
@ApiStatus.Experimental
|
||||
fun computeFullUrlInfo(): UrlPathContext {
|
||||
logger<UrlPathContext>().assertTrue(canBuildUrlContext.get(), "expensive transformations shouldn't be called there")
|
||||
return info.fullUrlComputation?.invoke() ?: this
|
||||
}
|
||||
|
||||
private fun update(transformation: UrlPathContextData.() -> UrlPathContextData): UrlPathContext {
|
||||
return UrlPathContext(this.immediate.chain(transformation), this.delayed?.chain(transformation))
|
||||
}
|
||||
@@ -151,6 +169,9 @@ class UrlPathContext private constructor(
|
||||
UrlPathContextData(info, this.parent?.paths ?: listOf(UrlPath.EMPTY), this.parent?.parent)
|
||||
}
|
||||
|
||||
fun withFullUrlComputation(fullUrlComputation: () -> UrlPathContext?): UrlPathContext =
|
||||
update { UrlPathContextData(info.copy(fullUrlComputation = fullUrlComputation), paths, parent) }
|
||||
|
||||
fun isEmpty(): Boolean = immediate.value.isEmpty()
|
||||
|
||||
val selfPaths: List<UrlPath> get() = immediate.value.paths
|
||||
|
||||
Reference in New Issue
Block a user