Passing real original element to EditSignatureBalloon to make external annotations work for compiled class files.
This commit is contained in:
+11
-6
@@ -82,6 +82,15 @@ public class KotlinSignatureInJavaMarkerProvider implements LineMarkerProvider {
|
|||||||
@Nullable
|
@Nullable
|
||||||
static PsiAnnotation findKotlinSignatureAnnotation(@NotNull PsiElement element) {
|
static PsiAnnotation findKotlinSignatureAnnotation(@NotNull PsiElement element) {
|
||||||
if (!(element instanceof PsiMethod)) return null;
|
if (!(element instanceof PsiMethod)) return null;
|
||||||
|
PsiMethod annotationOwner = getAnnotationOwner(element);
|
||||||
|
PsiAnnotation annotation =
|
||||||
|
JavaDescriptorResolver.findAnnotation(annotationOwner, KOTLIN_SIGNATURE_ANNOTATION);
|
||||||
|
if (annotation == null) return null;
|
||||||
|
if (annotation.getParameterList().getAttributes().length == 0) return null;
|
||||||
|
return annotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PsiMethod getAnnotationOwner(PsiElement element) {
|
||||||
PsiMethod annotationOwner = element.getOriginalElement() instanceof PsiMethod
|
PsiMethod annotationOwner = element.getOriginalElement() instanceof PsiMethod
|
||||||
? (PsiMethod) element.getOriginalElement()
|
? (PsiMethod) element.getOriginalElement()
|
||||||
: (PsiMethod) element;
|
: (PsiMethod) element;
|
||||||
@@ -94,11 +103,7 @@ public class KotlinSignatureInJavaMarkerProvider implements LineMarkerProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PsiAnnotation annotation =
|
return annotationOwner;
|
||||||
JavaDescriptorResolver.findAnnotation(annotationOwner, KOTLIN_SIGNATURE_ANNOTATION);
|
|
||||||
if (annotation == null) return null;
|
|
||||||
if (annotation.getParameterList().getAttributes().length == 0) return null;
|
|
||||||
return annotation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -169,7 +174,7 @@ public class KotlinSignatureInJavaMarkerProvider implements LineMarkerProvider {
|
|||||||
else {
|
else {
|
||||||
// TODO check if annotations are editable
|
// TODO check if annotations are editable
|
||||||
|
|
||||||
new EditSignatureBalloon(element, getKotlinSignature(annotation)).show(point, editor);
|
new EditSignatureBalloon(getAnnotationOwner(element), getKotlinSignature(annotation)).show(point, editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user