All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.fir.scopes.FirScopeProvider.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
/*
 * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
 */

package org.jetbrains.kotlin.fir.scopes

import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.FirClass
import org.jetbrains.kotlin.fir.resolve.ScopeSession

abstract class FirScopeProvider {
    abstract fun getUseSiteMemberScope(
        klass: FirClass,
        useSiteSession: FirSession,
        scopeSession: ScopeSession
    ): FirTypeScope

    abstract fun getStaticMemberScopeForCallables(
        klass: FirClass,
        useSiteSession: FirSession,
        scopeSession: ScopeSession
    ): FirContainingNamesAwareScope?

    abstract fun getNestedClassifierScope(
        klass: FirClass,
        useSiteSession: FirSession,
        scopeSession: ScopeSession
    ): FirContainingNamesAwareScope?

    fun getStaticScope(
        klass: FirClass,
        useSiteSession: FirSession,
        scopeSession: ScopeSession
    ): FirContainingNamesAwareScope? {
        val nestedClassifierScope = getNestedClassifierScope(klass, useSiteSession, scopeSession)
        val callableScope = getStaticMemberScopeForCallables(klass, useSiteSession, scopeSession)

        return when {
            nestedClassifierScope != null && callableScope != null ->
                FirNameAwareCompositeScope(listOf(nestedClassifierScope, callableScope))
            else -> nestedClassifierScope ?: callableScope
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy