FE: commonize throw-related annotation FQ names
This commit is contained in:
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.load.java.SpecialBuiltinMembers;
|
|||||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
|
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.kotlin.resolve.*;
|
import org.jetbrains.kotlin.resolve.*;
|
||||||
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
|
import org.jetbrains.kotlin.resolve.annotations.ThrowUtilKt;
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.UnderscoreUtilKt;
|
import org.jetbrains.kotlin.resolve.calls.util.UnderscoreUtilKt;
|
||||||
import org.jetbrains.kotlin.resolve.constants.ArrayValue;
|
import org.jetbrains.kotlin.resolve.constants.ArrayValue;
|
||||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||||
@@ -1105,7 +1105,7 @@ public class FunctionCodegen {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(AnnotationUtilKt.JVM_THROWS_ANNOTATION_FQ_NAME);
|
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(ThrowUtilKt.JVM_THROWS_ANNOTATION_FQ_NAME);
|
||||||
if (annotation == null) return Collections.emptyList();
|
if (annotation == null) return Collections.emptyList();
|
||||||
|
|
||||||
Collection<ConstantValue<?>> values = annotation.getAllValueArguments().values();
|
Collection<ConstantValue<?>> values = annotation.getAllValueArguments().values();
|
||||||
|
|||||||
+5
-3
@@ -19,8 +19,10 @@ import org.jetbrains.kotlin.fir.scopes.FirScope
|
|||||||
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
|
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.annotations.JVM_THROWS_ANNOTATION_FQ_NAME
|
||||||
|
import org.jetbrains.kotlin.resolve.annotations.KOTLIN_NATIVE_THROWS_ANNOTATION_FQ_NAME
|
||||||
|
import org.jetbrains.kotlin.resolve.annotations.KOTLIN_THROWS_ANNOTATION_FQ_NAME
|
||||||
|
|
||||||
enum class FirImportingScopeFilter {
|
enum class FirImportingScopeFilter {
|
||||||
ALL, INVISIBLE_CLASSES, MEMBERS_AND_VISIBLE_CLASSES;
|
ALL, INVISIBLE_CLASSES, MEMBERS_AND_VISIBLE_CLASSES;
|
||||||
@@ -127,7 +129,7 @@ abstract class FirAbstractImportingScope(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val ClassId.isJvmOrNativeThrows: Boolean
|
private val ClassId.isJvmOrNativeThrows: Boolean
|
||||||
get() = asSingleFqName() == FqName("kotlin.jvm.Throws") || asSingleFqName() == FqName("kotlin.native.Throws")
|
get() = asSingleFqName().let { it == JVM_THROWS_ANNOTATION_FQ_NAME || it == KOTLIN_NATIVE_THROWS_ANNOTATION_FQ_NAME }
|
||||||
|
|
||||||
private val ClassId.isCommonThrows: Boolean
|
private val ClassId.isCommonThrows: Boolean
|
||||||
get() = asSingleFqName() == FqName("kotlin.Throws")
|
get() = asSingleFqName() == KOTLIN_THROWS_ANNOTATION_FQ_NAME
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* 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.resolve.annotations
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.name.FqName
|
||||||
|
|
||||||
|
// This annotation is declared here in frontend (as opposed to frontend.java) because it's used in AllUnderImportScope
|
||||||
|
// If you wish to add another JVM-related annotation and has/find utility methods, please proceed to jvmAnnotationUtil.kt
|
||||||
|
@JvmField
|
||||||
|
val JVM_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.Throws")
|
||||||
|
|
||||||
|
val KOTLIN_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.Throws")
|
||||||
|
|
||||||
|
val KOTLIN_NATIVE_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.native.Throws")
|
||||||
@@ -43,11 +43,3 @@ fun AnnotationDescriptor.argumentValue(parameterName: String): ConstantValue<*>?
|
|||||||
)
|
)
|
||||||
val JVM_FIELD_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.JvmField")
|
val JVM_FIELD_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.JvmField")
|
||||||
|
|
||||||
// This annotation is declared here in frontend (as opposed to frontend.java) because it's used in AllUnderImportScope
|
|
||||||
// If you wish to add another JVM-related annotation and has/find utility methods, please proceed to jvmAnnotationUtil.kt
|
|
||||||
@JvmField
|
|
||||||
val JVM_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.Throws")
|
|
||||||
|
|
||||||
val KOTLIN_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.Throws")
|
|
||||||
|
|
||||||
val KOTLIN_NATIVE_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.native.Throws")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user