New J2K: Fix converters spliting
This commit is contained in:
committed by
Ilya Kirillov
parent
db2ad96f00
commit
02a206bf7c
@@ -96,6 +96,7 @@ dependencies {
|
|||||||
testRuntime(project(":idea:idea-android")) { isTransitive = false }
|
testRuntime(project(":idea:idea-android")) { isTransitive = false }
|
||||||
testRuntime(project(":plugins:lint")) { isTransitive = false }
|
testRuntime(project(":plugins:lint")) { isTransitive = false }
|
||||||
testRuntime(project(":plugins:uast-kotlin"))
|
testRuntime(project(":plugins:uast-kotlin"))
|
||||||
|
testRuntime(project(":nj2k:nj2k-services")) { isTransitive = false }
|
||||||
|
|
||||||
(rootProject.extra["compilerModules"] as Array<String>).forEach {
|
(rootProject.extra["compilerModules"] as Array<String>).forEach {
|
||||||
testRuntime(project(it))
|
testRuntime(project(it))
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ data class FilesResult(val results: List<String>, val externalCodeProcessing: Ex
|
|||||||
|
|
||||||
abstract class JavaToKotlinConverter(private val project: Project) {
|
abstract class JavaToKotlinConverter(private val project: Project) {
|
||||||
protected abstract fun elementsToKotlin(inputElements: List<PsiElement>, processor: WithProgressProcessor): Result
|
protected abstract fun elementsToKotlin(inputElements: List<PsiElement>, processor: WithProgressProcessor): Result
|
||||||
|
protected abstract fun createDummyKtFile(text: String, project: Project, context: PsiElement): KtFile
|
||||||
|
|
||||||
private val LOG = Logger.getInstance("#org.jetbrains.kotlin.j2k.JavaToKotlinConverter")
|
private val LOG = Logger.getInstance("#org.jetbrains.kotlin.j2k.JavaToKotlinConverter")
|
||||||
|
|
||||||
@@ -84,7 +85,7 @@ abstract class JavaToKotlinConverter(private val project: Project) {
|
|||||||
val (i, result) = pair
|
val (i, result) = pair
|
||||||
try {
|
try {
|
||||||
val kotlinFile = ApplicationManager.getApplication().runReadAction(Computable {
|
val kotlinFile = ApplicationManager.getApplication().runReadAction(Computable {
|
||||||
KtPsiFactory(project).createFileWithLightClassSupport("dummy.kt", result!!.text, files[i])
|
createDummyKtFile(result!!.text, project, files[i])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -119,7 +120,10 @@ class OldJavaToKotlinConverter(
|
|||||||
private val services: JavaToKotlinConverterServices
|
private val services: JavaToKotlinConverterServices
|
||||||
) : JavaToKotlinConverter(project) {
|
) : JavaToKotlinConverter(project) {
|
||||||
|
|
||||||
protected override fun elementsToKotlin(inputElements: List<PsiElement>, processor: WithProgressProcessor): Result {
|
override fun createDummyKtFile(text: String, project: Project, context: PsiElement): KtFile =
|
||||||
|
KtPsiFactory(project).createAnalyzableFile("dummy.kt", text, context)
|
||||||
|
|
||||||
|
override fun elementsToKotlin(inputElements: List<PsiElement>, processor: WithProgressProcessor): Result {
|
||||||
try {
|
try {
|
||||||
val usageProcessings = LinkedHashMap<PsiElement, MutableCollection<UsageProcessing>>()
|
val usageProcessings = LinkedHashMap<PsiElement, MutableCollection<UsageProcessing>>()
|
||||||
val usageProcessingCollector: (UsageProcessing) -> Unit = {
|
val usageProcessingCollector: (UsageProcessing) -> Unit = {
|
||||||
|
|||||||
+5
-10
@@ -8,11 +8,9 @@ plugins {
|
|||||||
dependencies {
|
dependencies {
|
||||||
testRuntime(intellijDep())
|
testRuntime(intellijDep())
|
||||||
|
|
||||||
compile(project(":j2k"))
|
compile(kotlinStdlib())
|
||||||
testCompile(files(project(":j2k").dependencyProject.sourceSets.getByName("test").output))
|
|
||||||
|
|
||||||
compile(project(":idea:idea-core"))
|
compile(project(":idea:idea-core"))
|
||||||
compile(project(":kotlin-stdlib"))
|
compile(project(":j2k"))
|
||||||
compile(project(":compiler:frontend"))
|
compile(project(":compiler:frontend"))
|
||||||
compile(project(":compiler:frontend.java"))
|
compile(project(":compiler:frontend.java"))
|
||||||
compile(project(":compiler:light-classes"))
|
compile(project(":compiler:light-classes"))
|
||||||
@@ -20,6 +18,7 @@ dependencies {
|
|||||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
|
|
||||||
testCompile(project(":idea"))
|
testCompile(project(":idea"))
|
||||||
|
testCompile(projectTests(":j2k"))
|
||||||
testCompile(project(":nj2k:nj2k-services"))
|
testCompile(project(":nj2k:nj2k-services"))
|
||||||
testCompile(projectTests(":idea:idea-test-framework"))
|
testCompile(projectTests(":idea:idea-test-framework"))
|
||||||
testCompile(project(":compiler:light-classes"))
|
testCompile(project(":compiler:light-classes"))
|
||||||
@@ -61,6 +60,7 @@ dependencies {
|
|||||||
testRuntime(intellijPluginDep("properties"))
|
testRuntime(intellijPluginDep("properties"))
|
||||||
testRuntime(intellijPluginDep("java-i18n"))
|
testRuntime(intellijPluginDep("java-i18n"))
|
||||||
testRuntime(intellijPluginDep("java-decompiler"))
|
testRuntime(intellijPluginDep("java-decompiler"))
|
||||||
|
testRuntime(project(":plugins:kapt3-idea")) { isTransitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -73,12 +73,9 @@ projectTest {
|
|||||||
workingDir = rootDir
|
workingDir = rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
testsJar()
|
testsJar()
|
||||||
|
|
||||||
|
|
||||||
val test: Test by tasks
|
|
||||||
val cleanTest by tasks
|
|
||||||
|
|
||||||
configureFreeCompilerArg(true, "-Xeffect-system")
|
configureFreeCompilerArg(true, "-Xeffect-system")
|
||||||
configureFreeCompilerArg(true, "-Xnew-inference")
|
configureFreeCompilerArg(true, "-Xnew-inference")
|
||||||
|
|
||||||
@@ -93,6 +90,4 @@ fun configureFreeCompilerArg(isEnabled: Boolean, compilerArgument: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ideaPlugin()
|
ideaPlugin()
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import com.intellij.psi.PsiElement
|
|||||||
import org.jetbrains.kotlin.j2k.*
|
import org.jetbrains.kotlin.j2k.*
|
||||||
import org.jetbrains.kotlin.nj2k.tree.JKTreeElement
|
import org.jetbrains.kotlin.nj2k.tree.JKTreeElement
|
||||||
import org.jetbrains.kotlin.nj2k.tree.prettyDebugPrintTree
|
import org.jetbrains.kotlin.nj2k.tree.prettyDebugPrintTree
|
||||||
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
|
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||||
|
|
||||||
class NewJavaToKotlinConverter(
|
class NewJavaToKotlinConverter(
|
||||||
val project: Project,
|
val project: Project,
|
||||||
@@ -31,6 +33,9 @@ class NewJavaToKotlinConverter(
|
|||||||
override val oldServices = oldConverterServices
|
override val oldServices = oldConverterServices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun createDummyKtFile(text: String, project: Project, context: PsiElement): KtFile =
|
||||||
|
KtPsiFactory(project).createFileWithLightClassSupport("dummy.kt", text, context)
|
||||||
|
|
||||||
private fun List<JKTreeElement>.prettyPrintTrees() = buildString {
|
private fun List<JKTreeElement>.prettyPrintTrees() = buildString {
|
||||||
for (tree in this@prettyPrintTrees) {
|
for (tree in this@prettyPrintTrees) {
|
||||||
appendln()
|
appendln()
|
||||||
|
|||||||
Reference in New Issue
Block a user