Search in sources :

Example 1 with PerlFancyMethodQuickFix

use of com.perl5.lang.perl.idea.quickfixes.PerlFancyMethodQuickFix in project Perl5-IDEA by Camelcade.

the class PerlFancyMethodCallInspection method buildVisitor.

@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    return new PerlVisitor() {

        @Override
        public void visitMethod(@NotNull PsiPerlMethod o) {
            if (o.isObjectMethod() && o.getLastChild() instanceof PerlNamespaceElement) {
                String packageName = o.getPackageName();
                if (packageName == null) {
                    return;
                }
                PerlSubNameElement subNameElement = o.getSubNameElement();
                if (subNameElement == null) {
                    return;
                }
                String properForm = String.format("%s->%s", packageName, subNameElement.getName());
                holder.registerProblem(o, PerlBundle.message("perl.inspection.fancy.call", properForm), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new PerlFancyMethodQuickFix(properForm));
            }
        }
    };
}
Also used : PerlSubNameElement(com.perl5.lang.perl.psi.PerlSubNameElement) PsiPerlMethod(com.perl5.lang.perl.psi.PsiPerlMethod) PerlFancyMethodQuickFix(com.perl5.lang.perl.idea.quickfixes.PerlFancyMethodQuickFix) PerlNamespaceElement(com.perl5.lang.perl.psi.PerlNamespaceElement) PerlVisitor(com.perl5.lang.perl.psi.PerlVisitor) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PerlFancyMethodQuickFix (com.perl5.lang.perl.idea.quickfixes.PerlFancyMethodQuickFix)1 PerlNamespaceElement (com.perl5.lang.perl.psi.PerlNamespaceElement)1 PerlSubNameElement (com.perl5.lang.perl.psi.PerlSubNameElement)1 PerlVisitor (com.perl5.lang.perl.psi.PerlVisitor)1 PsiPerlMethod (com.perl5.lang.perl.psi.PsiPerlMethod)1 NotNull (org.jetbrains.annotations.NotNull)1