Suppress deprecation warnings related to scripting

This commit is contained in:
Alexander Udalov
2020-08-14 12:21:04 +02:00
parent 549ee84687
commit 1d15a5547d
14 changed files with 26 additions and 7 deletions
@@ -3,12 +3,13 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("DEPRECATION")
package kotlin.script.experimental.jvm.compat
import kotlin.script.experimental.api.ScriptAcceptedLocation
import kotlin.script.experimental.location.ScriptExpectedLocation
@Suppress("DEPRECATION")
fun List<ScriptAcceptedLocation>.mapToLegacyExpectedLocations(): List<ScriptExpectedLocation> = map {
when (it) {
ScriptAcceptedLocation.Sources -> ScriptExpectedLocation.SourcesOnly
@@ -19,7 +20,6 @@ fun List<ScriptAcceptedLocation>.mapToLegacyExpectedLocations(): List<ScriptExpe
}
}
@Suppress("DEPRECATION")
fun List<ScriptExpectedLocation>.mapLegacyExpectedLocations(): List<ScriptAcceptedLocation> = map {
when (it) {
ScriptExpectedLocation.SourcesOnly -> ScriptAcceptedLocation.Sources
@@ -14,6 +14,8 @@
* limitations under the License.
*/
@file:Suppress("DEPRECATION")
package org.jetbrains.kotlin.script.util
import org.jetbrains.kotlin.script.util.resolvers.DirectResolver
@@ -14,6 +14,8 @@
* limitations under the License.
*/
@file:Suppress("DEPRECATION")
package org.jetbrains.kotlin.script.util.resolvers
import org.jetbrains.kotlin.script.util.Repository
@@ -3,6 +3,8 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("DEPRECATION")
package org.jetbrains.kotlin.script.util.resolvers.experimental
import org.jetbrains.kotlin.script.util.DependsOn
@@ -15,6 +15,7 @@
*/
@file:DependsOn("org.funktionale:funktionale:0.9.6")
@file:Suppress("DEPRECATION")
package org.jetbrains.kotlin.script.util.resolvers
@@ -3,6 +3,8 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("DEPRECATION")
package org.jetbrains.kotlin.script.util.resolvers
import org.jetbrains.kotlin.script.util.DependsOn
@@ -14,7 +14,7 @@
* limitations under the License.
*/
@file:Suppress("unused") // an API
@file:Suppress("unused", "DEPRECATION")
package org.jetbrains.kotlin.script.util.templates
@@ -19,7 +19,6 @@ import kotlin.script.experimental.host.ScriptingHostConfiguration
import kotlin.script.experimental.host.getScriptingClass
import kotlin.script.experimental.jvm.compat.mapToLegacyExpectedLocations
import kotlin.script.experimental.jvm.impl.BridgeDependenciesResolver
import kotlin.script.experimental.location.ScriptExpectedLocation
import kotlin.script.experimental.util.getOrError
// temporary trick with passing Any as a template and overwriting it below, TODO: fix after introducing new script definitions hierarchy
@@ -82,9 +81,12 @@ abstract class KotlinScriptDefinitionAdapterFromNewAPIBase : KotlinScriptDefinit
.orEmpty()
@Suppress("DEPRECATION")
override val scriptExpectedLocations: List<ScriptExpectedLocation>
override val scriptExpectedLocations: List<kotlin.script.experimental.location.ScriptExpectedLocation>
get() = scriptCompilationConfiguration[ScriptCompilationConfiguration.ide.acceptedLocations]?.mapToLegacyExpectedLocations()
?: listOf(ScriptExpectedLocation.SourcesOnly, ScriptExpectedLocation.TestsOnly)
?: listOf(
kotlin.script.experimental.location.ScriptExpectedLocation.SourcesOnly,
kotlin.script.experimental.location.ScriptExpectedLocation.TestsOnly
)
private val scriptingClassGetter by lazy(LazyThreadSafetyMode.PUBLICATION) {
hostConfiguration[ScriptingHostConfiguration.getScriptingClass]
@@ -55,6 +55,7 @@ abstract class LazyScriptDefinitionProvider : ScriptDefinitionProvider {
cachedDefinitions.firstOrNull { it.isScript(script) }
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun findScriptDefinition(fileName: String): KotlinScriptDefinition? =
if (nonScriptId(fileName)) null
else lock.read {
@@ -67,6 +68,7 @@ abstract class LazyScriptDefinitionProvider : ScriptDefinitionProvider {
cachedDefinitions.map { it.fileExtension }
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
override fun getDefaultScriptDefinition(): KotlinScriptDefinition = getDefaultDefinition().legacyDefinition
companion object {
@@ -34,6 +34,7 @@ class ScriptCompilationConfigurationFromDefinition(
providedProperties.putIfAny(scriptDefinition.providedProperties.map { it.first to KotlinType(it.second) })
annotationsForSamWithReceivers.put(scriptDefinition.annotationsForSamWithReceivers.map(::KotlinType))
platform(scriptDefinition.platform)
@Suppress("DEPRECATION")
compilerOptions.putIfAny(scriptDefinition.additionalCompilerArguments)
ide {
acceptedLocations.put(scriptDefinition.scriptExpectedLocations.mapLegacyExpectedLocations())
@@ -19,13 +19,14 @@ import kotlin.script.experimental.dependencies.ScriptDependencies
open class ScriptDependenciesProvider constructor(
protected val project: Project
) {
@Suppress("DEPRECATION")
@Deprecated("Migrating to configuration refinement", level = DeprecationLevel.ERROR)
fun getScriptDependencies(file: VirtualFile): ScriptDependencies? {
val ktFile = PsiManager.getInstance(project).findFile(file) as? KtFile ?: return null
return getScriptConfiguration(ktFile)?.legacyDependencies
}
@Suppress("DEPRECATION")
@Deprecated("Migrating to configuration refinement", level = DeprecationLevel.ERROR)
fun getScriptDependencies(file: PsiFile): ScriptDependencies? {
if (file !is KtFile) return null
@@ -15,6 +15,7 @@ dependencies {
compileOnly(project(":compiler:backend.js"))
compileOnly(project(":core:descriptors.runtime"))
compileOnly(project(":compiler:ir.tree.impl"))
compileOnly(project(":kotlin-reflect-api"))
compile(project(":kotlin-scripting-common"))
compile(project(":kotlin-scripting-js"))
compile(project(":kotlin-util-klib"))
@@ -203,7 +203,9 @@ open class ReplCodeAnalyzerBase(
// TODO: merge with org.jetbrains.kotlin.resolve.repl.ReplState when switching to new REPL infrastructure everywhere
// TODO: review its place in the extracted state infrastructure (now the analyzer itself is a part of the state)
class ResettableAnalyzerState {
@Suppress("DEPRECATION")
private val successfulLines = ResettableSnippetsHistory<LineInfo.SuccessfulLine>()
private val submittedLines = hashMapOf<KtFile, LineInfo>()
fun resetToLine(lineId: ILineId): List<SourceCodeByReplLine> {
@@ -41,6 +41,7 @@ class KotlinResolutionFacadeForRepl(
@FrontendInternals
override fun <T : Any> getFrontendService(serviceClass: Class<T>): T {
@Suppress("UNCHECKED_CAST")
return provider.resolve(serviceClass)!!.getValue() as T
}