Using real annotation owner when creating popup menu action group to make it work for library without sources.

This commit is contained in:
Evgeny Gerashchenko
2012-09-06 13:41:23 +04:00
parent 9e4ebe6982
commit 6b81ba1aef
3 changed files with 9 additions and 4 deletions
@@ -24,6 +24,7 @@ import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;
import static org.jetbrains.jet.plugin.codeInsight.ktSignature.KotlinSignatureUtil.KOTLIN_SIGNATURE_ANNOTATION;
import static org.jetbrains.jet.plugin.codeInsight.ktSignature.KotlinSignatureUtil.findKotlinSignatureAnnotation;
@@ -36,7 +37,7 @@ import static org.jetbrains.jet.plugin.codeInsight.ktSignature.KotlinSignatureUt
public class DeleteSignatureAction extends AnAction {
private final PsiMethod annotationOwner;
public DeleteSignatureAction(PsiMethod annotationOwner) {
public DeleteSignatureAction(@NotNull PsiMethod annotationOwner) {
super("Delete");
this.annotationOwner = annotationOwner;
}
@@ -40,7 +40,7 @@ import static org.jetbrains.jet.plugin.codeInsight.ktSignature.KotlinSignatureUt
public class EditSignatureAction extends AnAction {
private final PsiMethod annotationOwner;
public EditSignatureAction(PsiMethod annotationOwner) {
public EditSignatureAction(@NotNull PsiMethod annotationOwner) {
super("Edit");
this.annotationOwner = annotationOwner;
}
@@ -108,8 +108,12 @@ public class KotlinSignatureInJavaMarkerProvider implements LineMarkerProvider {
public ActionGroup getPopupMenuActions() {
DefaultActionGroup actionGroup = new DefaultActionGroup();
actionGroup.add(new EditSignatureAction(getElement()));
actionGroup.add(new DeleteSignatureAction(getElement()));
PsiMethod element = getElement();
assert element != null;
PsiMethod annotationOwner = getAnnotationOwner(element);
actionGroup.add(new EditSignatureAction(annotationOwner));
actionGroup.add(new DeleteSignatureAction(annotationOwner));
return actionGroup;
}