当前位置: 首页>>代码示例>>Java>>正文


Java PsiMethodCallExpression.resolveMethod方法代码示例

本文整理汇总了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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SystemSetSecurityManagerInspection.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DriverManagerGetConnectionInspection.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:RuntimeExecInspection.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ThreadYieldInspection.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ThreadStopSuspendResumeInspection.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SystemRunFinalizersOnExitInspection.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:ReplaceWithObjectsEqualsFix.java

示例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);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:ReplaceWithConstantValueFix.java

示例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;
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:VariablePassedAsArgumentExcludedVisitor.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:WrongTimberUsageDetector.java

示例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;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:14,代码来源:JavaIdeaUtils.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:InlineCallFix.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:EqualsHashCodeCalledOnUrlInspection.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:11,代码来源:NullityInferenceResult.java


注:本文中的com.intellij.psi.PsiMethodCallExpression.resolveMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。