[FIR] Mark all session components respectively to they have mutable state or not

Also add documentation for all fir annotations
This commit is contained in:
Dmitriy Novozhilov
2020-09-08 16:34:39 +03:00
parent 8686e3779e
commit 1a84ec9677
34 changed files with 117 additions and 30 deletions
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
import org.jetbrains.kotlin.fir.resolve.ScopeSession
@NoMutableState
abstract class FirEffectiveVisibilityResolver : FirSessionComponent {
abstract fun resolveFor(
declaration: FirMemberDeclaration,
@@ -15,12 +15,6 @@ import org.jetbrains.kotlin.fir.utils.TypeRegistry
import org.jetbrains.kotlin.utils.Jsr305State
import kotlin.reflect.KClass
@RequiresOptIn
annotation class PrivateSessionConstructor
@RequiresOptIn
annotation class SessionConfiguration
interface FirSessionComponent
abstract class FirSession @PrivateSessionConstructor constructor(val sessionProvider: FirSessionProvider?) : ComponentArrayOwner<FirSessionComponent, FirSessionComponent>() {
@@ -1,9 +0,0 @@
/*
* 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.fir
@RequiresOptIn(level = RequiresOptIn.Level.ERROR)
annotation class PrivateForInline
@@ -0,0 +1,44 @@
/*
* 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.fir
/**
* [NoMutableState] annotation means that annotated class has no mutable state
* and it's safe to use it concurrent environment (e.g. as session component)
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class NoMutableState
/**
* [ThreadSafeMutableState] annotation means that annotated class has mutable state
* and it should carefully implement it for concurrent environment if it will be used
* as session component
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class ThreadSafeMutableState
/**
* All [FirSession]s should be created via FirSessionFactories, so constructors of all [FirSession] inheritors
* should be marked with this annotation, to avoid accidental creating session without factory
*/
@RequiresOptIn
annotation class PrivateSessionConstructor
/**
* [SessionConfiguration] is used to avoid accidental registration of session components after
* session was initialized
*/
@RequiresOptIn
annotation class SessionConfiguration
/**
* [PrivateForInline] used for cases when there is a var property with mutable set and corresponding
* inline function which mutates this var
*/
@RequiresOptIn
annotation class PrivateForInline