本文整理汇总了Java中com.intellij.psi.PsiMethodCallExpression.resolveMethod方法的典型用法代码示例。如果您正苦于以下问题:Java PsiMethodCallExpression.resolveMethod方法的具体用法?Java PsiMethodCallExpression.resolveMethod怎么用?Java PsiMethodCallExpression.resolveMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiMethodCallExpression
的用法示例。
在下文中一共展示了PsiMethodCallExpression.resolveMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSetSecurityManager
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
private static boolean isSetSecurityManager(
PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
@NonNls final String methodName =
methodExpression.getReferenceName();
if (!"setSecurityManager".equals(methodName)) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return false;
}
final String className = aClass.getQualifiedName();
if (className == null) {
return false;
}
return "java.lang.System".equals(className);
}
示例2: isDriverManagerGetConnection
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
private static boolean isDriverManagerGetConnection(
PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
if (!HardcodedMethodConstants.GET_CONNECTION.equals(methodName)) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return false;
}
final String className = aClass.getQualifiedName();
if (className == null) {
return false;
}
return "java.sql.DriverManager".equals(className);
}
示例3: visitMethodCallExpression
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
@NonNls final String exec = "exec";
if (!exec.equals(methodName)) {
return;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return;
}
final String className = aClass.getQualifiedName();
if (!"java.lang.Runtime".equals(className)) {
return;
}
registerMethodCallError(expression);
}
示例4: isThreadYield
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
private static boolean isThreadYield(
PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
@NonNls final String methodName =
methodExpression.getReferenceName();
if (!"yield".equals(methodName)) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return false;
}
final String className = aClass.getQualifiedName();
if (className == null) {
return false;
}
return "java.lang.Thread".equals(className);
}
示例5: isStopSuspendOrResume
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
private static boolean isStopSuspendOrResume(
PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
@NonNls final String methodName =
methodExpression.getReferenceName();
if (!("stop".equals(methodName) || "suspend".equals(methodName) ||
"resume".equals(methodName))) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return false;
}
final String className = aClass.getQualifiedName();
if (className == null) {
return false;
}
return "java.lang.Thread".equals(className);
}
示例6: visitMethodCallExpression
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
@NotNull PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
if (!HardcodedMethodConstants.NOTIFY.equals(methodName) &&
!HardcodedMethodConstants.NOTIFY_ALL.equals(methodName)) {
return;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return;
}
final PsiParameterList parameterList = method.getParameterList();
if (parameterList.getParametersCount() != 0) {
return;
}
if (SynchronizationUtil.isInSynchronizedContext(expression)) {
return;
}
registerMethodCallError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:NotifyNotInSynchronizedContextInspection.java
示例7: isRunFinalizersOnExit
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
private static boolean isRunFinalizersOnExit(
PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression =
expression.getMethodExpression();
final String methodName = methodExpression.getReferenceName();
@NonNls final String runFinalizers = "runFinalizersOnExit";
if (!runFinalizers.equals(methodName)) {
return false;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return false;
}
final PsiClass aClass = method.getContainingClass();
if (aClass == null) {
return false;
}
final String className = aClass.getQualifiedName();
if (className == null) {
return false;
}
return "java.lang.System".equals(className);
}
示例8: createFix
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Nullable
public static ReplaceWithObjectsEqualsFix createFix(@NotNull PsiMethodCallExpression call, @NotNull PsiReferenceExpression methodExpression)
{
if(!"equals".equals(methodExpression.getReferenceName()) || call.getArgumentList().getExpressions().length != 1 || !PsiUtil.getLanguageLevel(call).isAtLeast(LanguageLevel.JDK_1_7))
{
return null;
}
PsiExpression qualifier = methodExpression.getQualifierExpression();
PsiExpression noParens = PsiUtil.skipParenthesizedExprDown(qualifier);
if(noParens == null)
{
return null;
}
PsiMethod method = call.resolveMethod();
if(method != null && method.getParameterList().getParametersCount() == 1 && method.getParameterList().getParameters()[0].getType().equalsToText(CommonClassNames.JAVA_LANG_OBJECT))
{
return new ReplaceWithObjectsEqualsFix(qualifier.getText(), noParens.getText());
}
return null;
}
示例9: applyFix
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor)
{
PsiElement problemElement = descriptor.getPsiElement();
if(problemElement == null)
{
return;
}
PsiMethodCallExpression call = problemElement.getParent() instanceof PsiExpressionList && problemElement.getParent().getParent() instanceof PsiMethodCallExpression ?
(PsiMethodCallExpression) problemElement.getParent().getParent() : null;
PsiMethod targetMethod = call == null ? null : call.resolveMethod();
JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
problemElement.replace(facade.getElementFactory().createExpressionFromText(myReplacementText, null));
if(targetMethod != null)
{
ExtractMethodUtil.addCastsToEnsureResolveTarget(targetMethod, call);
}
}
示例10: visitMethodCallExpression
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
if (passed) {
return;
}
super.visitMethodCallExpression(call);
final PsiExpressionList argumentList = call.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
for (PsiExpression argument : arguments) {
if (!VariableAccessUtils.mayEvaluateToVariable(argument, variable, myBuilderPattern)) {
continue;
}
final PsiMethod method = call.resolveMethod();
if (method != null) {
final PsiClass aClass = method.getContainingClass();
if (aClass != null) {
final String name = aClass.getQualifiedName();
if (excludes.contains(name)) {
continue;
}
}
}
passed = true;
}
}
示例11: getType
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
private static Class<?> getType(UExpression expression) {
if (expression == null) {
return null;
}
if (expression instanceof PsiMethodCallExpression) {
PsiMethodCallExpression call = (PsiMethodCallExpression) expression;
PsiMethod method = call.resolveMethod();
if (method == null) {
return null;
}
String methodName = method.getName();
if (methodName.equals(GET_STRING_METHOD)) {
return String.class;
}
} else if (expression instanceof PsiLiteralExpression) {
PsiLiteralExpression literalExpression = (PsiLiteralExpression) expression;
PsiType expressionType = literalExpression.getType();
if (LintUtils.isString(expressionType)) {
return String.class;
} else if (expressionType == PsiType.INT) {
return Integer.TYPE;
} else if (expressionType == PsiType.FLOAT) {
return Float.TYPE;
} else if (expressionType == PsiType.CHAR) {
return Character.TYPE;
} else if (expressionType == PsiType.BOOLEAN) {
return Boolean.TYPE;
} else if (expressionType == PsiType.NULL) {
return Object.class;
}
}
PsiType type = expression.getExpressionType();
if (type != null) {
Class<?> typeClass = getTypeClass(type);
return typeClass != null ? typeClass : Object.class;
}
return null;
}
示例12: isElementFromSetterProperty
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public boolean isElementFromSetterProperty(@NotNull PsiElement element, @NotNull String setter) {
// java method call
PsiMethodCallExpression call = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class);
if (call != null) {
PsiMethod resolved = call.resolveMethod();
if (resolved != null) {
String javaSetter = "set" + Character.toUpperCase(setter.charAt(0)) + setter.substring(1);
return javaSetter.equals(resolved.getName());
}
}
return false;
}
示例13: doFix
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@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);
}
示例14: visitMethodCallExpression
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
final PsiMethod method = expression.resolveMethod();
if (!MethodUtils.isEquals(method) && !MethodUtils.isHashCode(method)) {
return;
}
final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (!ExpressionUtils.hasType(qualifier, "java.net.URL")) {
return;
}
registerMethodCallError(expression);
}
示例15: isNotNullCall
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
private boolean isNotNullCall(ExpressionRange delegate, PsiCodeBlock body)
{
PsiMethodCallExpression call = (PsiMethodCallExpression) delegate.restoreExpression(body);
if(call.getType() instanceof PsiPrimitiveType)
{
return true;
}
PsiMethod target = call.resolveMethod();
return target != null && NullableNotNullManager.isNotNull(target);
}