use of com.intellij.psi.PsiMethodCallExpression in project intellij-community by JetBrains.
the class ReturnWrappedValue method fixUsage.
@Override
public void fixUsage() throws IncorrectOperationException {
PsiMethodCallExpression returnValue = (PsiMethodCallExpression) myStatement.getReturnValue();
assert returnValue != null;
PsiExpression qualifier = returnValue.getMethodExpression().getQualifierExpression();
assert qualifier != null;
MutationUtils.replaceExpression(qualifier.getText(), returnValue);
}
use of com.intellij.psi.PsiMethodCallExpression in project intellij-community by JetBrains.
the class InlineCallFix method doFix.
@Override
public void doFix(final Project project, ProblemDescriptor descriptor) {
final PsiElement nameElement = descriptor.getPsiElement();
final PsiReferenceExpression methodExpression = (PsiReferenceExpression) nameElement.getParent();
if (methodExpression == null)
return;
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression) methodExpression.getParent();
final PsiMethod method = methodCallExpression.resolveMethod();
if (method == null)
return;
inline(project, methodExpression, method);
}
use of com.intellij.psi.PsiMethodCallExpression in project intellij-community by JetBrains.
the class HibernateResourceInspection method isResourceCreation.
protected boolean isResourceCreation(PsiExpression expression) {
if (!(expression instanceof PsiMethodCallExpression)) {
return false;
}
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression) expression;
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
if (!HardcodedMethodConstants.OPEN_SESSION.equals(methodName)) {
return false;
}
final PsiExpression qualifier = methodExpression.getQualifierExpression();
return qualifier != null && TypeUtils.expressionHasTypeOrSubtype(qualifier, "org.hibernate.SessionFactory");
}
use of com.intellij.psi.PsiMethodCallExpression in project timber by JakeWharton.
the class WrongTimberUsageDetector method checkExceptionLogging.
private static void checkExceptionLogging(JavaContext context, PsiMethodCallExpression call) {
PsiExpression[] arguments = call.getArgumentList().getExpressions();
if (arguments.length > 1) {
boolean isFirstParameterThrowable = isSubclassOf(context, arguments[0], Throwable.class);
if (isFirstParameterThrowable) {
PsiExpression secondArgument = arguments[1];
String message = findLiteralValue(secondArgument);
boolean callsGetMessage = false;
if (secondArgument instanceof PsiMethodCallExpression) {
PsiMethodCallExpression callExpression = (PsiMethodCallExpression) secondArgument;
callsGetMessage = callExpression.getMethodExpression().getCanonicalText().endsWith("getMessage");
}
if (callsGetMessage) {
context.report(ISSUE_EXCEPTION_LOGGING, secondArgument, context.getLocation(secondArgument), "Explicitly logging exception message is redundant");
} else if (message == null || "".equals(message)) {
context.report(ISSUE_EXCEPTION_LOGGING, secondArgument, context.getLocation(secondArgument), "Use single-argument log method instead of null/empty message");
}
}
}
}
use of com.intellij.psi.PsiMethodCallExpression in project intellij-community by JetBrains.
the class MethodCallSelectioner method select.
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
PsiMethodCallExpression methodCall = (PsiMethodCallExpression) e;
PsiElement referenceNameElement = methodCall.getMethodExpression().getReferenceNameElement();
if (referenceNameElement == null) {
return null;
} else {
return Collections.singletonList(new TextRange(referenceNameElement.getTextRange().getStartOffset(), methodCall.getTextRange().getEndOffset()));
}
}
Aggregations