aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kotlin1521/kotlin/com/replaymod/gradle/remap/kotlin1521.kt18
-rw-r--r--src/kotlin1620/kotlin/com/replaymod/gradle/remap/kotlin1620.kt18
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt4
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt28
4 files changed, 48 insertions, 20 deletions
diff --git a/src/kotlin1521/kotlin/com/replaymod/gradle/remap/kotlin1521.kt b/src/kotlin1521/kotlin/com/replaymod/gradle/remap/kotlin1521.kt
new file mode 100644
index 0000000..c63cb98
--- /dev/null
+++ b/src/kotlin1521/kotlin/com/replaymod/gradle/remap/kotlin1521.kt
@@ -0,0 +1,18 @@
+package com.replaymod.gradle.remap
+
+import org.jetbrains.kotlin.analyzer.AnalysisResult
+import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
+import org.jetbrains.kotlin.cli.jvm.compiler.NoScopeRecordCliBindingTrace
+import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
+import org.jetbrains.kotlin.com.intellij.psi.search.GlobalSearchScope
+import org.jetbrains.kotlin.psi.KtFile
+
+fun analyze1521(environment: KotlinCoreEnvironment, ktFiles: List<KtFile>): AnalysisResult {
+ return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
+ environment.project,
+ ktFiles,
+ NoScopeRecordCliBindingTrace(),
+ environment.configuration,
+ { scope: GlobalSearchScope -> environment.createPackagePartProvider(scope) }
+ )
+}
diff --git a/src/kotlin1620/kotlin/com/replaymod/gradle/remap/kotlin1620.kt b/src/kotlin1620/kotlin/com/replaymod/gradle/remap/kotlin1620.kt
new file mode 100644
index 0000000..2574bfe
--- /dev/null
+++ b/src/kotlin1620/kotlin/com/replaymod/gradle/remap/kotlin1620.kt
@@ -0,0 +1,18 @@
+package com.replaymod.gradle.remap
+
+import org.jetbrains.kotlin.analyzer.AnalysisResult
+import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
+import org.jetbrains.kotlin.cli.jvm.compiler.NoScopeRecordCliBindingTrace
+import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
+import org.jetbrains.kotlin.com.intellij.psi.search.GlobalSearchScope
+import org.jetbrains.kotlin.psi.KtFile
+
+fun analyze1620(environment: KotlinCoreEnvironment, ktFiles: List<KtFile>): AnalysisResult {
+ return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
+ environment.project,
+ ktFiles,
+ NoScopeRecordCliBindingTrace(),
+ environment.configuration,
+ { scope: GlobalSearchScope -> environment.createPackagePartProvider(scope) }
+ )
+}
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
index dbd3f2e..1c5ac67 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -18,6 +18,8 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
import org.jetbrains.kotlin.lexer.KtTokens
+import org.jetbrains.kotlin.load.java.propertyNameByGetMethodName
+import org.jetbrains.kotlin.load.java.propertyNameBySetMethodName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.endOffset
@@ -29,8 +31,6 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperclassesWithoutAny
import org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeAsSequence
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
-import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor.Companion.propertyNameByGetMethodName
-import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor.Companion.propertyNameBySetMethodName
import java.util.*
internal class PsiMapper(
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt b/src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt
index 24f41ce..67b065e 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt
@@ -10,8 +10,6 @@ import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
-import org.jetbrains.kotlin.cli.jvm.compiler.NoScopeRecordCliBindingTrace
-import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
import org.jetbrains.kotlin.com.intellij.codeInsight.CustomExceptionHandler
@@ -25,7 +23,6 @@ import org.jetbrains.kotlin.com.intellij.openapi.vfs.StandardFileSystems
import org.jetbrains.kotlin.com.intellij.openapi.vfs.VirtualFileManager
import org.jetbrains.kotlin.com.intellij.openapi.vfs.local.CoreLocalFileSystem
import org.jetbrains.kotlin.com.intellij.psi.PsiManager
-import org.jetbrains.kotlin.com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
@@ -90,13 +87,11 @@ class Transformer(private val map: MappingSet) {
val psiFiles = virtualFiles.mapValues { psiManager.findFile(it.value)!! }
val ktFiles = psiFiles.values.filterIsInstance<KtFile>()
- val analysis = TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
- project,
- ktFiles,
- NoScopeRecordCliBindingTrace(),
- environment.configuration,
- { scope: GlobalSearchScope -> environment.createPackagePartProvider(scope) }
- )
+ val analysis = try {
+ analyze1521(environment, ktFiles)
+ } catch (e: NoSuchMethodError) {
+ analyze1620(environment, ktFiles)
+ }
val remappedProject = remappedClasspath?.let { setupRemappedProject(disposable, it) }
@@ -146,14 +141,11 @@ class Transformer(private val map: MappingSet) {
config,
EnvironmentConfigFiles.JVM_CONFIG_FILES
)
- val project = environment.project
- TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
- project,
- emptyList(),
- NoScopeRecordCliBindingTrace(),
- environment.configuration,
- { scope: GlobalSearchScope -> environment.createPackagePartProvider(scope) }
- )
+ try {
+ analyze1521(environment, emptyList())
+ } catch (e: NoSuchMethodError) {
+ analyze1620(environment, emptyList())
+ }
return environment.project
}