use of com.perl5.lang.perl.idea.codeInsight.PerlMethodMember in project Perl5-IDEA by Camelcade.
the class PerlCodeGeneratorImpl method generateOverrideMethod.
@Override
public void generateOverrideMethod(PsiElement anchor, Editor editor) {
if (anchor != null) {
final List<PerlMethodMember> subDefinitions = new ArrayList<>();
PerlPackageUtil.processNotOverridedMethods(PsiTreeUtil.getParentOfType(anchor, PerlNamespaceDefinitionElement.class), subDefinitionBase -> {
subDefinitions.add(new PerlMethodMember(subDefinitionBase));
return true;
});
final MemberChooser<PerlMethodMember> chooser = new MemberChooser<PerlMethodMember>(subDefinitions.toArray(new PerlMethodMember[subDefinitions.size()]), false, true, anchor.getProject()) {
@Override
protected SpeedSearchComparator getSpeedSearchComparator() {
return new SpeedSearchComparator(false) {
@Nullable
@Override
public Iterable<TextRange> matchingFragments(@NotNull String pattern, @NotNull String text) {
return super.matchingFragments(PerlMethodMember.trimUnderscores(pattern), text);
}
};
}
@Override
protected ShowContainersAction getShowContainersAction() {
return new ShowContainersAction(IdeBundle.message("action.show.classes"), PerlIcons.PACKAGE_GUTTER_ICON);
}
};
chooser.setTitle("Override/Implement Method");
chooser.setCopyJavadocVisible(false);
chooser.show();
if (chooser.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
return;
}
StringBuilder generatedCode = new StringBuilder("");
if (chooser.getSelectedElements() != null) {
for (PerlMethodMember methodMember : chooser.getSelectedElements()) {
String code = getOverrideCodeText(methodMember.getPsiElement());
if (StringUtil.isNotEmpty(code)) {
generatedCode.append(code);
generatedCode.append("\n\n");
}
}
insertCodeAfterElement(anchor, generatedCode.toString(), editor);
}
}
}
use of com.perl5.lang.perl.idea.codeInsight.PerlMethodMember in project Perl5-IDEA by Camelcade.
the class PerlMethodMember method getParentNodeDelegate.
@Override
public MemberChooserObject getParentNodeDelegate() {
final PsiElement subDefinitionBase = getPsiElement();
final PerlNamespaceDefinitionElement parent = (PerlNamespaceDefinitionElement) PerlPsiUtil.getParentElementOrStub(subDefinitionBase, PerlNamespaceDefinitionStub.class, PerlNamespaceDefinitionElement.class);
assert (parent != null);
return new PerlMethodMember(parent);
}
Aggregations