diff --git a/analysis/analysis-api-fir/build.gradle.kts b/analysis/analysis-api-fir/build.gradle.kts index d55778c5865..bb51a06d7b5 100644 --- a/analysis/analysis-api-fir/build.gradle.kts +++ b/analysis/analysis-api-fir/build.gradle.kts @@ -18,7 +18,7 @@ dependencies { api(project(":analysis:analysis-api")) api(project(":analysis:analysis-api-impl-base")) api(project(":analysis:light-classes-base")) - api(project(":compiler:backend")) + api(project(":compiler:backend.common.jvm")) api(intellijCore()) implementation(project(":analysis:analysis-api-providers")) implementation(project(":analysis:analysis-internal-utils")) diff --git a/compiler/backend.common.jvm/build.gradle.kts b/compiler/backend.common.jvm/build.gradle.kts index cb1e31ec804..fc3b805561e 100644 --- a/compiler/backend.common.jvm/build.gradle.kts +++ b/compiler/backend.common.jvm/build.gradle.kts @@ -8,6 +8,7 @@ dependencies { api(project(":compiler:config.jvm")) api(commonDependency("org.jetbrains.intellij.deps:asm-all")) api(commonDependency("com.google.guava:guava")) + compileOnly(intellijCore()) } sourceSets { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/signature/BothSignatureWriter.java b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/codegen/signature/BothSignatureWriter.java similarity index 92% rename from compiler/backend/src/org/jetbrains/kotlin/codegen/signature/BothSignatureWriter.java rename to compiler/backend.common.jvm/src/org/jetbrains/kotlin/codegen/signature/BothSignatureWriter.java index eb0b5aa15a2..5426d016919 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/signature/BothSignatureWriter.java +++ b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/codegen/signature/BothSignatureWriter.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 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-2022 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.codegen.signature; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/signature/JvmSignatureWriter.java b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/codegen/signature/JvmSignatureWriter.java similarity index 87% rename from compiler/backend/src/org/jetbrains/kotlin/codegen/signature/JvmSignatureWriter.java rename to compiler/backend.common.jvm/src/org/jetbrains/kotlin/codegen/signature/JvmSignatureWriter.java index 5b0486226da..0be043b0f48 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/signature/JvmSignatureWriter.java +++ b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/codegen/signature/JvmSignatureWriter.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-2022 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.codegen.signature; diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/TypeMappingModeExtensions.kt b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/TypeMappingModeExtensions.kt similarity index 97% rename from core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/TypeMappingModeExtensions.kt rename to compiler/backend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/TypeMappingModeExtensions.kt index 56dd5d1d6e4..5b45206f446 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/TypeMappingModeExtensions.kt +++ b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/TypeMappingModeExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/inlineClassMapping.kt b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/inlineClassMapping.kt similarity index 94% rename from core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/inlineClassMapping.kt rename to compiler/backend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/inlineClassMapping.kt index 99df989378b..772b0cf8a95 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/inlineClassMapping.kt +++ b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/load/kotlin/inlineClassMapping.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 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. */ diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmClassSignature.java b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmClassSignature.java similarity index 61% rename from compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmClassSignature.java rename to compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmClassSignature.java index 0a8286338a3..b7806db5b4e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmClassSignature.java +++ b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmClassSignature.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-2022 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.resolve.jvm.jvmSignature; diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodGenericSignature.java b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodGenericSignature.java similarity index 67% rename from compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodGenericSignature.java rename to compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodGenericSignature.java index de0080023c9..7519b0c8905 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodGenericSignature.java +++ b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodGenericSignature.java @@ -1,24 +1,12 @@ /* - * Copyright 2010-2016 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-2022 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.resolve.jvm.jvmSignature; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.org.objectweb.asm.Type; import org.jetbrains.org.objectweb.asm.commons.Method; import java.util.List; diff --git a/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterKind.java b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterKind.java new file mode 100644 index 00000000000..9d252879ffc --- /dev/null +++ b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterKind.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2022 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.resolve.jvm.jvmSignature; + +public enum JvmMethodParameterKind { + VALUE, + THIS, + OUTER, + RECEIVER, + CONTEXT_RECEIVER, + CAPTURED_LOCAL_VARIABLE, + ENUM_NAME_OR_ORDINAL, + SUPER_CALL_PARAM, + CONSTRUCTOR_MARKER; + + public boolean isSkippedInGenericSignature() { + return this == OUTER || this == ENUM_NAME_OR_ORDINAL; + } +} diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterSignature.java b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterSignature.java similarity index 65% rename from compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterSignature.java rename to compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterSignature.java index b76ba43431e..77678aaa241 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterSignature.java +++ b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterSignature.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-2022 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.resolve.jvm.jvmSignature; diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodSignature.java b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodSignature.java similarity index 70% rename from compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodSignature.java rename to compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodSignature.java index 3bb7497835f..56f2fbe274e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodSignature.java +++ b/compiler/backend.common.jvm/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodSignature.java @@ -1,23 +1,11 @@ /* - * 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-2022 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.resolve.jvm.jvmSignature; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.jetbrains.org.objectweb.asm.Type; import org.jetbrains.org.objectweb.asm.commons.Method; diff --git a/compiler/frontend.common-psi/src/org/jetbrains/kotlin/resolve/calls/util/psiUtils.kt b/compiler/frontend.common-psi/src/org/jetbrains/kotlin/resolve/calls/util/psiUtils.kt new file mode 100644 index 00000000000..5e24e596fb0 --- /dev/null +++ b/compiler/frontend.common-psi/src/org/jetbrains/kotlin/resolve/calls/util/psiUtils.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2022 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.resolve.calls.util + +import org.jetbrains.kotlin.psi.* + +fun KtElement?.getCalleeExpressionIfAny(): KtExpression? = + when (val element = if (this is KtExpression) KtPsiUtil.deparenthesize(this) else this) { + is KtSimpleNameExpression -> element + is KtCallElement -> element.calleeExpression + is KtQualifiedExpression -> element.selectorExpression.getCalleeExpressionIfAny() + is KtOperationExpression -> element.operationReference + else -> null + } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterKind.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterKind.java deleted file mode 100644 index 5e6f43e6039..00000000000 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/jvmSignature/JvmMethodParameterKind.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -package org.jetbrains.kotlin.resolve.jvm.jvmSignature; - -public enum JvmMethodParameterKind { - VALUE, - THIS, - OUTER, - RECEIVER, - CONTEXT_RECEIVER, - CAPTURED_LOCAL_VARIABLE, - ENUM_NAME_OR_ORDINAL, - SUPER_CALL_PARAM, - CONSTRUCTOR_MARKER; - - public boolean isSkippedInGenericSignature() { - return this == OUTER || this == ENUM_NAME_OR_ORDINAL; - } -} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt index 1f0f588b9d0..6d6c061c50d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 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-2022 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.resolve.calls.util @@ -132,17 +121,6 @@ fun Call.getValueArgumentForExpression(expression: KtExpression): ValueArgument? // Get call / resolved call from binding context -fun KtElement?.getCalleeExpressionIfAny(): KtExpression? { - val element = if (this is KtExpression) KtPsiUtil.deparenthesize(this) else this - return when (element) { - is KtSimpleNameExpression -> element - is KtCallElement -> element.calleeExpression - is KtQualifiedExpression -> element.selectorExpression.getCalleeExpressionIfAny() - is KtOperationExpression -> element.operationReference - else -> null - } -} - /** * For expressions like a(), a[i], a.b.c(), +a, a + b, (a()), a(): Int, @label a() * returns a corresponding call.