Drop all usages of Callbacks.ConstantAffectionResolver
This commit fixes deprecation API usage (deprecated in intellij) which is actually
an error (because of -Werror)
KotlinJavaBuilderExtension implements only one method (getConstantSearch) which is
deprecated and the method is actually not called in since 202 IDEA (minimum
supported IDEA right now is 203).
KotlinJavaBuilderExtension originally appeared in 39f7ecc9a3
in order to fix KT-16091. The fact that we ignored the depreaction caused the issue
regression. Luckily, we already fixes the issue again but this API usage is useless so
can be safely droped
This commit is contained in:
-6
@@ -168,12 +168,6 @@ abstract class AbstractIncrementalJpsTest(
|
||||
}
|
||||
}
|
||||
|
||||
// JPS forces rebuild of all files when JVM constant has been changed and Callbacks.ConstantAffectionResolver
|
||||
// is not provided, so ConstantAffectionResolver is mocked with empty implementation
|
||||
// Usages in Kotlin files are expected to be found by KotlinLookupConstantSearch
|
||||
protected open val mockConstantSearch: Callbacks.ConstantAffectionResolver?
|
||||
get() = MockJavaConstantSearch(workDir)
|
||||
|
||||
private fun build(
|
||||
name: String?,
|
||||
scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().allModules()
|
||||
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 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.jps.build
|
||||
|
||||
import com.intellij.util.concurrency.FixedFuture
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks
|
||||
import org.jetbrains.kotlin.incremental.isJavaFile
|
||||
import java.io.File
|
||||
import java.util.concurrent.Future
|
||||
|
||||
/**
|
||||
* Mocks Intellij Java constant search.
|
||||
* When JPS is run from Intellij, it sends find usages request to IDE (it only searches for references inside Java files).
|
||||
*
|
||||
* We rely on heuristics instead of precise usages search.
|
||||
* A Java file is considered affected if:
|
||||
* 1. It contains changed field name as a content substring.
|
||||
* 2. Its simple file name is not equal to a field's owner class simple name (to avoid recompiling field's declaration again)
|
||||
*/
|
||||
class MockJavaConstantSearch(private val workDir: File) :
|
||||
Callbacks.ConstantAffectionResolver {
|
||||
override fun request(
|
||||
ownerClassName: String,
|
||||
fieldName: String,
|
||||
accessFlags: Int,
|
||||
fieldRemoved: Boolean,
|
||||
accessChanged: Boolean
|
||||
): Future<Callbacks.ConstantAffection> {
|
||||
fun File.isAffected(): Boolean {
|
||||
if (!isJavaFile()) return false
|
||||
|
||||
if (nameWithoutExtension == ownerClassName.substringAfterLast(".")) return false
|
||||
|
||||
val code = readText()
|
||||
return code.contains(fieldName)
|
||||
}
|
||||
|
||||
|
||||
val affectedJavaFiles = workDir.walk().filter(File::isAffected).toList()
|
||||
return FixedFuture(
|
||||
Callbacks.ConstantAffection(
|
||||
affectedJavaFiles
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
org.jetbrains.kotlin.jps.build.KotlinJavaBuilderExtension
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2018 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.jps.build
|
||||
|
||||
import org.jetbrains.jps.api.BasicFuture
|
||||
import org.jetbrains.jps.builders.java.JavaBuilderExtension
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks
|
||||
import org.jetbrains.jps.incremental.CompileContext
|
||||
import org.jetbrains.kotlin.incremental.LookupSymbol
|
||||
import java.io.File
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.Future
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class KotlinJavaBuilderExtension : JavaBuilderExtension() {
|
||||
override fun getConstantSearch(context: CompileContext): Callbacks.ConstantAffectionResolver {
|
||||
return KotlinLookupConstantSearch(context)
|
||||
}
|
||||
}
|
||||
|
||||
private class KotlinLookupConstantSearch(context: CompileContext) : Callbacks.ConstantAffectionResolver {
|
||||
private val pool = Executors.newSingleThreadExecutor()
|
||||
private val kotlinContext by lazy { context.kotlin }
|
||||
|
||||
override fun request(
|
||||
ownerClassName: String,
|
||||
fieldName: String,
|
||||
accessFlags: Int,
|
||||
fieldRemoved: Boolean,
|
||||
accessChanged: Boolean
|
||||
): Future<Callbacks.ConstantAffection> {
|
||||
val future = object : BasicFuture<Callbacks.ConstantAffection>() {
|
||||
@Volatile
|
||||
private var result: Callbacks.ConstantAffection = Callbacks.ConstantAffection.EMPTY
|
||||
|
||||
fun result(files: Collection<File>) {
|
||||
result = Callbacks.ConstantAffection(files)
|
||||
setDone()
|
||||
}
|
||||
|
||||
override fun get(): Callbacks.ConstantAffection {
|
||||
super.get()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun get(timeout: Long, unit: TimeUnit): Callbacks.ConstantAffection {
|
||||
super.get(timeout, unit)
|
||||
return result
|
||||
}
|
||||
}
|
||||
pool.submit {
|
||||
if (!future.isCancelled) {
|
||||
kotlinContext.lookupStorageManager.withLookupStorage { storage ->
|
||||
val paths = storage.get(LookupSymbol(name = fieldName, scope = ownerClassName))
|
||||
future.result(paths.map { File(it) })
|
||||
}
|
||||
}
|
||||
}
|
||||
return future
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user