Move all annotation FQ names to JvmAnnotationNames
Delete reflected usages of annotation classes (JetValueParameter.class, KotlinSignature.class, etc.). It's wrong: this is a dependency on the old runtime, whereas the compiler should work with the new one
This commit is contained in:
@@ -19,7 +19,6 @@ package org.jetbrains.jet.codegen;
|
|||||||
|
|
||||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import jet.runtime.typeinfo.JetValueParameter;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.asm4.AnnotationVisitor;
|
import org.jetbrains.asm4.AnnotationVisitor;
|
||||||
@@ -56,7 +55,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContextUtils.callableDescrip
|
|||||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration;
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isFunctionLiteral;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isFunctionLiteral;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils.fqNameByClass;
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.OLD_JET_VALUE_PARAMETER_ANNOTATION;
|
||||||
|
|
||||||
public class FunctionCodegen extends ParentCodegenAwareImpl {
|
public class FunctionCodegen extends ParentCodegenAwareImpl {
|
||||||
private final CodegenContext owner;
|
private final CodegenContext owner;
|
||||||
@@ -213,7 +212,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AnnotationVisitor av =
|
AnnotationVisitor av =
|
||||||
mv.visitParameterAnnotation(i, asmDescByFqNameWithoutInnerClasses(fqNameByClass(JetValueParameter.class)), true);
|
mv.visitParameterAnnotation(i, asmDescByFqNameWithoutInnerClasses(OLD_JET_VALUE_PARAMETER_ANNOTATION), true);
|
||||||
if (av != null) {
|
if (av != null) {
|
||||||
av.visit("name", name);
|
av.visit("name", name);
|
||||||
if (nullableType) {
|
if (nullableType) {
|
||||||
|
|||||||
+3
-7
@@ -17,20 +17,16 @@
|
|||||||
package org.jetbrains.jet.lang.resolve.java.kotlinSignature;
|
package org.jetbrains.jet.lang.resolve.java.kotlinSignature;
|
||||||
|
|
||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import jet.runtime.typeinfo.KotlinSignature;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.ExternalAnnotationResolver;
|
import org.jetbrains.jet.lang.resolve.java.resolver.ExternalAnnotationResolver;
|
||||||
import org.jetbrains.jet.lang.resolve.java.structure.*;
|
import org.jetbrains.jet.lang.resolve.java.structure.*;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils.fqNameByClass;
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME;
|
||||||
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KOTLIN_SIGNATURE;
|
||||||
|
|
||||||
public class SignaturesUtil {
|
public class SignaturesUtil {
|
||||||
public static final FqName KOTLIN_SIGNATURE = fqNameByClass(KotlinSignature.class);
|
|
||||||
public static final Name KOTLIN_SIGNATURE_VALUE_FIELD_NAME = Name.identifier("value");
|
|
||||||
|
|
||||||
private SignaturesUtil() {
|
private SignaturesUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +35,7 @@ public class SignaturesUtil {
|
|||||||
JavaAnnotation annotation = findAnnotationWithExternal(externalAnnotationResolver, member, KOTLIN_SIGNATURE);
|
JavaAnnotation annotation = findAnnotationWithExternal(externalAnnotationResolver, member, KOTLIN_SIGNATURE);
|
||||||
|
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
JavaAnnotationArgument argument = annotation.findArgument(KOTLIN_SIGNATURE_VALUE_FIELD_NAME);
|
JavaAnnotationArgument argument = annotation.findArgument(DEFAULT_ANNOTATION_MEMBER_NAME);
|
||||||
if (argument instanceof JavaLiteralAnnotationArgument) {
|
if (argument instanceof JavaLiteralAnnotationArgument) {
|
||||||
Object value = ((JavaLiteralAnnotationArgument) argument).getValue();
|
Object value = ((JavaLiteralAnnotationArgument) argument).getValue();
|
||||||
if (value instanceof String) {
|
if (value instanceof String) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import org.jetbrains.jet.JetTestUtils;
|
|||||||
import org.jetbrains.jet.TestJdkKind;
|
import org.jetbrains.jet.TestJdkKind;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.CoreExternalAnnotationsManager;
|
import org.jetbrains.jet.cli.jvm.compiler.CoreExternalAnnotationsManager;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesUtil;
|
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames;
|
||||||
import org.jetbrains.jet.lang.resolve.lazy.KotlinTestWithEnvironment;
|
import org.jetbrains.jet.lang.resolve.lazy.KotlinTestWithEnvironment;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
|
||||||
@@ -166,9 +166,9 @@ public class IdeaJdkAnnotationsReflectedTest extends KotlinTestWithEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private enum AnnotationsKind {
|
private enum AnnotationsKind {
|
||||||
KOTLIN_SIGNATURE(SignaturesUtil.KOTLIN_SIGNATURE.asString()),
|
KOTLIN_SIGNATURE(JvmAnnotationNames.KOTLIN_SIGNATURE.asString()),
|
||||||
NOT_NULL(AnnotationUtil.NOT_NULL),
|
NOT_NULL(AnnotationUtil.NOT_NULL),
|
||||||
ANY(AnnotationUtil.NOT_NULL, SignaturesUtil.KOTLIN_SIGNATURE.asString());
|
ANY(AnnotationUtil.NOT_NULL, JvmAnnotationNames.KOTLIN_SIGNATURE.asString());
|
||||||
|
|
||||||
public final String[] annotationNames;
|
public final String[] annotationNames;
|
||||||
|
|
||||||
|
|||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2014 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.jet.lang.resolve.java;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils.fqNameByClass;
|
|
||||||
|
|
||||||
public final class AnnotationLoadingUtil {
|
|
||||||
public static final Name DEFAULT_ANNOTATION_MEMBER_NAME = Name.identifier("value");
|
|
||||||
public static final FqName JETBRAINS_NOT_NULL_ANNOTATION = fqNameByClass(NotNull.class);
|
|
||||||
public static final FqName JETBRAINS_NULLABLE_ANNOTATION = fqNameByClass(Nullable.class);
|
|
||||||
public static final FqName JETBRAINS_MUTABLE_ANNOTATION = new FqName("org.jetbrains.annotations.Mutable");
|
|
||||||
public static final FqName JETBRAINS_READONLY_ANNOTATION = new FqName("org.jetbrains.annotations.ReadOnly");
|
|
||||||
public static final FqName JL_CLASS_FQ_NAME = new FqName("java.lang.Class");
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static boolean isSpecialAnnotation(@NotNull FqName fqName) {
|
|
||||||
return fqName.asString().startsWith("jet.runtime.typeinfo.")
|
|
||||||
|| fqName.equals(JETBRAINS_NOT_NULL_ANNOTATION)
|
|
||||||
|| fqName.equals(JvmAnnotationNames.OLD_KOTLIN_CLASS)
|
|
||||||
|| fqName.equals(JvmAnnotationNames.OLD_KOTLIN_PACKAGE)
|
|
||||||
|| fqName.equals(JvmAnnotationNames.KOTLIN_CLASS)
|
|
||||||
|| fqName.equals(JvmAnnotationNames.KOTLIN_PACKAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private AnnotationLoadingUtil() {}
|
|
||||||
}
|
|
||||||
+22
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.java;
|
package org.jetbrains.jet.lang.resolve.java;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
|
|
||||||
public final class JvmAnnotationNames {
|
public final class JvmAnnotationNames {
|
||||||
public static final FqName KOTLIN_CLASS = new FqName("kotlin.jvm.internal.KotlinClass");
|
public static final FqName KOTLIN_CLASS = new FqName("kotlin.jvm.internal.KotlinClass");
|
||||||
@@ -24,14 +26,24 @@ public final class JvmAnnotationNames {
|
|||||||
public static final FqName KOTLIN_PACKAGE_PART = new FqName("kotlin.jvm.internal.KotlinPackagePart");
|
public static final FqName KOTLIN_PACKAGE_PART = new FqName("kotlin.jvm.internal.KotlinPackagePart");
|
||||||
public static final FqName KOTLIN_TRAIT_IMPL = new FqName("kotlin.jvm.internal.KotlinTraitImpl");
|
public static final FqName KOTLIN_TRAIT_IMPL = new FqName("kotlin.jvm.internal.KotlinTraitImpl");
|
||||||
|
|
||||||
|
public static final FqName KOTLIN_SIGNATURE = new FqName("jet.runtime.typeinfo.KotlinSignature");
|
||||||
|
|
||||||
public static final String ABI_VERSION_FIELD_NAME = "abiVersion";
|
public static final String ABI_VERSION_FIELD_NAME = "abiVersion";
|
||||||
public static final String DATA_FIELD_NAME = "data";
|
public static final String DATA_FIELD_NAME = "data";
|
||||||
|
public static final Name DEFAULT_ANNOTATION_MEMBER_NAME = Name.identifier("value");
|
||||||
|
|
||||||
|
public static final FqName JETBRAINS_NOT_NULL_ANNOTATION = new FqName("org.jetbrains.annotations.NotNull");
|
||||||
|
public static final FqName JETBRAINS_NULLABLE_ANNOTATION = new FqName("org.jetbrains.annotations.Nullable");
|
||||||
|
public static final FqName JETBRAINS_MUTABLE_ANNOTATION = new FqName("org.jetbrains.annotations.Mutable");
|
||||||
|
public static final FqName JETBRAINS_READONLY_ANNOTATION = new FqName("org.jetbrains.annotations.ReadOnly");
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final FqName OLD_JET_CLASS_ANNOTATION = new FqName("jet.runtime.typeinfo.JetClass");
|
public static final FqName OLD_JET_CLASS_ANNOTATION = new FqName("jet.runtime.typeinfo.JetClass");
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final FqName OLD_JET_PACKAGE_CLASS_ANNOTATION = new FqName("jet.runtime.typeinfo.JetPackageClass");
|
public static final FqName OLD_JET_PACKAGE_CLASS_ANNOTATION = new FqName("jet.runtime.typeinfo.JetPackageClass");
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
public static final FqName OLD_JET_VALUE_PARAMETER_ANNOTATION = new FqName("jet.runtime.typeinfo.JetValueParameter");
|
||||||
|
@Deprecated
|
||||||
public static final FqName OLD_KOTLIN_CLASS = new FqName("jet.KotlinClass");
|
public static final FqName OLD_KOTLIN_CLASS = new FqName("jet.KotlinClass");
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final FqName OLD_KOTLIN_PACKAGE = new FqName("jet.KotlinPackage");
|
public static final FqName OLD_KOTLIN_PACKAGE = new FqName("jet.KotlinPackage");
|
||||||
@@ -40,6 +52,16 @@ public final class JvmAnnotationNames {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public static final FqName OLD_KOTLIN_TRAIT_IMPL = new FqName("jet.KotlinTraitImpl");
|
public static final FqName OLD_KOTLIN_TRAIT_IMPL = new FqName("jet.KotlinTraitImpl");
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static boolean isSpecialAnnotation(@NotNull FqName fqName) {
|
||||||
|
return fqName.asString().startsWith("jet.runtime.typeinfo.")
|
||||||
|
|| fqName.equals(JETBRAINS_NOT_NULL_ANNOTATION)
|
||||||
|
|| fqName.equals(OLD_KOTLIN_CLASS)
|
||||||
|
|| fqName.equals(OLD_KOTLIN_PACKAGE)
|
||||||
|
|| fqName.equals(KOTLIN_CLASS)
|
||||||
|
|| fqName.equals(KOTLIN_PACKAGE);
|
||||||
|
}
|
||||||
|
|
||||||
private JvmAnnotationNames() {
|
private JvmAnnotationNames() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -22,13 +22,13 @@ import org.jetbrains.jet.lang.resolve.name.FqName
|
|||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.java.lazy.descriptors.LazyJavaAnnotationDescriptor
|
import org.jetbrains.jet.lang.resolve.java.lazy.descriptors.LazyJavaAnnotationDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnnotationLoadingUtil
|
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames
|
||||||
|
|
||||||
class LazyJavaAnnotations(c: LazyJavaResolverContextWithTypes, val annotationOwner: JavaAnnotationOwner) : Annotations {
|
class LazyJavaAnnotations(c: LazyJavaResolverContextWithTypes, val annotationOwner: JavaAnnotationOwner) : Annotations {
|
||||||
private val annotationDescriptors = c.storageManager.createMemoizedFunctionWithNullableValues {
|
private val annotationDescriptors = c.storageManager.createMemoizedFunctionWithNullableValues {
|
||||||
(jAnnotation: JavaAnnotation) ->
|
(jAnnotation: JavaAnnotation) ->
|
||||||
val fqName = jAnnotation.getFqName()
|
val fqName = jAnnotation.getFqName()
|
||||||
if (fqName == null || AnnotationLoadingUtil.isSpecialAnnotation(fqName)) {
|
if (fqName == null || JvmAnnotationNames.isSpecialAnnotation(fqName)) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
else LazyJavaAnnotationDescriptor(c, jAnnotation)
|
else LazyJavaAnnotationDescriptor(c, jAnnotation)
|
||||||
@@ -54,6 +54,6 @@ fun LazyJavaResolverContextWithTypes.resolveAnnotations(annotationsOwner: JavaAn
|
|||||||
private fun GlobalJavaResolverContext.hasAnnotation(owner: JavaAnnotationOwner, annotationFqName: FqName): Boolean
|
private fun GlobalJavaResolverContext.hasAnnotation(owner: JavaAnnotationOwner, annotationFqName: FqName): Boolean
|
||||||
= owner.findAnnotation(annotationFqName) != null || externalAnnotationResolver.findExternalAnnotation(owner, annotationFqName) != null
|
= owner.findAnnotation(annotationFqName) != null || externalAnnotationResolver.findExternalAnnotation(owner, annotationFqName) != null
|
||||||
|
|
||||||
fun GlobalJavaResolverContext.hasMutableAnnotation(owner: JavaAnnotationOwner): Boolean = hasAnnotation(owner, AnnotationLoadingUtil.JETBRAINS_MUTABLE_ANNOTATION)
|
fun GlobalJavaResolverContext.hasMutableAnnotation(owner: JavaAnnotationOwner): Boolean = hasAnnotation(owner, JvmAnnotationNames.JETBRAINS_MUTABLE_ANNOTATION)
|
||||||
fun GlobalJavaResolverContext.hasReadOnlyAnnotation(owner: JavaAnnotationOwner): Boolean = hasAnnotation(owner, AnnotationLoadingUtil.JETBRAINS_READONLY_ANNOTATION)
|
fun GlobalJavaResolverContext.hasReadOnlyAnnotation(owner: JavaAnnotationOwner): Boolean = hasAnnotation(owner, JvmAnnotationNames.JETBRAINS_READONLY_ANNOTATION)
|
||||||
fun GlobalJavaResolverContext.hasNotNullAnnotation(owner: JavaAnnotationOwner): Boolean = hasAnnotation(owner, AnnotationLoadingUtil.JETBRAINS_NOT_NULL_ANNOTATION)
|
fun GlobalJavaResolverContext.hasNotNullAnnotation(owner: JavaAnnotationOwner): Boolean = hasAnnotation(owner, JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION)
|
||||||
|
|||||||
+3
-4
@@ -13,7 +13,7 @@ import org.jetbrains.jet.lang.resolve.name.FqName
|
|||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptor
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnnotationLoadingUtil.*
|
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.*
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames
|
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils
|
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||||
@@ -33,7 +33,6 @@ import org.jetbrains.jet.renderer.DescriptorRenderer
|
|||||||
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap
|
import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap
|
||||||
import org.jetbrains.jet.lang.types.TypeUtils
|
import org.jetbrains.jet.lang.types.TypeUtils
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.resolveCompileTimeConstantValue
|
import org.jetbrains.jet.lang.resolve.java.resolver.resolveCompileTimeConstantValue
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnnotationLoadingUtil
|
|
||||||
|
|
||||||
private object DEPRECATED_IN_JAVA : JavaLiteralAnnotationArgument {
|
private object DEPRECATED_IN_JAVA : JavaLiteralAnnotationArgument {
|
||||||
override fun getName(): Name? = null
|
override fun getName(): Name? = null
|
||||||
@@ -107,7 +106,7 @@ class LazyJavaAnnotationDescriptor(
|
|||||||
val fqName = javaAnnotation.getFqName()
|
val fqName = javaAnnotation.getFqName()
|
||||||
if (fqName == null) return null
|
if (fqName == null) return null
|
||||||
|
|
||||||
if (AnnotationLoadingUtil.isSpecialAnnotation(fqName)) {
|
if (JvmAnnotationNames.isSpecialAnnotation(fqName)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +145,7 @@ class LazyJavaAnnotationDescriptor(
|
|||||||
private fun resolveFromJavaClassObjectType(javaType: JavaType): CompileTimeConstant<*>? {
|
private fun resolveFromJavaClassObjectType(javaType: JavaType): CompileTimeConstant<*>? {
|
||||||
// Class type is never nullable in 'Foo.class' in Java
|
// Class type is never nullable in 'Foo.class' in Java
|
||||||
val `type` = TypeUtils.makeNotNullable(c.typeResolver.transformJavaType(javaType, TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes()))
|
val `type` = TypeUtils.makeNotNullable(c.typeResolver.transformJavaType(javaType, TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes()))
|
||||||
val jlClass = c.javaClassResolver.resolveClassByFqName(JL_CLASS_FQ_NAME)
|
val jlClass = c.javaClassResolver.resolveClassByFqName(FqName("java.lang.Class"))
|
||||||
if (jlClass == null) return null
|
if (jlClass == null) return null
|
||||||
|
|
||||||
val arguments = listOf(TypeProjectionImpl(`type`))
|
val arguments = listOf(TypeProjectionImpl(`type`))
|
||||||
|
|||||||
+3
-3
@@ -26,7 +26,6 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
import org.jetbrains.jet.lang.resolve.constants.StringValue;
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnnotationLoadingUtil;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage;
|
import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage;
|
||||||
@@ -38,6 +37,7 @@ import org.jetbrains.jet.lang.types.lang.PrimitiveType;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME;
|
||||||
import static org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils.fqNameByClass;
|
import static org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils.fqNameByClass;
|
||||||
|
|
||||||
public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements PlatformToKotlinClassMap {
|
public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements PlatformToKotlinClassMap {
|
||||||
@@ -108,8 +108,8 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
|||||||
private static AnnotationDescriptor getAnnotationDescriptorForJavaLangDeprecated(@NotNull ClassDescriptor annotationClass) {
|
private static AnnotationDescriptor getAnnotationDescriptorForJavaLangDeprecated(@NotNull ClassDescriptor annotationClass) {
|
||||||
AnnotationDescriptorImpl annotation = new AnnotationDescriptorImpl();
|
AnnotationDescriptorImpl annotation = new AnnotationDescriptorImpl();
|
||||||
annotation.setAnnotationType(annotationClass.getDefaultType());
|
annotation.setAnnotationType(annotationClass.getDefaultType());
|
||||||
ValueParameterDescriptor value = DescriptorResolverUtils.getAnnotationParameterByName(
|
ValueParameterDescriptor value =
|
||||||
AnnotationLoadingUtil.DEFAULT_ANNOTATION_MEMBER_NAME, annotationClass);
|
DescriptorResolverUtils.getAnnotationParameterByName(DEFAULT_ANNOTATION_MEMBER_NAME, annotationClass);
|
||||||
assert value != null : "kotlin.deprecated must have one parameter called value";
|
assert value != null : "kotlin.deprecated must have one parameter called value";
|
||||||
annotation.setValueArgument(value, new StringValue("Deprecated in Java", true));
|
annotation.setValueArgument(value, new StringValue("Deprecated in Java", true));
|
||||||
return annotation;
|
return annotation;
|
||||||
|
|||||||
+5
-6
@@ -28,13 +28,11 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
|||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationsImpl;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationsImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnnotationLoadingUtil;
|
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.EnumValue;
|
import org.jetbrains.jet.lang.resolve.constants.EnumValue;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.ErrorValue;
|
import org.jetbrains.jet.lang.resolve.constants.ErrorValue;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
||||||
@@ -52,6 +50,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isClassObject;
|
||||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isTrait;
|
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isTrait;
|
||||||
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.*;
|
||||||
import static org.jetbrains.jet.lang.resolve.kotlin.DeserializedResolverUtils.kotlinFqNameToJavaFqName;
|
import static org.jetbrains.jet.lang.resolve.kotlin.DeserializedResolverUtils.kotlinFqNameToJavaFqName;
|
||||||
import static org.jetbrains.jet.lang.resolve.kotlin.DeserializedResolverUtils.naiveKotlinFqName;
|
import static org.jetbrains.jet.lang.resolve.kotlin.DeserializedResolverUtils.naiveKotlinFqName;
|
||||||
|
|
||||||
@@ -148,10 +147,10 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean ignoreAnnotation(@NotNull JvmClassName className) {
|
private static boolean ignoreAnnotation(@NotNull JvmClassName className) {
|
||||||
return className.equals(JvmClassName.byFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_CLASS))
|
return className.equals(JvmClassName.byFqNameWithoutInnerClasses(KOTLIN_CLASS))
|
||||||
|| className.equals(JvmClassName.byFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_PACKAGE))
|
|| className.equals(JvmClassName.byFqNameWithoutInnerClasses(KOTLIN_PACKAGE))
|
||||||
|| className.equals(JvmClassName.byFqNameWithoutInnerClasses(AnnotationLoadingUtil.JETBRAINS_NOT_NULL_ANNOTATION))
|
|| className.equals(JvmClassName.byFqNameWithoutInnerClasses(JETBRAINS_NOT_NULL_ANNOTATION))
|
||||||
|| className.equals(JvmClassName.byFqNameWithoutInnerClasses(AnnotationLoadingUtil.JETBRAINS_NULLABLE_ANNOTATION))
|
|| className.equals(JvmClassName.byFqNameWithoutInnerClasses(JETBRAINS_NULLABLE_ANNOTATION))
|
||||||
|| className.getInternalName().startsWith("jet/runtime/typeinfo/");
|
|| className.getInternalName().startsWith("jet/runtime/typeinfo/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,13 +33,14 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
|||||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnnotationLoadingUtil;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
import org.jetbrains.jet.lang.resolve.java.resolver.DescriptorResolverUtils;
|
||||||
import org.jetbrains.jet.lang.types.TypeUtils;
|
import org.jetbrains.jet.lang.types.TypeUtils;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||||
|
|
||||||
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME;
|
||||||
|
|
||||||
public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisitor {
|
public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisitor {
|
||||||
|
|
||||||
private static final TokenSet PROPERTY_SET_OPERATIONS =
|
private static final TokenSet PROPERTY_SET_OPERATIONS =
|
||||||
@@ -231,8 +232,8 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito
|
|||||||
private static String getMessageFromAnnotationDescriptor(@NotNull AnnotationDescriptor descriptor) {
|
private static String getMessageFromAnnotationDescriptor(@NotNull AnnotationDescriptor descriptor) {
|
||||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(descriptor.getType());
|
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(descriptor.getType());
|
||||||
assert classDescriptor != null : "ClassDescriptor for kotlin.deprecated mustn't be null";
|
assert classDescriptor != null : "ClassDescriptor for kotlin.deprecated mustn't be null";
|
||||||
ValueParameterDescriptor parameter = DescriptorResolverUtils.getAnnotationParameterByName(
|
ValueParameterDescriptor parameter =
|
||||||
AnnotationLoadingUtil.DEFAULT_ANNOTATION_MEMBER_NAME, classDescriptor);
|
DescriptorResolverUtils.getAnnotationParameterByName(DEFAULT_ANNOTATION_MEMBER_NAME, classDescriptor);
|
||||||
assert parameter != null : "kotlin.deprecated must have one parameter called value";
|
assert parameter != null : "kotlin.deprecated must have one parameter called value";
|
||||||
CompileTimeConstant<?> valueArgument = descriptor.getValueArgument(parameter);
|
CompileTimeConstant<?> valueArgument = descriptor.getValueArgument(parameter);
|
||||||
assert valueArgument != null : "kotlin.deprecated must have value argument";
|
assert valueArgument != null : "kotlin.deprecated must have value argument";
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedExternalAnnotationResolver;
|
import org.jetbrains.jet.lang.resolve.java.resolver.PsiBasedExternalAnnotationResolver;
|
||||||
|
|
||||||
import static org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesUtil.KOTLIN_SIGNATURE;
|
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KOTLIN_SIGNATURE;
|
||||||
|
|
||||||
class KotlinSignatureUtil {
|
class KotlinSignatureUtil {
|
||||||
static final String KOTLIN_SIGNATURE_ANNOTATION = KOTLIN_SIGNATURE.asString();
|
static final String KOTLIN_SIGNATURE_ANNOTATION = KOTLIN_SIGNATURE.asString();
|
||||||
|
|||||||
Reference in New Issue
Block a user