use of com.intellij.psi.PsiCallExpression in project PermissionsDispatcher by hotchemi.
the class CallOnRequestPermissionsResultDetector method checkMethodCall.
private static boolean checkMethodCall(PsiMethod method, PsiClass psiClass) {
PsiCodeBlock codeBlock = method.getBody();
if (codeBlock == null) {
return false;
}
PsiStatement[] statements = codeBlock.getStatements();
for (PsiStatement statement : statements) {
if (!(statement instanceof PsiExpressionStatement)) {
continue;
}
PsiExpression expression = ((PsiExpressionStatement) statement).getExpression();
if (!(expression instanceof PsiCallExpression)) {
continue;
}
PsiCallExpression callExpression = (PsiCallExpression) expression;
String targetClassName = psiClass.getName() + "PermissionsDispatcher";
PsiMethod resolveMethod = callExpression.resolveMethod();
if (resolveMethod == null) {
continue;
}
PsiClass containingClass = resolveMethod.getContainingClass();
if (containingClass == null) {
continue;
}
if (targetClassName.equals(containingClass.getName()) && "onRequestPermissionsResult".equals(resolveMethod.getName())) {
return true;
}
}
return false;
}
Aggregations