summaryrefslogtreecommitdiff
path: root/plugins/kotlin/fir-low-level-api-ide-impl/test/org/jetbrains/kotlin/idea/fir/low/level/api/firTestUtils.kt
blob: 7feb38ecf9f344ad398b9641f4e712ede52071b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

package org.jetbrains.kotlin.idea.fir.low.level.api

import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirModuleResolveState
import org.jetbrains.kotlin.analysis.low.level.api.fir.createResolveStateForNoCaching
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSession
import org.jetbrains.kotlin.analysis.project.structure.getKtModule
import org.jetbrains.kotlin.psi.KtElement

internal inline fun <R> resolveWithClearCaches(
    context: KtElement,
    noinline configureSession: LLFirSession.() -> Unit = {},
    action: (LLFirModuleResolveState) -> R,
): R {
    val project = context.project
    val resolveState = createResolveStateForNoCaching(context.getKtModule(project), project, configureSession)
    return action(resolveState)
}