From 52baf7338edcbc877e2ca1b0c7b63665d15f0e80 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 16 Dec 2021 11:08:25 +0300 Subject: [PATCH] Move KotlinBinaryClassCache to separate module, so it can be used outside FE1.0 --- compiler/frontend.common.jvm/build.gradle.kts | 21 +++++++++++++++++++ .../load/kotlin/FileBasedKotlinClass.java | 16 +++----------- .../load/kotlin/KotlinBinaryClassCache.kt | 16 +++----------- .../load/kotlin/VirtualFileKotlinClass.kt | 16 +++----------- compiler/frontend.java/build.gradle.kts | 2 ++ .../kotlin/load/kotlin/VirtualFileFinder.kt | 1 + .../load/kotlin/moduleVisibilityUtils.kt | 1 + settings.gradle | 1 + 8 files changed, 35 insertions(+), 39 deletions(-) create mode 100644 compiler/frontend.common.jvm/build.gradle.kts rename compiler/{frontend.java => frontend.common.jvm}/src/org/jetbrains/kotlin/load/kotlin/FileBasedKotlinClass.java (96%) rename compiler/{frontend.java => frontend.common.jvm}/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt (82%) rename compiler/{frontend.java => frontend.common.jvm}/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt (84%) diff --git a/compiler/frontend.common.jvm/build.gradle.kts b/compiler/frontend.common.jvm/build.gradle.kts new file mode 100644 index 00000000000..2c27c289978 --- /dev/null +++ b/compiler/frontend.common.jvm/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + api(project(":core:metadata.jvm")) + api(project(":core:deserialization.common")) + api(project(":core:deserialization.common.jvm")) + implementation(project(":core:compiler.common.jvm")) + api(intellijCoreDep()) { includeJars("intellij-core", rootProject = rootProject) } + implementation(intellijDep()) { includeJars("asm-all", rootProject = rootProject) } + + implementation(project(":core:descriptors.jvm")) + +} + +sourceSets { + "main" { projectDefault() } + "test" {} +} diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/FileBasedKotlinClass.java b/compiler/frontend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/FileBasedKotlinClass.java similarity index 96% rename from compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/FileBasedKotlinClass.java rename to compiler/frontend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/FileBasedKotlinClass.java index 68649234e73..a998f0e9e9c 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/FileBasedKotlinClass.java +++ b/compiler/frontend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/FileBasedKotlinClass.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.load.kotlin; @@ -22,6 +11,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap; import org.jetbrains.kotlin.descriptors.SourceElement; +import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass; import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader; import org.jetbrains.kotlin.load.kotlin.header.ReadKotlinClassHeaderAnnotationVisitor; import org.jetbrains.kotlin.name.ClassId; diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt b/compiler/frontend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt similarity index 82% rename from compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt rename to compiler/frontend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt index c43b2826ad0..f71242fd2c3 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt +++ b/compiler/frontend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.load.kotlin @@ -23,6 +12,7 @@ import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.util.Computable import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiJavaModule +import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder import java.lang.ref.WeakReference import java.util.concurrent.CopyOnWriteArrayList diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt b/compiler/frontend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt similarity index 84% rename from compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt rename to compiler/frontend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt index 56549178692..903bded0252 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt +++ b/compiler/frontend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.load.kotlin @@ -20,6 +9,7 @@ import com.intellij.ide.highlighter.JavaClassFileType import com.intellij.openapi.diagnostic.ControlFlowException import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.vfs.VirtualFile +import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder.Result.KotlinClass import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader import org.jetbrains.kotlin.name.ClassId diff --git a/compiler/frontend.java/build.gradle.kts b/compiler/frontend.java/build.gradle.kts index 2580b9efa8f..f24e5289354 100644 --- a/compiler/frontend.java/build.gradle.kts +++ b/compiler/frontend.java/build.gradle.kts @@ -11,6 +11,8 @@ dependencies { api("javax.annotation:jsr250-api:1.0") api(project(":compiler:frontend")) api(project(":compiler:resolution.common.jvm")) + api(project(":compiler:frontend.common.jvm")) + compileOnly(intellijCore()) compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all")) compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j")) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileFinder.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileFinder.kt index a057b0db9e3..ab276d14006 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileFinder.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileFinder.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.search.GlobalSearchScope import org.jetbrains.annotations.TestOnly import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.load.java.structure.impl.VirtualFileBoundJavaClass import org.jetbrains.kotlin.name.ClassId diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/moduleVisibilityUtils.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/moduleVisibilityUtils.kt index a5f850805f9..de31f74e230 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/moduleVisibilityUtils.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/moduleVisibilityUtils.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.openapi.vfs.VfsUtilCore import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.load.kotlin.VirtualFileKotlinClass import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageFragment import org.jetbrains.kotlin.modules.Module import org.jetbrains.kotlin.resolve.DescriptorUtils diff --git a/settings.gradle b/settings.gradle index 6c0765d5463..8583cc6eb0a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -181,6 +181,7 @@ include ":benchmarks", ":core:metadata.jvm", ":core:deserialization.common", ":core:deserialization.common.jvm", + ":compiler:frontend.common.jvm", ":core:util.runtime", ":compiler:compiler.version", ":dependencies:android-sdk",