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


Java PsiMethod.equals方法代码示例

本文整理汇总了Java中com.intellij.psi.PsiMethod.equals方法的典型用法代码示例。如果您正苦于以下问题:Java PsiMethod.equals方法的具体用法?Java PsiMethod.equals怎么用?Java PsiMethod.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.PsiMethod的用法示例。


在下文中一共展示了PsiMethod.equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertNewMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
public PsiMethod insertNewMethod(PsiClass clazz, @NotNull PsiMethod newMethod, Editor editor) {

        // if main method exists and is the last then add toString just before main method
        PsiMethod mainMethod = PsiAdapter.findPublicStaticVoidMainMethod(clazz);
        if (mainMethod != null) {
            // add before main method if it is the last method
            PsiMethod[] methods = clazz.getMethods();
            if (mainMethod.equals(methods[methods.length - 1])) {
                return (PsiMethod) clazz.addBefore(newMethod, mainMethod);  // return as the method is added
            }
        }

        // otherwise add it at the end
        PsiElement last = clazz.getRBrace(); // rbrace is the last } java token. fixes bug #9
        return (PsiMethod) clazz.addBefore(newMethod, last);
    }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:InsertLastStrategy.java

示例2: isTheLastClassRef

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
static PsiMethod isTheLastClassRef(PsiElement element, PsiMethod member) {
  final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
  if ( containingMethod != null &&
      !containingMethod.hasModifierProperty(PsiModifier.STATIC) &&
      !containingMethod.isConstructor() &&
       containingMethod.findDeepestSuperMethods().length == 0 &&
      !containingMethod.equals(member)) {
    final PsiClass containingClass = containingMethod.getContainingClass();
    if (containingClass != null) {
      final PsiClass gContainingClass = containingClass.getContainingClass();
      if (gContainingClass == null || gContainingClass.hasModifierProperty(PsiModifier.STATIC)) {
        final InternalUsageInfo[] refsInMember = MakeStaticUtil.findClassRefsInMember(containingMethod, true);
        for (InternalUsageInfo info : refsInMember) {
          final PsiElement referencedElement = info.getReferencedElement();
          if (!member.equals(referencedElement) && !containingMethod.equals(referencedElement)) {
            return null;
          }
        }
        return containingMethod;
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MakeStaticJavaCallerChooser.java

示例3: methodCallExpressionDefinitelyRecurses

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static boolean methodCallExpressionDefinitelyRecurses(
    GrMethodCallExpression exp, GrMethod method) {
  final GrExpression invoked = exp.getInvokedExpression();
  if (invoked instanceof GrReferenceExpression) {
    final GrReferenceExpression methodExpression = (GrReferenceExpression) invoked;
    final PsiMethod referencedMethod = exp.resolveMethod();
    if (referencedMethod == null) {
      return false;
    }
    final GrExpression qualifier =
        methodExpression.getQualifierExpression();
    if (referencedMethod.equals(method)) {
      if (method.hasModifierProperty(PsiModifier.STATIC) ||
          method.hasModifierProperty(PsiModifier.PRIVATE)) {
        return true;
      }
      if (qualifier == null || qualifier instanceof GrReferenceExpression && PsiUtil.isThisReference(qualifier)) {
        return true;
      }
    }
    if (expressionDefinitelyRecurses(qualifier, method)) {
      return true;
    }
  }
  return callExpressionDefinitelyRecurses(exp, method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:RecursionUtils.java

示例4: invoke

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static void invoke(PsiMethod method, final Project project) {
  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, method)) return;
  if (method instanceof GrReflectedMethod) method = ((GrReflectedMethod)method).getBaseMethod();

  PsiMethod newMethod = SuperMethodWarningUtil.checkSuperMethod(method, RefactoringBundle.message("to.refactor"));
  if (newMethod == null) return;

  if (!newMethod.equals(method)) {
    ChangeSignatureUtil.invokeChangeSignatureOn(newMethod, project);
    return;
  }

  if (!CommonRefactoringUtil.checkReadOnlyStatus(project, method)) return;

  if (!(method instanceof GrMethod)) return; //todo
  final GrChangeSignatureDialog dialog = new GrChangeSignatureDialog(project, new GrMethodDescriptor((GrMethod)method), true, null);
  dialog.show();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GrChangeSignatureHandler.java

示例5: newExpressionsAreEquivalent

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
private static boolean newExpressionsAreEquivalent(@NotNull GrNewExpression newExp1,
                                                   @NotNull GrNewExpression newExp2) {
  final PsiMethod constructor1 = newExp1.resolveMethod();
  final PsiMethod constructor2 = newExp2.resolveMethod();
  if (constructor1 == null || constructor2 == null || constructor1.equals(constructor2)) {
    return false;
  }
  return argumentListsAreEquivalent(newExp1.getArgumentList(), newExp2.getArgumentList());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:EquivalenceChecker.java


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