Search in sources :

Example 1 with USuperExpression

use of org.jetbrains.uast.USuperExpression in project kotlin by JetBrains.

the class WrongCallDetector method visitMethod.

@Override
public void visitMethod(@NonNull JavaContext context, @Nullable UastVisitor visitor, @NonNull UCallExpression node, @NonNull UMethod calledMethod) {
    // Call is only allowed if it is both only called on the super class (invoke special)
    // as well as within the same overriding method (e.g. you can't call super.onLayout
    // from the onMeasure method)
    UExpression operand = node.getReceiver();
    if (!(operand instanceof USuperExpression)) {
        report(context, node, calledMethod);
        return;
    }
    PsiMethod method = UastUtils.getParentOfType(node, UMethod.class, true);
    if (method != null) {
        String callName = node.getMethodName();
        if (callName != null && !callName.equals(method.getName())) {
            report(context, node, calledMethod);
        }
    }
}
Also used : UExpression(org.jetbrains.uast.UExpression) USuperExpression(org.jetbrains.uast.USuperExpression) PsiMethod(com.intellij.psi.PsiMethod)

Aggregations

PsiMethod (com.intellij.psi.PsiMethod)1 UExpression (org.jetbrains.uast.UExpression)1 USuperExpression (org.jetbrains.uast.USuperExpression)1