diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/PsiClassFinderImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/PsiClassFinderImpl.java index 2cf425c5175..46738479bf0 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/PsiClassFinderImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/PsiClassFinderImpl.java @@ -82,7 +82,7 @@ public class PsiClassFinderImpl implements PsiClassFinder { if ("jet".equals(qualifiedName.parent().getFqName())) { PsiAnnotation assertInvisibleAnnotation = - JavaAnnotationResolver.findAnnotation(original, JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().getFqName()); + JavaAnnotationResolver.findOwnAnnotation(original, JvmStdlibNames.ASSERT_INVISIBLE_IN_RESOLVER.getFqName().getFqName()); if (assertInvisibleAnnotation != null) { if (runtimeClassesHandleMode == RuntimeClassesHandleMode.IGNORE) { return null; diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetClassAnnotation.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetClassAnnotation.java index 2b6711f830a..3af667a9e36 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetClassAnnotation.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetClassAnnotation.java @@ -56,7 +56,8 @@ public class JetClassAnnotation extends PsiAnnotationWithFlags { @NotNull public static JetClassAnnotation get(PsiClass psiClass) { - final PsiAnnotation annotation = JavaAnnotationResolver.findAnnotation(psiClass, JvmStdlibNames.JET_CLASS.getFqName().getFqName()); + final PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass, + JvmStdlibNames.JET_CLASS.getFqName().getFqName()); return annotation != null ? new JetClassAnnotation(annotation) : NULL_ANNOTATION; } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetConstructorAnnotation.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetConstructorAnnotation.java index 6a7af8d49f8..d7ea754daa1 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetConstructorAnnotation.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetConstructorAnnotation.java @@ -51,7 +51,7 @@ public class JetConstructorAnnotation extends PsiAnnotationWithFlags { public static JetConstructorAnnotation get(PsiMethod constructor) { final PsiAnnotation annotation = - JavaAnnotationResolver.findAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName()); + JavaAnnotationResolver.findOwnAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName()); return annotation != null ? new JetConstructorAnnotation(annotation) : NULL_ANNOTATION; } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetMethodAnnotation.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetMethodAnnotation.java index 4985ee36dfd..665c2cbc7b7 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetMethodAnnotation.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetMethodAnnotation.java @@ -73,7 +73,7 @@ public class JetMethodAnnotation extends PsiAnnotationWithFlags { public static JetMethodAnnotation get(PsiMethod psiMethod) { final PsiAnnotation annotation = - JavaAnnotationResolver.findAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().getFqName()); + JavaAnnotationResolver.findOwnAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().getFqName()); return annotation != null ? new JetMethodAnnotation(annotation) : NULL_ANNOTATION; } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetTypeParameterAnnotation.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetTypeParameterAnnotation.java index 5167abc384b..e89f8143865 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetTypeParameterAnnotation.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetTypeParameterAnnotation.java @@ -43,7 +43,7 @@ public class JetTypeParameterAnnotation extends PsiAnnotationWrapper { @NotNull public static JetTypeParameterAnnotation get(@NotNull PsiParameter psiParameter) { final PsiAnnotation annotation = - JavaAnnotationResolver.findAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().getFqName()); + JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().getFqName()); return annotation != null ? new JetTypeParameterAnnotation(annotation) : NULL_ANNOTATION; } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetValueParameterAnnotation.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetValueParameterAnnotation.java index d867dc03860..afe70031e6c 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetValueParameterAnnotation.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/JetValueParameterAnnotation.java @@ -74,7 +74,7 @@ public class JetValueParameterAnnotation extends PsiAnnotationWrapper { public static JetValueParameterAnnotation get(PsiParameter psiParameter) { final PsiAnnotation annotation = - JavaAnnotationResolver.findAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName()); + JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName()); return annotation != null ? new JetValueParameterAnnotation(annotation) : NULL_ANNOTATION; } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/KotlinSignatureAnnotation.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/KotlinSignatureAnnotation.java index 402ce820092..0d37cb528ae 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/KotlinSignatureAnnotation.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kt/KotlinSignatureAnnotation.java @@ -54,7 +54,7 @@ public class KotlinSignatureAnnotation extends PsiAnnotationWrapper { @NotNull public static KotlinSignatureAnnotation get(PsiModifierListOwner psiModifierListOwner) { final PsiAnnotation annotation = - JavaAnnotationResolver.findAnnotation(psiModifierListOwner, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName()); + JavaAnnotationResolver.findAnnotationWithExternal(psiModifierListOwner, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName()); return annotation != null ? new KotlinSignatureAnnotation(annotation) : NULL_ANNOTATION; } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaAnnotationResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaAnnotationResolver.java index efbf7f362d7..8a206104147 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaAnnotationResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaAnnotationResolver.java @@ -24,8 +24,11 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.lang.resolve.constants.*; -import org.jetbrains.jet.lang.resolve.java.*; +import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; +import org.jetbrains.jet.lang.resolve.java.DescriptorResolverUtils; +import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule; +import org.jetbrains.jet.lang.resolve.java.JavaToKotlinClassMap; +import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.Name; @@ -146,7 +149,7 @@ public final class JavaAnnotationResolver { } @Nullable - public static PsiAnnotation findAnnotation(@NotNull PsiModifierListOwner owner, @NotNull String fqName) { + public static PsiAnnotation findOwnAnnotation(@NotNull PsiModifierListOwner owner, @NotNull String fqName) { PsiModifierList list = owner.getModifierList(); if (list != null) { PsiAnnotation found = list.findAnnotation(fqName); @@ -155,6 +158,16 @@ public final class JavaAnnotationResolver { } } + return null; + } + + @Nullable + public static PsiAnnotation findAnnotationWithExternal(@NotNull PsiModifierListOwner owner, @NotNull String fqName) { + PsiAnnotation annotation = findOwnAnnotation(owner, fqName); + if (annotation != null) { + return annotation; + } + return ExternalAnnotationsManager.getInstance(owner.getProject()).findExternalAnnotation(owner, fqName); } } \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java index e3520a6a4b6..40d312dd6e8 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaFunctionResolver.java @@ -309,7 +309,7 @@ public final class JavaFunctionResolver { returnType, JavaTypeTransformer.TypeUsage.MEMBER_SIGNATURE_COVARIANT, typeVariableResolver); } - if (JavaAnnotationResolver.findAnnotation(method.getPsiMethod(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != + if (JavaAnnotationResolver.findAnnotationWithExternal(method.getPsiMethod(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null) { return TypeUtils.makeNullableAsSpecified(transformedType, false); } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java index 0257bc337b2..06fce396e8d 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaPropertyResolver.java @@ -379,7 +379,7 @@ public final class JavaPropertyResolver { JetType propertyType = semanticServices.getTypeTransformer().transformToType( characteristicMember.getType().getPsiType(), typeVariableResolverForPropertyInternals); - boolean hasNotNullAnnotation = JavaAnnotationResolver.findAnnotation( + boolean hasNotNullAnnotation = JavaAnnotationResolver.findAnnotationWithExternal( characteristicMember.getType().getPsiNotNullOwner(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null; diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaValueParameterResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaValueParameterResolver.java index 67d155a475b..b427f0546d3 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaValueParameterResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaValueParameterResolver.java @@ -93,8 +93,7 @@ public final class JavaValueParameterResolver { else { JetType transformedType; - if (JavaAnnotationResolver - .findAnnotation(parameter.getPsiParameter(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != + if (JavaAnnotationResolver.findAnnotationWithExternal(parameter.getPsiParameter(), JvmAbi.JETBRAINS_NOT_NULL_ANNOTATION.getFqName().getFqName()) != null) { transformedType = TypeUtils.makeNullableAsSpecified(outType, false); } diff --git a/idea/src/org/jetbrains/jet/plugin/codeInsight/ktSignature/KotlinSignatureUtil.java b/idea/src/org/jetbrains/jet/plugin/codeInsight/ktSignature/KotlinSignatureUtil.java index 27198964a2d..8e85975e2ae 100644 --- a/idea/src/org/jetbrains/jet/plugin/codeInsight/ktSignature/KotlinSignatureUtil.java +++ b/idea/src/org/jetbrains/jet/plugin/codeInsight/ktSignature/KotlinSignatureUtil.java @@ -84,7 +84,7 @@ class KotlinSignatureUtil { static PsiAnnotation findKotlinSignatureAnnotation(@NotNull PsiElement element) { if (!(element instanceof PsiModifierListOwner)) return null; PsiModifierListOwner annotationOwner = getAnnotationOwner(element); - PsiAnnotation annotation = JavaAnnotationResolver.findAnnotation(annotationOwner, KOTLIN_SIGNATURE_ANNOTATION); + PsiAnnotation annotation = JavaAnnotationResolver.findAnnotationWithExternal(annotationOwner, KOTLIN_SIGNATURE_ANNOTATION); if (annotation == null) return null; if (annotation.getParameterList().getAttributes().length == 0) return null; return annotation;