Search in sources :

Example 1 with PsiPerlSubCallExpr

use of com.perl5.lang.perl.psi.PsiPerlSubCallExpr in project Perl5-IDEA by Camelcade.

the class PerlFancyMethodQuickFix method applyFix.

@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    PsiElement method = descriptor.getPsiElement();
    assert method instanceof PerlMethod;
    PsiElement currentCallExpression = method.getParent();
    assert currentCallExpression instanceof PsiPerlSubCallExpr;
    // fixme ok, this is works, but we make syntax tree invalid, will be updated with next reparsing. Not sure it's a problem
    PerlNamespaceElement namespaceElement = ((PerlMethod) method).getNamespaceElement();
    assert namespaceElement != null;
    PerlSubNameElement subNameElement = ((PerlMethod) method).getSubNameElement();
    assert subNameElement != null;
    method.replace(PerlElementFactory.createMethodCall(project, namespaceElement.getCanonicalName(), subNameElement.getName()));
}
Also used : PerlMethod(com.perl5.lang.perl.psi.PerlMethod) PerlSubNameElement(com.perl5.lang.perl.psi.PerlSubNameElement) PsiPerlSubCallExpr(com.perl5.lang.perl.psi.PsiPerlSubCallExpr) PerlNamespaceElement(com.perl5.lang.perl.psi.PerlNamespaceElement) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PerlMethod (com.perl5.lang.perl.psi.PerlMethod)1 PerlNamespaceElement (com.perl5.lang.perl.psi.PerlNamespaceElement)1 PerlSubNameElement (com.perl5.lang.perl.psi.PerlSubNameElement)1 PsiPerlSubCallExpr (com.perl5.lang.perl.psi.PsiPerlSubCallExpr)1