本文整理汇总了Java中com.intellij.psi.PsiMethodCallExpression.getMethodExpression方法的典型用法代码示例。如果您正苦于以下问题:Java PsiMethodCallExpression.getMethodExpression方法的具体用法?Java PsiMethodCallExpression.getMethodExpression怎么用?Java PsiMethodCallExpression.getMethodExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.PsiMethodCallExpression
的用法示例。
在下文中一共展示了PsiMethodCallExpression.getMethodExpression方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitMethod
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor,
PsiMethodCallExpression call, PsiMethod method) {
PsiReferenceExpression methodExpression = call.getMethodExpression();
String fullyQualifiedMethodName = methodExpression.getQualifiedName();
if (fullyQualifiedMethodName.startsWith("android.util.Log")
//Handle multiple overloaded out.print(and println, etc) methods.
|| fullyQualifiedMethodName.startsWith("java.lang.System.out.print")) {
sHelper.reportIssue(context, ISSUE_LOG_CLASS, methodExpression);
return;
}
if (fullyQualifiedMethodName.equals("java.lang.String.format")) {
checkNestedStringFormat(context, call);
return;
}
}
示例2: 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);
}
示例3: 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);
}
示例4: isResourceCreation
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
protected boolean isResourceCreation(PsiExpression expression) {
if (expression instanceof PsiMethodCallExpression) {
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
@NonNls final String methodName = methodExpression.getReferenceName();
if (!"accept".equals(methodName)) {
return false;
}
final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (qualifier == null || !TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.net.ServerSocket")) {
return false;
}
return TypeUtils.expressionHasTypeOrSubtype(methodCallExpression, "java.net.Socket");
}
else if (expression instanceof PsiNewExpression) {
return TypeUtils.expressionHasTypeOrSubtype(expression, "java.net.Socket", "java.net.DatagramSocket", "java.net.ServerSocket") != null;
}
return false;
}
示例5: 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);
}
示例6: visitMethodCallExpression
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
if (!MethodCallUtils.isEqualsCall(expression)) {
return;
}
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
final PsiExpression qualifier = methodExpression.getQualifierExpression();
if (qualifier == null) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length != 1) {
return;
}
final PsiExpression argument = arguments[0];
if (!EquivalenceChecker.expressionsAreEquivalent(qualifier, argument) ||
SideEffectChecker.mayHaveSideEffects(qualifier)) {
return;
}
registerMethodCallError(expression);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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
示例10: 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);
}
示例11: visitMethodCallExpression
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
final String name = methodExpression.getReferenceName();
if (!"setScale".equals(name) && !"divide".equals(name)) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
if (PsiUtilCore.hasErrorElementChild(argumentList)) {
return;
}
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length != 1) {
return;
}
if (!TypeUtils.expressionHasTypeOrSubtype(expression, "java.math.BigDecimal")) {
return;
}
registerMethodCallError(expression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:BigDecimalMethodWithoutRoundingCalledInspection.java
示例12: visitMethodCallExpression
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
/**
* Check MethodCallExpressions for calls for default (argument less) constructor
* Produce an error if resolved constructor method is build by lombok and contains some arguments
*/
@Override
public void visitMethodCallExpression(PsiMethodCallExpression methodCall) {
super.visitMethodCallExpression(methodCall);
PsiExpressionList list = methodCall.getArgumentList();
PsiReferenceExpression referenceToMethod = methodCall.getMethodExpression();
boolean isThisOrSuper = referenceToMethod.getReferenceNameElement() instanceof PsiKeyword;
final int parameterCount = list.getExpressions().length;
if (isThisOrSuper && parameterCount == 0) {
JavaResolveResult[] results = referenceToMethod.multiResolve(true);
JavaResolveResult resolveResult = results.length == 1 ? results[0] : JavaResolveResult.EMPTY;
PsiElement resolved = resolveResult.getElement();
if (resolved instanceof LombokLightMethodBuilder && ((LombokLightMethodBuilder) resolved).getParameterList().getParameters().length != 0) {
holder.registerProblem(methodCall, "Default constructor doesn't exist", ProblemHighlightType.ERROR);
}
}
}
示例13: getMembersToImport
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@NotNull
@Override
protected List<PsiMethod> getMembersToImport(boolean applicableOnly)
{
final Project project = myMethodCall.getProject();
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
final PsiMethodCallExpression element = myMethodCall.getElement();
PsiReferenceExpression reference = element == null ? null : element.getMethodExpression();
String name = reference == null ? null : reference.getReferenceName();
if(name == null)
{
return Collections.emptyList();
}
final StaticMembersProcessor<PsiMethod> processor = new MyStaticMethodProcessor(element);
cache.processMethodsWithName(name, element.getResolveScope(), processor);
return processor.getMembersToImport(applicableOnly);
}
示例14: isResourceCreation
import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
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");
}
示例15: 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);
}