@Override
 public ProblemDescriptor[] checkMethod(
     @NotNull PsiMethod psiMethod, @NotNull InspectionManager manager, boolean isOnTheFly) {
   final PsiCodeBlock body = psiMethod.getBody();
   if (body != null) {
     return getDescriptions(body, manager, isOnTheFly);
   }
   return null;
 }
コード例 #2
0
  private static boolean canCallMethodsInConstructors(PsiClass aClass, boolean virtual) {
    for (PsiMethod constructor : aClass.getConstructors()) {
      if (!constructor.getLanguage().isKindOf(JavaLanguage.INSTANCE)) return true;

      PsiCodeBlock body = constructor.getBody();
      if (body == null) continue;

      for (PsiMethodCallExpression call :
          SyntaxTraverser.psiTraverser().withRoot(body).filter(PsiMethodCallExpression.class)) {
        PsiReferenceExpression methodExpression = call.getMethodExpression();
        if (methodExpression instanceof PsiThisExpression
            || methodExpression instanceof PsiSuperExpression) continue;
        if (!virtual) return true;

        PsiMethod target = call.resolveMethod();
        if (target != null && PsiUtil.canBeOverriden(target)) return true;
      }
    }

    return false;
  }