FIR IDE: introduce scopes for HL API

This commit is contained in:
Ilya Kirillov
2020-06-29 23:59:07 +03:00
parent 6596dc359b
commit f709e6acf3
12 changed files with 290 additions and 15 deletions
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.frontend.api
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.frontend.api.scopes.KtScopeProvider
import org.jetbrains.kotlin.idea.frontend.api.symbols.*
import org.jetbrains.kotlin.idea.frontend.api.types.KtType
import org.jetbrains.kotlin.name.ClassId
@@ -18,6 +19,7 @@ abstract class KtAnalysisSession(project: Project) : ValidityOwner {
override fun invalidationReason(): String = validityToken.invalidationReason()
abstract val symbolProvider: KtSymbolProvider
abstract val scopeProvider: KtScopeProvider
abstract fun getSmartCastedToTypes(expression: KtExpression): Collection<KtType>?
@@ -0,0 +1,41 @@
/*
* Copyright 2010-2020 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.idea.frontend.api.scopes
import org.jetbrains.kotlin.idea.frontend.api.ValidityOwner
import org.jetbrains.kotlin.idea.frontend.api.symbols.*
import org.jetbrains.kotlin.name.Name
interface KtScope : ValidityOwner {
fun getAllNames(): Set<Name>
fun getCallableNames(): Set<Name>
fun getClassLikeSymbolNames(): Set<Name>
fun getAllSymbols(): Sequence<KtSymbol>
fun getCallableSymbols(): Sequence<KtSymbol>
fun getClassClassLikeSymbols(): Sequence<KtClassLikeSymbol>
fun containsName(name: Name): Boolean
}
interface KtMemberScope : KtScope {
val owner: KtClassOrObjectSymbol
}
interface KtDeclaredMemberScope : KtScope {
val owner: KtClassOrObjectSymbol
}
interface KtPackageScope : KtScope, KtSubstitutedScope<KtPackageScope> {
val owner: KtPackageSymbol
}
interface KtUnsubstitutedScope<S : KtScope> : KtScope {
fun substitute(/*substitution*/): KtSubstitutedScope<S> = TODO()
}
interface KtSubstitutedScope<S> : KtScope
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2020 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.idea.frontend.api.scopes
import org.jetbrains.kotlin.idea.frontend.api.ValidityOwner
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassOrObjectSymbol
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtPackageSymbol
abstract class KtScopeProvider : ValidityOwner {
abstract fun getMemberScope(classSymbol: KtClassOrObjectSymbol): KtMemberScope
abstract fun getDeclaredMemberScope(classSymbol: KtClassOrObjectSymbol): KtDeclaredMemberScope
abstract fun getPackageScope(packageSymbol: KtPackageSymbol): KtPackageScope
}