PsiMethodCallExpression (PsiElement element) { PsiMethodCallExpression methodCallExpression = null; if (element instanceof PsiMethodCallExpression) { methodCallExpression = (PsiMethodCallExpression)element; } else if (element instanceof PsiExpressionStatement) { final PsiExpression expression = ((PsiExpressionStatement)element).getExpression(); if (expression instanceof PsiMethodCallExpression) { methodCallExpression = (PsiMethodCallExpression)expression; } else if (expression instanceof PsiAssignmentExpression) { final PsiExpression psiExpression = ((PsiAssignmentExpression)expression).getRExpression(); if (psiExpression instanceof PsiMethodCallExpression) { methodCallExpression = (PsiMethodCallExpression)psiExpression; } } } else if (element instanceof PsiDeclarationStatement) { final PsiElement[] declaredElements = ((PsiDeclarationStatement)element).getDeclaredElements(); for (PsiElement declaredElement : declaredElements) { if (declaredElement instanceof PsiLocalVariable) { final PsiExpression initializer = ((PsiLocalVariable)declaredElement).getInitializer(); if (initializer instanceof PsiMethodCallExpression) { methodCallExpression = (PsiMethodCallExpression)initializer; break; } } } } else if (element instanceof PsiIfStatement) { PsiExpression condition = ((PsiIfStatement)element).getCondition(); if (condition instanceof PsiMethodCallExpression) { methodCallExpression = (PsiMethodCallExpression)condition; } } return methodCallExpression; }