private void reportCallMayProduceNpe( ProblemsHolder holder, PsiMethodCallExpression callExpression, boolean onTheFly) { LocalQuickFix[] fix = createNPEFixes( callExpression.getMethodExpression().getQualifierExpression(), callExpression, onTheFly); holder.registerProblem( callExpression, InspectionsBundle.message("dataflow.message.npe.method.invocation"), fix); }
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; }